//***************************************************************************************************
//Purpose : General functions used throughout the portal and admin functionality.
//Author : D Staniforth
//Last Revised Date : 03/12/2002
//Script Version : 1.00
//----------------------------------History----------------------------------------------------------
//***************************************************************************************************

var IE   = (navigator.appName.indexOf("Microsoft")!=-1);
var objNewsItem

function ContactDetails(lngSessionID, lngCodePage) {

	varName = document.frmContact.txtName.value;
	varAddress1 = document.frmContact.txtAddress1.value;
	varAddress2 = document.frmContact.txtAddress2.value;
	varPostCode = document.frmContact.txtPostCode.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 + "&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 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=400,height=400,top=150,left=150,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no");	
	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.frmSidebar.txtSearch.value;
	
	if (strSearchvalue.length > 0)	{
	
		if (lngType==1)	{
			document.location.href = "PageServer.asp?S=" + lngSessionID + "&aid=10&C=" + lngCodePage + "&ss=" + document.frmSidebar.txtSearch.value;
		
		}
		else	{
			var index = document.frmSidebar.cboSearchFilter.selectedIndex;
			var lngPID = document.frmSidebar.cboSearchFilter.options[index].value;

			document.location.href = "PageServer.asp?S=" + lngSessionID + "&C=" + lngCodePage + "&ss=" + document.frmSidebar.txtSearch.value + "&pid=" + lngPID;
		}
	}
	else	{
		alert("Enter Search Text");
		document.frmSidebar.txtSearch.focus()
	}
		
	// document.frmSidebar.txtRequestType.value = "Search"
	// document.frmSidebar.submit();
	
}

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");	

}
