﻿var SEND_TO_FRIEND_URL = "/Archive/Pages/SendToAFriend.aspx";
var iCurrentPic = 1;
var gAutoPrint = true; // Tells whether to automatically call the print function
/*function EnableBtnPreviousPic()
{
	if (iCurrentPic <= 1)
		document.getElementById("btnPreviousPic").style.visibility = "hidden";
	else
		document.getElementById("btnPreviousPic").style.visibility = "visible";
}

function EnableBtnNextPic()
{
	if (document.getElementById("div_" + (iCurrentPic + 1)) == null)
		document.getElementById("btnNextPic").style.visibility = "hidden";
	else
		document.getElementById("btnNextPic").style.visibility = "visible";		
}*/

function OpenLeagueDetails(iLeagueId)
{

	document.location.href = "/Leagues/Pages/LeagueDetails.aspx?LEAGUE_ID=" + iLeagueId;
}

function OpenCurrentPageWithParam(sParamName,sParamValue)
{
	sPageUrl = "" ; 
	
	sPageUrl = window.location.href;
	
	if (sPageUrl.indexOf("?") > -1)
		sPageUrl = sPageUrl.substring(0,sPageUrl.indexOf("?"));
		
 	window.location.href = sPageUrl + "?" + sParamName + "=" + sParamValue;
}

function ShowPreviousPic()
{
	var iPrevPicId = iCurrentPic - 1;
	
	if(document.getElementById("div_" + iPrevPicId) != null)
	{
		document.getElementById("div_" + iCurrentPic).style.display = "none" ;
		iCurrentPic--;
		document.getElementById("div_" + iCurrentPic).style.display = "inline" ;
		
	}
	else
	{
		document.getElementById("div_" + iCurrentPic).style.display = "none" ;
		iCurrentPic = document.getElementById("hdnTotalRows").value ;
		document.getElementById("div_" + iCurrentPic ).style.display = "inline" ;
	}	
}

function ShowNextPic()
{
	var iNextPicId = iCurrentPic + 1;
	
	if(document.getElementById("div_" + iNextPicId) != null)
	{
		document.getElementById("div_" + iCurrentPic).style.display = "none" ;
		iCurrentPic++;
		document.getElementById("div_" + iCurrentPic).style.display = "inline" ;
	}
	else
	{
		document.getElementById("div_" + iCurrentPic).style.display = "none" ;
		iCurrentPic = 1;
		document.getElementById("div_1").style.display = "inline" ;
		
	}	

}

function SetHomePage(sElement)
{
	var sUrl = IFA_ENGLISH_URL;
	sElement.style.behavior='url(#default#homepage)';
	sElement.setHomePage(sUrl);
	 
}

function printSpecial(printId)
{
	if (document.getElementById != null)
	{
		var html = '<HTML>\n<HEAD>\n';
	
		//if (document.getElementsByTagName != null)
		//{
		//	var headTags = document.getElementsByTagName("head");
		//	if (headTags.length > 0)
		//		html += headTags[0].innerHTML;
		//} 

		html += '<link rel="stylesheet" type="text/css" href="/Style%20Library/SiteStyle.css"/>\n</HEAD>\n<BODY>\n';
		
		var printReadyElem = document.getElementById(printId);
		if (printReadyElem != null)
		{
			html += printReadyElem.innerHTML;
		}
		else
		{
			alert("Could not find the printReady function");
			return;
		}
		
		html += '\n</BODY>\n</HTML>';
		
		var printWin = window.open("","printSpecial");
		printWin.document.open();
		printWin.document.write(html);
		printWin.document.close();
		if (gAutoPrint)
		printWin.print();
	}
	else
	{
		alert("The print ready feature is only available if you are using an browser. Please update your browswer.");
	}
}

function OpenPicture(sUrl)
{
	if (document.getElementById != null)
	{
		var html = "<html><body><img src='" + sUrl + "'></body></html>";
		
		var pictureWin = window.open("","pictureWin");
		pictureWin.document.open();
		pictureWin.document.write(html);
		pictureWin.document.close();
	}
}

//Set side menu height
function StrechSideMenu()
{
	//if (document.getElementById("tdSideMenuContainer") != null && document.getElementById("tdParentSideMenuContainer") != null &&
	//	document.getElementById("tdSideMenuContainer").height + 50 > document.getElementById("tdParentSideMenuContainer").offsetHeight)
		
		//document.getElementById("tdSideMenuContainer").height = document.getElementById("tdParentSideMenuContainer").offsetHeight - 3;
}

function SideMenuSwitchGroupChildVisibility(iGroupId)
{
	if (document.getElementById('_row' + iGroupId).style.display == "none")
	{
		document.getElementById('_row' + iGroupId).style.display = "inline" ;
		StrechSideMenu();
	}
	else
	{
		document.getElementById('_row' + iGroupId).style.display = "none" ;			
		StrechSideMenu();
	}
}

function ChangeLanguage()
{
	window.location.href = IFA_URL;
}

function OpenModal(sUrl)
{
	window.showModalDialog(sUrl,null,"dialogWidth:781px;dialogHeight:620px;center=yes;status=no;help=0;toolbar=no;location=no;directories=no;menubar=no;resizable=0;copyhistory=no");
}


