/***************************************************************************************************
//----------------------------------History----------------------------------------------------------

	01/11/06	Added Validate for Login
	21/11/07	Remove copyright notice on right-click
***************************************************************************************************/

var IE   = (navigator.appName.indexOf("Microsoft")!=-1);
var objNewsItem

/*****************************************************
 Prevent image theft   END Commented out to disable 21/11/07

if (document.all) {
    if (navigator.appVersion.indexOf("MSIE 5")<0) { // Remove for forms and embedded controls
        document.onmousedown=iecapture;
        document.onmouseup=iecapture;
        document.onclick=iecapture;
        document.ondblclick=iecapture;
    } // Remove for forms and embedded controls
}else if (document.layers) {
    window.captureEvents(Event.MOUSEDOWN)
    window.onmousedown=nscapture
}
*****************************************************/


function iecapture() {
    var el=event.srcElement;
    if (event.button==2){
        if ((el.tagName!="input") && (el.tagName!="TEXTAREA") && (el.tagName!="SELECT") && (el.tagName!="EMBED") && (el.tagName!="OBJECT")) {
            alert('All Images and code is copyright \u00A9 2006');
        }
    }
}

function nscapture(ev) {
    if (ev.which!=1){
        alert('Sorry, code is copyright \u00A9 2006.');
        return false;
    }
}

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=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.frmSidebar.txtSearch.value;
	var strSearchvalue = document.getElementById("txtSearch").value;
		
	if (strSearchvalue.length > 0)	{
		document.location.href = "PageServer.asp?S=" + lngSessionID + "&aid=10&C=" + lngCodePage + "&ss=" + strSearchvalue;
	}
	else	{
		alert("Enter Search Text");
		document.getElementById("txtSearch").focus()
	}
}

function Search2(lngSessionID, lngCodePage, lngType)	{

	var strSearchvalue = document.getElementById("txtSearch2").value;
	
	if (strSearchvalue.length > 0)	{
		document.location.href = "PageServer.asp?S=" + lngSessionID + "&aid=10&C=" + lngCodePage + "&ss=" + strSearchvalue;
	}
	else	{
		alert("Enter Search Text");
		document.getElementById("txtSearch2").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 Validate() {

	var varLogin = document.frmLogin.txtLogonName.value;
	var varPassword = document.frmLogin.txtPassword.value;
	
	if (varLogin.length == 0) {
		alert("You must enter a User ID");
		document.frmLogin.txtLogonName.focus();
	}
	else if (varPassword.length == 0) {
		alert("You must enter a Password");	
		document.frmLogin.txtPassword.focus();
	}
	else {
		document.frmLogin.txtLoginAction.value = "LoggingIn";
		document.frmLogin.submit();
	}
}
