﻿// JScript File
function SelectSubNav(sectionName) 
{
	if (document.getElementById("subnavkids") != null) 
	{
		document.getElementById("subnavkids").className = sectionName;
	}
}


function GoFullScreen(sectionName, subsectionName) 
{
	OpenWindow(99, 'full-screen.aspx?section='+ sectionName + "&subsection=" + subsectionName);
}

function CloseFullScreen()
{
	window.close();
}


function OpenWindow(percent,url) 
{
    var w = 800, h = 600; // default sizes
    if (window.screen) {
        var scaleRelation= window.screen.availHeight/h;
        //Best check that scaling to height won't compromise width.
        if (window.screen.availWidth < (w*scaleRelation) )
        {
			scaleRelation= window.screen.availWidth/w;
		}
		scaleRelation = scaleRelation * ( percent / 100 );
		w=w*scaleRelation;
        h=h*scaleRelation;
    }
    window.open(url,'windowName','resizable=yes,width='+w+',height='+h + ',left=0,top=0');
}

/* cookies */


function WriteCookie(name, value, days) 
{
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function ReadCookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) 
		{	
			alert(c.substring(nameEQ.length,c.length));
			return c.substring(nameEQ.length,c.length);
		}
	}
	return null;
}



function ChangeVisibility(id) 
{
       if (document.getElementById(id).style.display == "none") 
       {
            document.getElementById(id).style.display = "block";
       } 
       else 
       {
            document.getElementById(id).style.display = "none";
       }
}




