// JavaScript Document
var tm=0;
var ctimeNew_2=0;
var ctimeNew_3=0;
var ctimeNew=0;
function showDiv(divID)
{
	var objPopup = document.getElementById(divID);		
	if(objPopup.style.display == '')
	{
	    clearTimeout(ctimeNew);
		clearTimeout(ctimeNew_2);
		objPopup.style.display = '';				
	}
	
}
function HideDiv(divID)
{	
	clearTimeout(ctimeNew);
	ctimeNew=setTimeout('hidesByName("' + divID + '")',1000);
}
function LoadPhotoPage(ID,ImgStyle,LinkSrc)
{

	//http://www.jamesmetzger.net/wordpress/jcm	   	 //window.open('/wordpress/jcm/?page_id=241&ImdId='+ID,'','toolbar=no,location=no,status=1,menubar=no,resizable=no,width=225,height=250,addressbar=0'); 
	if(LinkSrc.indexOf("http://www.laxpower.com/all-amer/aa_historical_men_list.php") > -1)
	{		
		document.forms[0].submit();
		//document.myform.submit();
	}
	else if(LinkSrc.indexOf("www.jamesmetzger.net") > -1 || LinkSrc.indexOf("localhost") > -1)
	{
		//alert("Same site");
		document.location=LinkSrc;
	}
	else
	{
		window.open(LinkSrc); //to open in new window
		//alert("Another site");
	}
	
	
	//document.location='/wordpress/jcm/?page_id=241&ImgId='+ID+'&ImageStyle='+ImgStyle;
	
	
}
function  HideAllPopUps()
{
	if(document.getElementById('DivHighlightedLeft')!=null)
	    document.getElementById('DivHighlightedLeft').style.display='none';
	if(document.getElementById('DivHighlightedImage')!=null)
		document.getElementById('DivHighlightedImage').style.display='none';
}
function showDivByName(obj,event,divID,Title,ImageName,Description,ParticipatingTeams,Players,ImgDate,ImgId,ImgStyle,Location,Position,LinkSrc)
{  	


    HideAllPopUps();
	posHorizontal = 0;
	posVertical =0;
	var temp = 0;
	var temp2 = 0;
	//alert(divID);	
		var objPopup = document.getElementById(divID);	
		if(objPopup.style.display == '')
			objPopup.style.display = 'none';	
			
		clearTimeout(ctimeNew);
		clearTimeout(ctimeNew_2);
	 	if (objPopup.style.left=='');
		{		
				objPopup.style.left ="325";
		}
		
		//objPopup.style.left = findPosX(obj)-300 + "px";
		//position =left means highlighting left popup otherwise right
		if(Position=="ADMINLEFT")
			objPopup.style.left = findPosX(obj)+300+ "px";
		else if(Position=="LEFT")
			objPopup.style.left = findPosX(obj)+245+ "px";
		else		
			objPopup.style.left = findPosX(obj)-300+ "px";		
		if (event.pageX)	//Mozilla  or chrome    All other browser's other than IE Will take the page left = actual page left and the left blank space  so it is a problem in wide screen  -Rinosh
		{
			objPopup.style.left = objPopup.style.left - document.getElementById('content').offsetLeft;
		}
		//objPopup.style.top = obj.offsetTop+ 252 +"px";
		if(Position=="ADMINLEFT")
			objPopup.style.top = obj.offsetTop+ 195 +"px";	
		else		
		    objPopup.style.top = obj.offsetTop+ 245 +"px";	
		//if Position  argument is LEFT we have to load Left popup  and if RIGHT -we have to load right	
		 
		 
	    if(Position=="LEFT" || Position=="ADMINLEFT")
		{
			ctimeNew_2 = setTimeout('showLeftPopUp("' + divID +'","' +Title +'","' +ImageName +'","' +Description +'","' +ParticipatingTeams +'","' +Players+'","' +ImgDate +'","' +ImgId+'","' +ImgStyle+'","' +Location+'","' +Position+'","' +LinkSrc+'")',0);
		}
		else
			ctimeNew_2 = setTimeout('showLinksByName("' + divID +'","' +Title +'","' +ImageName +'","' +Description +'","' +ParticipatingTeams +'","' +Players+'","' +ImgDate +'","' +ImgId+'","' +ImgStyle+'","' +Location+'","' +Position+'","' +LinkSrc+'")',0);
		
}

function findPosX(obj)
  {
    var curleft = 0;
    if(obj.offsetParent)
	{
		
        while(1) 
        {
          curleft += obj.offsetLeft;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
		curleft = curleft -125;
	}
	else if(obj.x)
	{
        curleft +=  obj.x ;
	}
    return curleft;
  }

function hideDivByName(obj,tm,divID)
{ 	
	clearTimeout(ctimeNew);
	ctimeNew = setTimeout('hidesByName("' + divID + '")',tm);
}
function hidesByName(divId)
{ 	
	document.getElementById(divId).style.display='none';
}
function trim(str, chars) 
{
	return ltrim(rtrim(str, chars), chars);
}
function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}
 
function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
function showLeftPopUp(divId,Title,ImageName,Description,ParticipatingTeams,Players,ImgDate,ImgId,ImgStyle,Location,Position,LinkSrc)
{ 	
    //LPP-LeftPopp  
	//with out Lpp its right pop up these two are used to highlight codes in MileStoneLeftPopUp.php and MileStoneRightPopUp.php
	//called from  MileStoneLeftFilmStrip.php and MileStoneRightFilmStrip.php
	var Displayfooter =false;
	document.getElementById("MessageLabelLPP").innerHTML =Title;
	
	if(trim(ImgDate)!='')
	{
		document.getElementById("trPopUpDateLPP").style.display = '';
		document.getElementById("popupDateLPP").innerHTML =ImgDate;	
		 Displayfooter=true;
	}
	else
    {
		document.getElementById("trPopUpDateLPP").style.display = 'none';
	   document.getElementById("popupDateLPP").innerHTML ="&nbsp;";
	}
	
	//alert(ImgStyle);
	//alert('<img width="340px" src="/wordpress/JCM/PopupImages/'+ImageName+'" onClick="LoadPhotoPage(\''+ImgStyle+'\',\''+ImgId+'\');" style="cursor:hand;cursor:pointer;">');
	var SiteUrl="'"+window.location+"'";
	if(SiteUrl.indexOf("page_id=753") > -1 )
		document.getElementById("tdImageLPP").innerHTML ='<img height="245px" src="/wordpress/JCM/wp-content/images/MileStoneImages/Thumbnails/'+ImageName+'" onClick="LoadPhotoPage('+ImgId+','+ImgStyle+',\''+LinkSrc+'\');" style="cursor:hand;cursor:pointer;">';	
	else	
		document.getElementById("tdImageLPP").innerHTML ='<img width="340px" src="/wordpress/JCM/wp-content/images/MileStoneImages/Thumbnails/'+ImageName+'" onClick="LoadPhotoPage('+ImgId+','+ImgStyle+',\''+LinkSrc+'\');" style="cursor:hand;cursor:pointer;">';	
	
	document.getElementById("imageLeftBottomCornerLPP").onclick =function(){ LoadPhotoPage(ImgId,ImgStyle,LinkSrc)};
	//document.getElementById("imageLeftBottomCorner").style.cursor='cursor:pointer';
	//document.getElementById("MessageTitle").innerHTML =Title;
	
	if(trim(Description)!='')
	{
		document.getElementById("trDescriptionLPP").style.display = '';
		document.getElementById("MessageDescriptionLPP").innerHTML =Description;
		 Displayfooter=true;
	}
	else
	{
		document.getElementById("trDescriptionLPP").style.display = 'none';
		document.getElementById("MessageDescriptionLPP").innerHTML ="&nbsp;";
	}	
	
	if(Location!="")
	{
		document.getElementById("trLocationLPP").style.display = '';
		document.getElementById("MessageLocationLPP").innerHTML =Location;
		document.getElementById("MessageTeamsLPP").className = 'withBorder';	
		 Displayfooter=true;
	}
	else
	{
		//alert(document.getElementById("MessageTeams").innerHTML);		
		document.getElementById("MessageTeamsLPP").className = 'withoutBoarder';			
		//alert(document.getElementById("MessageTeams").style.cssClass);
		document.getElementById("trLocationLPP").style.display = 'none';
	}	
	if(ParticipatingTeams!="")
	{
		document.getElementById("trParticipatingTeamsLPP").style.display = '';
		document.getElementById("MessageTeamsLPP").innerHTML =ParticipatingTeams;
		document.getElementById("MessagePlayersLPP").className = 'withBorder';	
		 Displayfooter=true;
	}
	else
	{
		if(Location=="")
		{
			document.getElementById("MessagePlayersLPP").className = 'withoutBoarder';	
		}		
		document.getElementById("trParticipatingTeamsLPP").style.display = 'none';
	}	
	
	if(Players!="")
	{		
		document.getElementById("trPlayersLPP").style.display = '';			
		document.getElementById("MessagePlayersLPP").innerHTML =Players;
		 Displayfooter=true;
	}
	else
	{		
		document.getElementById("trPlayersLPP").style.display = 'none';
	}	
	//alert(document.getElementById("MessageTeams").style.cssClass);
	if( Displayfooter==true)
	{
		document.getElementById("trBottomSpaceLPP").style.display = '';
	}
	else
	{
		document.getElementById("trBottomSpaceLPP").style.display = 'none';
	}
	document.getElementById(divId).style.display='';
		
}
function showLinksByName(divId,Title,ImageName,Description,ParticipatingTeams,Players,ImgDate,ImgId,ImgStyle,Location,Position,LinkSrc)
{ 	
    //LPP-LeftPopp  
	//with out Lpp its right pop up these two are used to highlight codes in MileStoneLeftPopUp.php and MileStoneRightPopUp.php
	//called from  MileStoneLeftFilmStrip.php and MileStoneRightFilmStrip.php
	//if Position  argument is LEFT we have to load Left popup  and if RIGHT -we have to load right	
	var Displayfooter =false;
	document.getElementById("MessageLabel").innerHTML =Title;
	document.getElementById("popupDate").innerHTML =ImgDate;		
	if(trim(ImgDate)!='')
	{
		document.getElementById("trPopUpDate").style.display = '';
		document.getElementById("popupDate").innerHTML =ImgDate;	
		 Displayfooter=true;
	}
	else
    {
		document.getElementById("trPopUpDate").style.display = 'none';
	   document.getElementById("popupDate").innerHTML ="&nbsp;";
	}
	//alert(ImgStyle);
	//alert('<img width="340px" src="/wordpress/JCM/PopupImages/'+ImageName+'" onClick="LoadPhotoPage(\''+ImgStyle+'\',\''+ImgId+'\');" style="cursor:hand;cursor:pointer;">');
	
	document.getElementById("tdImage").innerHTML ='<img width="340px" src="/wordpress/JCM/wp-content/images/MileStoneImages/Thumbnails/'+ImageName+'" onClick="LoadPhotoPage('+ImgId+','+ImgStyle+',\''+LinkSrc+'\');" style="cursor:hand;cursor:pointer;">';	
	//document.getElementById("tdImage").innerHTML ='<img width="340px" src="/wordpress/JCM/PopupImages/'+ImageName+'" onClick="LoadPhotoPage('+ImgId+','+ImgStyle+','+LinkSrc+');" style="cursor:hand;cursor:pointer;">';	
	document.getElementById("imageLeftBottomCorner").onclick =function(){ LoadPhotoPage(ImgId,ImgStyle,LinkSrc)};
	//document.getElementById("imageLeftBottomCorner").style.cursor='cursor:pointer';
	//document.getElementById("MessageTitle").innerHTML =Title;
	//document.getElementById("MessageDescription").innerHTML =Description;
	if(trim(Description)!='')
	{
		document.getElementById("trDescription").style.display = '';
		document.getElementById("MessageDescription").innerHTML =Description;
		Displayfooter=true;
	}
	else
	{
		document.getElementById("trDescription").style.display = 'none';
		document.getElementById("MessageDescription").innerHTML ="&nbsp;";
	}	
	
	if(Location!="")
	{
		document.getElementById("trLocation").style.display = '';
		document.getElementById("MessageLocation").innerHTML =Location;
		document.getElementById("MessageTeams").className = 'withBorder';	
		 Displayfooter=true;
	}
	else
	{
		//alert(document.getElementById("MessageTeams").innerHTML);		
		document.getElementById("MessageTeams").className = 'withoutBoarder';			
		//alert(document.getElementById("MessageTeams").style.cssClass);
		document.getElementById("trLocation").style.display = 'none';
	}
	
	if(ParticipatingTeams!="")
	{
		document.getElementById("trParticipatingTeams").style.display = '';
		document.getElementById("MessageTeams").innerHTML =ParticipatingTeams;
		document.getElementById("MessagePlayers").className = 'withBorder';	
		Displayfooter=true;
	}
	else
	{
		if(Location=="")
		{
			document.getElementById("MessagePlayers").className = 'withoutBoarder';	
		}		
		document.getElementById("trParticipatingTeams").style.display = 'none';
	}	
	
	if(Players!="")
	{		
		document.getElementById("trPlayers").style.display = '';			
		document.getElementById("MessagePlayers").innerHTML =Players;
		 Displayfooter=true;
	}
	else
	{		
		document.getElementById("trPlayers").style.display = 'none';
	}	
	//alert(document.getElementById("MessageTeams").style.cssClass);
	
	if( Displayfooter==true)
	{
		document.getElementById("trBottomSpace").style.display = '';
	}
	else
	{
		document.getElementById("trBottomSpace").style.display = 'none';
	}
	
	document.getElementById(divId).style.display='';
		
}
function showPopUpWindow(obj,event,divId,Title,ImageName,Description,ParticipatingTeams,Players)
{ 	

	document.getElementById("MessageLabelOnWindow").innerHTML =ImageName;			
	document.getElementById("PopUpImageOnWindow").src ='/wordpress/JCM/PopupImages/'+ImageName;	
	document.getElementById("MessageTitleOnWindow").innerHTML =Title;
	document.getElementById("MessageDescriptionOnWindow").innerHTML =Description;	
	document.getElementById("MessageTeamsOnWindow").innerHTML =ParticipatingTeams;
	document.getElementById("MessagePlayersOnWindow").innerHTML =Players;
	document.getElementById(divId).style.display='';		
}
function hidePopUpWindow(divId)
{ 	
	document.getElementById(divId).style.display='none';
}
//To position the popup 
function getY( oElement )
{
	var iReturnValue = 0;
	while( oElement != null ) {
	iReturnValue += oElement.offsetTop;
	oElement = oElement.offsetParent;
}
	return iReturnValue;
}

function getX( oElement )
{
	var iReturnValue = 0;
	while( oElement != null ) {
	iReturnValue += oElement.offsetLeft;
	oElement = oElement.offsetParent;
}
	return iReturnValue;
}

