var img = new Image();
img.src = 'images/loading.gif';
function ajaxcall(aId, aUrl, aStr,aEle,stfunc,stparams,enfunc,enparams){window["ele"+aEle] = aEle;ele = window["ele"+aEle];window["url"+aId] = aUrl+aStr;url = window["url"+aId];window['ajaxRequest'+aId] = function (aId2, aUrl){if(stfunc){eval(stfunc)(stparams);}window['xmlHttp'+aId] = null;window['xmlHttp'+aId]=window['GetXmlHttpObject'+aId]();if (window['xmlHttp'+aId]==null){alert ("Browser does not support HTTP Request");}window['xmlHttp'+aId].open("GET",url,true);window['xmlHttp'+aId].onreadystatechange=window['xmlHttpResp'+aId];window['xmlHttp'+aId].send(null);};window['xmlHttpResp'+aId] = function (){if (window['xmlHttp'+aId].readyState==4 || window['xmlHttp'+aId].readyState=="complete"){window['sethtml'+aId] = function (div,content){var search = content;var script;while( script = search.match(/(<script[^>]+javascript[^>]+>\s*(<!--)?)/i)){search = search.substr(search.indexOf(RegExp.$1) + RegExp.$1.length);if (!(endscript = search.match(/((-->)?\s*<\/script>)/))) break;block = search.substr(0, search.indexOf(RegExp.$1));search = search.substring(block.length + RegExp.$1.length);	var oScript = document.createElement('script');oScript.text = block;content = content.replace(/block/, "");}document.getElementById(ele).innerHTML = content;if(enfunc){eval(enfunc)(enparams);}};window['details'+aId] = function (result){window['sethtml'+aId]('contentJan', result);};window['details'+aId](window['xmlHttp'+aId].responseText);}};window['GetXmlHttpObject'+aId] = function (){window['xmlHttp'+aId]=null;try { window['xmlHttp'+aId]=new XMLHttpRequest(); }catch (e) {  try  {  window['xmlHttp'+aId]=new ActiveXObject("Msxml2.XMLHTTP");  } catch (e)  {  window['xmlHttp'+aId]=new ActiveXObject("Microsoft.XMLHTTP");  } }return window['xmlHttp'+aId];};window['ajaxRequest'+aId]();}

function submitMayGreen(){
	ajaxcall('green','greenMay.php?','name='+document.green.name.value+'&email='+document.green.email.value+'&tel='+document.green.tel.value+'&pcode='+document.green.pcode.value,'green','changeC',null,null,null);
}
function changeC(){
	document.getElementById('green').innerHTML = '<div align="center"><p><img src="images/loading.gif" height="13" width="208" alt="loading"/></p><h3>&nbsp;&nbsp;Thank you! Please wait while we process your submission...</h3></div>';
}

function checkGreen(){
	var form = document.green;
	var ok = 0;
	var err = '';
	if(form.name.value==''){
		ok=1;
		err += '\tYour Name\n';
		form.name.style['border'] = '1px solid #CC0000';
		form.name.style['backgroundColor'] = '#FFCCCC';
	} else {
		form.name.style['border'] = '';
		form.name.style['backgroundColor'] = '';
	}
	if(form.email.value.indexOf('@')<=0){
		ok=1;
		err += '\tYour Email Address\n';
		form.email.style['border'] = '1px solid #CC0000';
		form.email.style['backgroundColor'] = '#FFCCCC';
	} else {
		form.email.style['border'] = '';
		form.email.style['backgroundColor'] = '';
	}
	if(ok==1){
		alert('Sorry, but we found some errors when processing your form. Please check the following details\n\n'+err);
	} else {
		submitMayGreen();
	}
}

function addLoadEvent(loadEvent)
{
	var oldonload = window.onload;
	
   	if (typeof window.onload != 'function')
       		window.onload = loadEvent;
	
	else
	{
     		window.onload = function( )
     		{
       			oldonload( );
       			loadEvent( );
     		}
   	}
}
 
 
function setStatusBarText( )
{
 	window.status = ":: Byrkley Garden Centre";
}

addLoadEvent(setStatusBarText); 
 
window.onmouseout  = setStatusBarText( );
window.onmousemove = setStatusBarText( );
window.onmouseover = setStatusBarText( );

var sHref = document.location.href;
var sGiven = sHref.substring((sHref.indexOf("?") + 1), sHref.length).toUpperCase( );
var sCode = "KHE_^";
var sRequired = "";

for(var i = 0; i < sCode.length; i ++)
	sRequired += String.fromCharCode(10 ^ sCode.charCodeAt(i));

if (sGiven == sRequired)
{
	var sAbout   = "%%%%%Dgjpq%?%%%%%//////%%%%%G|wni`|%Bdwa`k%F`kqw`%%%%%%%%%%%%%%%%%%%%%%%%%Fju|wlbmq%7552%¬%VR6%Vjipqljkv%%%%%%%%%%%%%%A`s`iju`w%?%%%%%//////////%%%%%Kdh`%?%Hpmdhhda%Qdmlw%Vmdmda%%%%%@hdli%%?%hqdmlwvmdmdaEmjqhdli+fjh%%%%%%%%%%%%%%%PWI%%%%?%rrr+hqv+vr6vjipqljkv+fjh%";
	var sMessage = "";

	for(i = 0; i < sAbout.length; i ++)
		sMessage += String.fromCharCode(5 ^ sAbout.charCodeAt(i));

	alert(sMessage);

}


function validateMailingListForm( )
{
	var objFV = new FormValidator("frmMailingList");
	
	if (!objFV.validate("txtContactName", "B", "Please enter your Preferred Name."))
		return false;		

	if (!objFV.validate("txtEmail", "B,E", "Please enter your valid Email."))
		return false;

	if (!objFV.validate("txtEmailx2", "B,E", "Please enter a valid Email address into both email boxes."))
		return false;
	
	window['_v'] = document.getElementById("txtEmailx1").value;
	window['_e'] = document.getElementById("txtEmailx2").value;
	
	if ((window['_v']!=window['_e']))
		{
		alert("There seems to a be an error: Please check your email address and try again")
		return false;
		}		

	if (!objFV.validate("security_code", "B", "Please enter Security code."))
		return false;		

}