// JavaScript Document

function showDiv(the_div,the_change){
  var the_style = getStyleObject(the_div);
  if (the_style != false){

  if(the_style.display=='block'){
      the_style.display = 'none';
  }else{
    the_style.display = the_change;
	}
  }
}


function hideDiv(the_div,the_change){
  var the_style = getStyleObject(the_div);
  the_style.display = 'none';
}

function hide5Div(the_div1,the_div2,the_div3,the_div4,the_div5,the_imgdiv1,the_imgdiv2,the_imgdiv3,the_imgdiv4,the_imgdiv5,the_change){
  var the_style = getStyleObject(the_div1);the_style.display = 'none';
   var the_style = getStyleObject(the_div2);the_style.display = 'none';
    var the_style = getStyleObject(the_div3);the_style.display = 'none';
	 var the_style = getStyleObject(the_div4);the_style.display = 'none';
	  var the_style = getStyleObject(the_div5);the_style.display = 'none';
		var the_style = getStyleObject(the_imgdiv1);the_style.display = 'none';
		   var the_style = getStyleObject(the_imgdiv2);the_style.display = 'none';
			var the_style = getStyleObject(the_imgdiv3);the_style.display = 'none';
			 var the_style = getStyleObject(the_imgdiv4);the_style.display = 'none';
			  var the_style = getStyleObject(the_imgdiv5);the_style.display = 'none';
}


function getStyleObject(objectId) {
  if (document.getElementById && document.getElementById(objectId)) {
    return document.getElementById(objectId).style;
  } else if (document.all && document.all(objectId)) {
    return document.all(objectId).style;
  } else {
    return false;
  }
}

function init(){

	empty_mc = document.getElementById('varsity_menu');
	dummy_mc = document.getElementById('main-menu-holder');
	dummy_mc2 = document.getElementById('main-menu-holder2');
	
	empty_mc.onload = moveSquareUp();
	empty_mc.onload = moveSquareUp2();
	/*empty_mc.onmouseout = function(){
		if(1*document.Show.MouseX.value > 165 && 1*document.Show.MouseX.value<383 && 1*document.Show.MouseY.value > 391 && 1*document.Show.MouseY.value < 706){
		}else{
		moveSquareDown();
		}
	}*/
}

function moveSquareUp(evt){
	zz = new Tween(dummy_mc.style,'left','',parseInt(dummy_mc.style.left),0,10,'px');
	zzz = new Tween(dummy_mc.style,'top','',parseInt(dummy_mc.style.top),250,10,'px');
		if(!evt) evt = window.event;
		var x = 20;
		var y = 114;
		var duration = document.getElementById('myDuration').value;
		var easingFunc = Tween.strongEaseInOut;
		isNaN(duration) ? duration = 1 : null;
		zz.func = easingFunc;
		zz.continueTo(x,duration);
		zzz.func = easingFunc;
		zzz.continueTo(y,duration);
		//zzz.onMotionFinished = function(){alert( 'onMotionFinished' )};

}

function moveSquareUp2(evt){
	zz = new Tween(dummy_mc2.style,'left','',parseInt(dummy_mc2.style.left),0,10,'px');
	zzz = new Tween(dummy_mc2.style,'top','',parseInt(dummy_mc2.style.top),250,10,'px');
		if(!evt) evt = window.event;
		var x = 20;
		var y = 168;
		var duration = document.getElementById('myDuration').value;
		var easingFunc = Tween.strongEaseInOut;
		isNaN(duration) ? duration = 1 : null;
		zz.func = easingFunc;
		zz.continueTo(x,duration);
		zzz.func = easingFunc;
		zzz.continueTo(y,duration);
		//zzz.onMotionFinished = function(){alert( 'onMotionFinished' )};

}

function moveSquareDown(evt){
	zz = new Tween(dummy_mc.style,'left','',parseInt(dummy_mc.style.left),0,10,'px');
	zzz = new Tween(dummy_mc.style,'top','',parseInt(dummy_mc.style.top),350,10,'px');
		if(!evt) evt = window.event;
		var x = 20;
		var y = 384;
		var duration = document.getElementById('myDuration').value;
		var easingFunc = Tween.strongEaseInOut;
		isNaN(duration) ? duration = 1 : null;
		zz.func = easingFunc;
		zz.continueTo(x,duration);
		zzz.func = easingFunc;
		zzz.continueTo(y,duration);	
}

// Main function to retrieve mouse x-y pos.s

function getMouseXY(e) {
  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
  // show the position values in the form named Show
  // in the text fields named MouseX and MouseY
  
  document.Show.MouseX.value = tempX
  document.Show.MouseY.value = tempY
  return true
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function viewNotes(sport_id,language,divID, imgURL, offset, pNum, lName, fName, htw, hSchool, cTeam, dob, ht, wt, pos, elig, shoots, prg, statistics, biography) {
	if(pNum == '0') pNum = '&nbsp;';
	if(language == 'fra'){
		var Caption = new Array('Pr&eacute;nom','Nom','Taille','Poids','&Eacute;cole secondaire','&Eacute;lig','Tirs/Attrape','Dipl&ocirc;me','Ville d\'origine','Sp&eacute;cialit&eacute;','Biographie','Date de naissance','&Eacute;quipe pr&eacute;c&eacute;dente','Statistiques' );
		if(shoots == 1)
			cShoots = 'Droite';
		else if(shoots == 2)
			cShoots = 'Nil';
		else cShoots = 'Gauche';
	}
	else{
		var Caption = new Array('First&nbsp;Name','Last Name','Height','Weight','High School','Elig','Shoots/Catch','Program','Home town','Discipline','Biography','Birth Date','Last Team','Statistics');
		if(shoots == 1)
			cShoots = 'Right';
		else if(shoots == 2)
			cShoots = 'None';
		else cShoots = 'Left';
	}
	var yPos = document.getElementById('test'+offset).offsetTop;
	if(document.getElementById(divID)){
		var space = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:';
		document.getElementById(divID).style.visibility = "visible";
		//document.getElementById('content-frame').style.zIndex = 151;
		
		document.getElementById(divID).style.left = 150 + "px";
		//document.getElementById(divID).style.top = 375 + offset + "px";
		document.getElementById(divID).style.top = 335 + yPos + "px";
		document.getElementById(divID).style.zIndex = 15 ;
		document.getElementById(divID).style.color = "#ffffff";
		
		document.getElementById(divID).innerHTML = '<div id="Close1" style = "background-color:#900028;text-align:right;" onclick = "return hideNotes(\''+divID+'\')"><a href="#summary" style="color:#ffffff;text-decoration:none">Close&nbsp;</a></div>';

		document.getElementById(divID).innerHTML += '<table id = "info" border = "0" cellspacing = "0" cellpadding = "0" bgcolor = "#000000">';
		$hasBiography = 0;
		if(biography != ''){
			addRows('playersBiography','<table bgcolor = "#000000" border = "0" cellpadding = "5" width = "550">'+ biography +'</table></td></tr>');
			addRows('biography','<strong>'+Caption[10]+'</strong>');
			addRows('biography','&nbsp;');
			$hasBiography = 1;
		}
		if(statistics != '')
			addRows('statistics','<a id = "pStats" href = "'+ statistics +'">' + Caption[13] + '</a>');
		if(prg != '')
			addRows('&nbsp;&nbsp;' + Caption[7], space +  prg);
		if(shoots != 2 && (sport_id == 26 || sport_id == 16))
			addRows('&nbsp;&nbsp;' + Caption[6], space + cShoots);
		if(elig != '')
			addRows('&nbsp;&nbsp;' + Caption[5], space + elig);
		if(sport_id != 19 && sport_id != 21 && sport_id != 24){
			if(pos != '')
				addRows('&nbsp;&nbsp;POS', space + pos);
		}
		else{ //Track , Cross-contry, swimming
			if(pos != '')
				addRows('&nbsp;&nbsp;' + Caption[9], space + pos); 
		}
		if(wt != '')
			addRows('&nbsp;&nbsp;' + Caption[3], space + wt);
		if(ht != '')
			addRows('&nbsp;&nbsp;' + Caption[2], space + ht);
		//if(dob != '0000-00-00')
			//addRows('&nbsp;&nbsp;' + Caption[10], space +  dob);
		if(cTeam != '')
			addRows('&nbsp;&nbsp;' + Caption[12], space +  cTeam);
		if(hSchool != '')
			addRows('&nbsp;&nbsp;' + Caption[4], space + hSchool);
		if(htw != '')
			addRows('&nbsp;&nbsp;' + Caption[8], space + htw);
		addRows('playerHeading','<table width = 100% bgcolor = "#000000"><tr><td width = 25% align = "left"><font size = "5">'+pNum+'</font></td><td width = 50% align = "center">'+fName+' '+lName+'</td><td width = 25% align = "right"><img src = "/sites/all/themes/geegees/geegee-images/bio_geegees.gif"></image></td></tr></table><hr>');
		addRows('playerImage'+$hasBiography,'<img  src = "' + imgURL + '" width="150" border="1" height="206" />');
		document.getElementById(divID).innerHTML += '</table>';
	}
}

function addRows(name, value){
	var getTable = document.getElementById("info").insertRow(0);
	if(name == 'playerImage0' || name == 'playerImage1' || name == 'statistics' || name == 'playerHeading' || name == 'biography' || name == 'playersBiography'){
		var data = getTable.insertCell(0);
		if(name == 'playerImage0')
			data.setAttribute("rowspan",document.getElementById("info").rows.length);
		else if(name == 'playerImage1')
			data.setAttribute("rowspan",document.getElementById("info").rows.length - 3);
		else if(name == 'statistics' || name == 'playerHeading'){
			data.setAttribute("colspan",2);
			data.setAttribute("align","center");
		}
		else if(name == 'biography' || name == 'playersBiography'){
			data.setAttribute("colspan",3);
			if(name == 'biography')
				data.setAttribute("align","center");
		}
		data.innerHTML = value;
	}
	else{
		var title = getTable.insertCell(0);
		var data = getTable.insertCell(1);
		title.innerHTML = name;
		data.innerHTML = value;
	}
	//getTable.deleteRow(0);
}
function view_Ticket_Notes(divID, offset, text) {
		
	if(document.getElementById(divID)){
		//var space = '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;:';
		document.getElementById(divID).style.visibility = "visible";
		document.getElementById('content-frame').style.zIndex = 151;
		document.getElementById(divID).style.left = 220 + "px";
		document.getElementById(divID).style.top = 180 + offset + "px";
		document.getElementById(divID).style.color = "#ffffff";
		
		document.getElementById(divID).innerHTML = '<div style = "background-color:#900028;text-align:right;" onclick = "return hideNotes(\''+divID+'\')"><a href="#" style="color:#ffffff;text-decoration:none">Close&nbsp;</a></div>';

		document.getElementById(divID).innerHTML += '<table id ="info"  border = "1" cellspacing = "4" cellpadding = "4">';
		document.getElementById(divID).innerHTML += '<tr><td><div align="left">' + text +'</div></td></tr></table>';
	}
}
//end of viewNotes


function hideNotes(divID) {
	document.getElementById(divID).style.visibility = "hidden";
	document.getElementById('content-frame').style.zIndex = 150;
}
