////////////////////////////////////////////////////////////////////
//    This file contains JavaScripts for home pages
////////////////////////////////////////////////////////////////////

function OpenFeedbackForm( TheSection ) {
	var url = "tr/assets/FeedbackForm.asp?Section=" + TheSection;
	var nmHeight = 275;
	var nmWidth = 600;
	var nmTop = window.screen.height/2 - nmHeight / 2;
	var nmLeft = window.screen.width/2 - nmWidth / 2;
	window.open(url, "Feedback", "width=" + nmWidth + ",height=" + nmHeight + ",toolbar=0,location=0,directories=0,resizable=0,status=0,menubar=0,scrollbars=0,left=" + nmLeft + ",Top=" + nmTop );
}


function OpenHelpWindow( TheSection ) {
	var url = "tr/assets/HelpFrame.asp?Section=" + TheSection;
	var nmHeight = 500;
	var nmWidth = 420;
	var nmTop = window.screen.height/2 - nmHeight / 2;
	var nmLeft = window.screen.width/2 - nmWidth / 2;
	window.open(url, "HelpWindow", "width=" + nmWidth + ",height=" + nmHeight + ",toolbar=0,location=0,directories=0,resizable=1,status=0,menubar=0,scrollbars=0,left=" + nmLeft + ",Top=" + nmTop );
}


function PopWindow(name,width,height,url) {
	var nmTop = window.screen.height/2 - height / 2 - 20;
	var nmLeft = window.screen.width/2 - width / 2;
	window.open(url, name, "width=" + width + ",height=" + height + ",toolbar=0,location=0,directories=0,resizable=0,status=0,menubar=0,scrollbars=0,left=" + nmLeft + ",Top=" + nmTop );
}



// Create a cookie with the specified name and value.
function SetCookie(sName, sValue, sDuration)
{
	if ( sDuration == 0 )
	{
		document.cookie = sName + "=" + escape(sValue)
	}
	else
	{
		date = new Date();
		date.setDate( date.getDate() + sDuration )
		document.cookie = sName + "=" + escape(sValue) + "; expires=" + date.toGMTString();
	}
}



// Retrieve the cookie with the specified name.
function GetCookie(sName)
{
	// cookies are separated by semicolons
	var aCookie = document.cookie.split("; ");
	
	for (var i=0; i < aCookie.length; i++)
		{
		// a name/value pair (a crumb) is separated by an equal sign
		var aCrumb = aCookie[i].split("=");
			if (sName == aCrumb[0]) 
			return unescape(aCrumb[1]);
		}

	// a cookie with the requested name does not exist
	return null;
}



function RecommendThisPage( TheSection ) {
	var url = "tr/assets/HelpFrame.asp?Section=" + TheSection;
	var nmHeight = 500;
	var nmWidth = 420;
	var nmTop = window.screen.height/2 - nmHeight / 2;
	var nmLeft = window.screen.width/2 - nmWidth / 2;
	window.open(url, "HelpWindow", "width=" + nmWidth + ",height=" + nmHeight + ",toolbar=0,location=0,directories=0,resizable=1,status=0,menubar=0,scrollbars=0,left=" + nmLeft + ",Top=" + nmTop );
}



function PrintThisPage( TheURL ) {
	var url = "tr/assets/PrintThisPage.asp?TheURL=" + TheURL;
	var nmHeight = 500;
	var nmWidth = 420;
	var nmTop = window.screen.height/2 - nmHeight / 2;
	var nmLeft = window.screen.width/2 - nmWidth / 2;
	window.open(url, "HelpWindow", "width=" + nmWidth + ",height=" + nmHeight + ",toolbar=0,location=0,directories=0,resizable=1,status=0,menubar=0,scrollbars=0,left=" + nmLeft + ",Top=" + nmTop );
}


function dict()
{
	if (navigator.appName == "Netscape")
		{
			OpenDictionaryWindow(document.getSelection());
		}
	else
		{
			var strText = document.selection.createRange();
			if( document.selection.type == 'Text' )
				{
					OpenDictionaryWindow(strText.text);
				}
		}
}

function OpenDictionaryWindow(strQuery)
{
	if (strQuery != '')
		{
			var DictionaryWindow;
			DictionaryWindow = window.open('shared/lugat/lugat.asp?Kelime=' +  escape(strQuery), 'DictionaryPopUp', 'width=500,height=227,toolbar=0,location=0,directories=0,resizable=0,status=1,menubar=0');
			DictionaryWindow.focus();
		}
}
