function openWindow(url, name) {
  var l = openWindow.arguments.length;
  var w = "";
  var h = "";
  var features = "";

  for (i=2; i<l; i++) {
    var param = openWindow.arguments[i];
    if ( (parseInt(param) == 0) ||
      (isNaN(parseInt(param))) ) {
      features += param + ',';
    } else {
      (w == "") ? w = "width=" + param + "," :
       h = "height=" + param;
    }
  }

  features += w + h;
  var code = "popupWin = window.open(url, name";
  if (l > 2) code += ", '" + features;
  code += "')";
  eval(code);
  }
  
// write media player javascript
document.write('<script src="/mediaplayer/player.js" language="JavaScript"></script>');

PBSAudioWindow_X=354;
PBSAudioWindow_Y=128;

PBSVideoWindow_X=570;
PBSVideoWindow_Y=450;


// email this page
var fileName = document.URL;
escapedFileName = escape(fileName);
function openemail()
{
var popurl="email_friend/email.html?"+escapedFileName;
winpops=window.open(popurl,"","width=403,height=365,status,scrollbars");
}

// feedback

function feedback()
{
var popurl="feedback/feedback.html?"+escapedFileName;
winpops=window.open(popurl,"","width=429,height=388,status");
}


// pop printable page
var fileName = location.pathname.substring(location.pathname.lastIndexOf('/')+1)
function popprint() {openWindow('print/p_'+ fileName +'','printpop', 567, 430, 'resizable', 'toolbar', 'status', 'scrollbars', 'menubar');}

// drop down menu
function gotosite(site) {            
        if (site != "") {                    
                self.location=site; 
        }
}      
//stay
function stay() {if (document.images) document.stay.src= 'images/spacer.gif'}


/*
 * This function parses ampersand-separated name=value argument pairs from
 * the query string of the URL. It stores the name=value pairs in 
 * properties of an object and returns that object.
 */
function getArgs() {
    var args = new Object();
    var query = location.search.substring(1);  // Get query string.
    var pairs = query.split("&");              // Break at ampersand.
    for(var i = 0; i < pairs.length; i++) {
	var pos = pairs[i].indexOf('=');       // Look for "name=value".
	if (pos == -1) continue;               // If not found, skip.
	var argname = pairs[i].substring(0,pos);  // Extract the name.
	var value = pairs[i].substring(pos+1); // Extract the value.
	args[argname] = unescape(value);          // Store as a property.
    }
    return args;                               // Return the object.
}

function getScore(a1, a2, a3, a4, a5, a6, a7, a8, a9, a10) {
  var score = 0;
  if (a1 == 'd') { score++; }
  if (a2 == 'c') { score++; }
  if (a3 == 'd') { score++; }
  if (a4 == 'c') { score++; }
  if (a5 == 'b') { score++; }
  if (a6 == 'a') { score++; }
  if (a7 == 'c') { score++; }
  if (a8 == 'b') { score++; }
  if (a9 == 'b') { score++; }
  if (a10 == 'd') { score++; }
  
  var message = '';
  if (score == 9) {
    message = "";
  } else if (score > 5) {
    message = "";
  } else if (score > 2) {
    message = '';
  }
  var table = '';
  table += ''+ score +'';
  table += '';
  return table;
}

function getAnswer(q, a) {
  if (q == 'q1') {
    if (a == 'a') {
      return 'Don\'t let the steer dawdle, keep them moving at a gallop';
    } else if (a == 'b') {
      return 'Longhorns are obstinate, shout to make yourself clear';
    } else if (a == 'c') {
      return 'Bring a female cow to keep the steers from running away';
    } else if (a == 'd') {
      return 'Cattle are sensitive. Don\'t be unduly rough';
    }
	
  } else if (q == 'q2') {
    if (a == 'a') {
      return 'Longhorns are alert, nervous and quick to stampede';
    } else if (a == 'b') {
      return 'Steers are slow to mature and gain weight';
    } else if (a == 'c') {
      return 'Longhorns require lots of feeding, care and maintenance';
    } else if (a == 'd') {
      return 'Their horns are twisted and turn wrinkled with age';
    }
	
  } else if (q == 'q3') {
    if (a == 'a') {
      return 'North Star';
    } else if (a == 'b') {
      return 'Big Dipper';
    } else if (a == 'c') {
      return 'Seven Stars';
    } else if (a == 'd') {
      return 'Alpha Centauri';
    }
	
  } else if (q == 'q4') {
    if (a == 'a') {
      return 'Only one, the horse-cowboy bond is like a marriage, monogamous';
    } else if (a == 'b') {
      return 'Two, one is a back up should his first get injured';
    } else if (a == 'c') {
      return 'Three to six, depending on his tasks, time of year and size of outfit';
    } else if (a == 'd') {
      return 'Only one, it is the ranch owner who usually has five or six';
    }
	
  } else if (q == 'q5') {
    if (a == 'a') {
      return 'Coax calves away from their mothers';
    } else if (a == 'b') {
      return 'Invite the cattle\'s owner to a necktie party';
    } else if (a == 'c') {
      return 'Alter the brand with a running iron';
    } else if (a == 'd') {
      return 'Start a stampede';
    }
	
  } else if (q == 'q6') {
    if (a == 'a') {
      return 'Wood ashes and lard';
    } else if (a == 'b') {
      return 'Horse hooves and egg whites';
    } else if (a == 'c') {
      return 'Beeswax and molasses';
    } else if (a == 'd') {
      return 'Marrow and hay';
    }
	
  } else if (q == 'q7') {
    if (a == 'a') {
      return 'Telling tall tales of wild coyotes, near-death duels and Indians';
    } else if (a == 'b') {
      return 'Memorizing the labels on airtights and the copy of catalogues';
    } else if (a == 'c') {
      return 'Bragging about one\'s prowess or superior book learning';
    } else if (a == 'd') {
      return 'Curling the paint off the bunkhouse with creative cussing';
    }
	
  } else if (q == 'q8') {
    if (a == 'a') {
      return 'The horn is handy for repeated mounting and dismounting';
    } else if (a == 'b') {
      return 'He uses the horn to secure his lariat during dallying';
    } else if (a == 'c') {
      return 'He sounds the horn to alert others of Indians or rustlers';
    } else if (a == 'd') {
      return 'None of the above';
    }
	
  } else if (q == 'q9') {
    if (a == 'a') {
      return 'Gathering round browns';
    } else if (a == 'b') {
      return 'Dozing under the chuck wagon';
    } else if (a == 'c') {
      return 'Keeping pie-biters away from his foodstuffs';
    } else if (a == 'd') {
      return 'Cranking the grinder';
    }

  } else if (q == 'q10') {
    if (a == 'a') {
      return 'Never make yourself the hero of your own story';
    } else if (a == 'b') {
      return 'Do eat chicken gizzards. You will be pretty';
    } else if (a == 'c') {
      return 'Use rattlesnake oil to cure corns, calluses, and bunions';
    } else if (a == 'd') {
      return 'Flatter the men in your life. They work hard';
    }
  } 
  return '';
}
