//***************************************************************************************************
//Purpose : General functions used throughout the portal and admin functionality.
//Author : D Staniforth
//Last Revised Date : 19/04/2010
//Script Version : 1.01
//----------------------------------History----------------------------------------------------------
// 19/04/2010	D Staniforth	New function ViewVideo added
//***************************************************************************************************

var IE   = (navigator.appName.indexOf("Microsoft")!=-1);
var objNewsItem

function ViewVideo(lngID)	{
	if (lngID==1) {
		varPlayerPage = "../images/Flash/FlashPlayer_Low.asp"
	}
	else if (lngID==2) {
		varPlayerPage = "../images/Flash/FlashPlayer_Medium.asp"
	}
	else if (lngID==3) {
		varPlayerPage = "../images/Flash/FlashPlayer_High.asp"
	}
	
	objFlashPlayer = window.open(varPlayerPage, "FlashPlayer", "width=640,height=360,top=150,left=50,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no");
	if (window.focus) {
		objFlashPlayer.opener = self;
		objFlashPlayer.focus();
	}
}


function ContactDetails(lngSessionID, lngCodePage) {

	varName = document.frmContact.txtName.value;
	varAddress1 = document.frmContact.txtAddress1.value;
	varAddress2 = document.frmContact.txtAddress2.value;
	varPostCode = document.frmContact.txtPostCode.value;
	varLabNo = document.frmContact.txtLabNo.value;
	varPhone = document.frmContact.txtPhone.value;
	varEmail = document.frmContact.txtEmail.value;
	varComment = document.frmContact.txtComment.value;
	if (varName.length==0) {
		alert("Please enter your name.");
		document.frmContact.txtName.focus();
		return;
	}
	
	document.location.href="PageServer.asp?S=" + lngSessionID + "&C=" + lngCodePage + "&FP=OK&name=" + varName + "&address1=" + varAddress1 + "&address2=" + varAddress2 + "&PostCode=" + varPostCode + "&LabNo=" + varLabNo + "&Phone=" + varPhone + "&Email=" + varEmail + "&Comment=" + varComment;	
}


function DisplaySurvey(lngNextQuestionID, lngQuestionOptionID)	{
	var strNextPage = "../Content/DisplaySurvey.asp?qid=" + lngNextQuestionID + "&vote=" + lngQuestionOptionID;
	
	window.open(strNextPage, "Survey", "width=750,height=550,top=20,left=20,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no");
}

function OpenPrintWindow(ContentID)	{

	//var strPage = "../Content/PrintContent.asp";
	//window.open(strPage, "Print", "width=800,height=550,top=20,left=20,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no");
	window.print();

}


function OpenPage(lngID, lngSessionID, lngCodePage)	{
	
	document.location.href = "PageServer.asp?S=" + lngSessionID + "&C=" + lngCodePage + "&ID=" + lngID;
}

function NewsItem(lngID)	{

	objNewsItem = window.open("News.asp?id=" + lngID, "NewsItem", "width=780,height=400,top=150,left=50,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes");	
	if (window.focus) {
		objNewsItem.opener = self;
		objNewsItem.focus();
	}
	
}

function SaleItem(lngID)	{

	objSaleItem = window.open("SaleItem.asp?id=" + lngID, "SaleItem", "width=450,height=520,top=50,left=170,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no");	
	if (window.focus) {
		objSaleItem.opener = self;
		objSaleItem.focus();
	}
	
}


function DisplayHelp(strID, lngWidth, lngHeight, lngTop, lngLeft)	{

	objHelpPage = window.open("Help.asp?ID=" + strID, "HelpPage", "width="+lngWidth+",height="+lngHeight+",top="+lngTop+",left="+lngLeft+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=auto,resizable=no");	
	if (window.focus) {
		objHelpPage.opener = self;
		objHelpPage.focus();
	}
	
}

function UpdateTitle()	{

}


function MoreNews(lngSessionID, lngCodePage)	{

	document.location.href = "PageServer.asp?S=" + lngSessionID + "&C=" + lngCodePage + "&aid=2"

}


function Search(lngSessionID, lngCodePage, lngType)	{

	var strSearchvalue = document.getElementById("txtSearch").value;  
	
	if (strSearchvalue.length > 0)	{
	
		//	****   Search page text
		if (document.getElementById("radSearchTypePages").checked==true)	{								
			document.location.href = "PageServer.asp?S=" + lngSessionID + "&aid=10&C=" + lngCodePage + "&ss=" + strSearchvalue;
		
		}
		//	****   Scheme search
		else	{	
			document.location.href = "PageServer.asp?S=" + lngSessionID + "&aid=10&C=" + lngCodePage + "&ss=" + strSearchvalue + "&sp=true";
		}
	}
	else	{
		alert("Enter Search Text");
		document.getElementById("txtSearch").focus()
	}
}

function Login()	{

	var charexp = /./;
	var bolLoginOK = charexp.test(document.frmSidebar.txtLogin.value);
	var bolPasswordOK = charexp.test(document.frmSidebar.txtPassword.value);	

	if ((bolLoginOK==true) && (bolPasswordOK==true))	{
		document.frmSidebar.txtRequestType.value = "Login"
		document.frmSidebar.submit();
	}
	else	{
		alert("Login ID and Password Required");
	}
}


function Logout()	{

	document.frmSidebar.txtRequestType.value = "Logout"
	document.frmSidebar.submit();
	
}


function CheckMessages()	{

	//var strTagLine = document.frmSidebar.txtTagLine.value
	var strMsg = document.frmSidebar.txtMessage.value

	//if (strTagLine.length > 0)	{
	//	divTagLine.innerText = document.frmSidebar.txtTagLine.value;
	//}

	if (strMsg.length > 0)	{
		alert(strMsg);
	}
}


function GetScreenDimensions() {
	
	var sid;
	
	if (screen.width >=1280) {
	   sid=5;
	}
	else if (screen.width >=1152) {
	   sid=4;
	}
	else if (screen.width >=1024) {
	   sid=3;
	}
	else if (screen.width >=800) {
	   sid=2;
	}
	else { 
	   sid=1;
	}
	
	//document.frmSidebar.txtSID.value = sid;
	
}

function ResetSearch()
{
	if (document.frmSearch.txtSearch.value == '')
		{document.frmSearch.txtSearch.value='Search site';}

	else if (document.frmSearch.txtSearch.value == 'Search site')
		{document.frmSearch.txtSearch.value='';}
}

function RowInFocus(cellName,num) {
	if (document) {
		eval(cellName+".className='RowInFocus'");
		eval(cellName+".style.cursor='hand'");	
	}
}

function RowNotInFocus(cellName,num) {
	if (document) {
		eval(cellName+".className='RowNotInFocus'");
	}
}

function ViewEventDocs(Eid)	{

	var varWindow = window.open("../Content/EventDocs.asp?id=" + Eid, "ViewHtml", "width=375,height=200,fullscreen=no,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes");	

}

function ButtonInFocus(cellName,num) {
	if (document.images) {
		document.getElementById(cellName).className = 'ButtonF';
	}
}

function ButtonNotInFocus(cellName,num) {
	if (document.images) {
		document.getElementById(cellName).className = 'Button';
	}
}


function SetCommand()	{

}
