var z2; var z2b; var activeSub=0;var SubNum=0;var timerID=null;var timerOn=false;var timecount=1000;var what=null;var newbrowser=true;var check=false;var montharray=new Array("January","February","March","April","May","June","July","August","September","October","November","December");var minYear="1920";var maxYear="2020";var dtCh="/";var levels=Array();var ko = 0; submenus = "";
var agent = navigator.userAgent.toLowerCase();if (agent.indexOf("msie") != -1) {myb = "ie";mys = "i";}else if (agent.indexOf("gecko") != -1){myb = "ns6";mys = "i";}else{myb="ns";mys = "n";} 

function MM_findObj(n, d){var p,i,x;if(!d) d=document;if((p=n.indexOf("?"))>0&&parent.frames.length){d=parent.frames[n.substring(p+1)].document;n=n.substring(0,p);}if(!(x=d[n])&&d.all) x=d.all[n];for(i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);if(!x&&document.getElementById) x=document.getElementById(n);return x;}
function getAbsLeft(o){oLeft=o.offsetLeft; while(o.offsetParent!=null){oParent=o.offsetParent; oLeft +=oParent.offsetLeft; o=oParent;}return oLeft;}
function getAbsTop(o){oTop=o.offsetTop; while(o.offsetParent!=null){oParent=o.offsetParent; oTop +=oParent.offsetTop; o=oParent;}if(!oTop){oTop=0;}return oTop;}
function resetheight(){



x1 = MM_findObj('bodytext');
var phy=-190; 
if (myb=="ie") { 
phy = (phy+document.body.clientHeight); 
}else if (myb=="ns6") { 
phy = (phy+document.body.clientHeight)-40; x1.style["height"]="";
}else{ 
phy = (phy+window.innerHeight);
} 

y1 = MM_findObj('linkList');y2 = MM_findObj('calcpos');z1 = 10 +getAbsTop(y2)-getAbsTop(y1);
u2 = MM_findObj('calcpos2');u1 = MM_findObj('bodycont');z3 = getAbsTop(u2)-getAbsTop(x1)-22;
if(z1<z3){z1=z3;}
if(z1>phy){x1.style["height"] = ''+z1+'px';}else {x1.style["height"] = ''+phy+'px';}

}



function openmenu(whmenu){x = MM_findObj(whmenu);if(x.style["display"]=="block"){x.style["display"]="none";}else{x.style["display"]="block";}resetheight();}
function resetlinks(gotlinks,ko,ka){if(!ko){ko=0;}if(!ka){ka=0;}for(j=0;j<gotlinks.length;j++){i=gotlinks[j];if(i!=ko && i!=ka){ld = MM_findObj('linkList'+i+'');ld.style["display"]="none";}lt = MM_findObj('link'+i+'');lt.href = "javascript:openmenu('linkList"+i+"');"; }}
function getthedate(){var mydate=new Date();var year=mydate.getYear();if(year<1000){year+=1900;}var day=mydate.getDay();var month=mydate.getMonth();var daym=mydate.getDate();var hours=mydate.getHours();var minutes=mydate.getMinutes();var seconds=mydate.getSeconds();var dn="AM";if(hours>=12){dn="PM";}if(hours>12){hours=hours-12;}if(hours==0){hours=12;}if(minutes<=9){minutes="0"+minutes;}if(seconds<=9){seconds="0"+seconds;}var cdate=montharray[month]+" "+daym+" "+year+" | "+hours+":"+minutes+":"+seconds+" "+dn+"";if(document.all){document.all.clock.innerHTML=cdate;}else if(document.getElementById){document.getElementById("clock").innerHTML=cdate;}}
function adddate(){if(navigator.appVersion.indexOf('Mac')!=-1){getthedate();}else{if(document.all||document.getElementById){setInterval("getthedate()",1000);}}}
function menuclose(i,ko){ if(ko!=i){ld = MM_findObj('linkList'+i+'');ld.style["display"]="none";} }
function Side_ClientValidate(frm){var x = "";x = x + validatetext(frm,"username",1,"Username","");x = x + validatetext(frm,"password",1,"Password","");if(document.forms[frm].username.value=="Username" && document.forms[frm].password.value=="Password"){x = "Please enter your login details";} if (x>""){alert(x);return false;}else{document.forms[frm].submit();return false;}}

function resetandload(gotlinks,ko,ka){if(gotlinks!=""){resetlinks(gotlinks,ko,ka);}resetheight();adddate();}





function validateloop(frm,checkboxarray){any=0;var y;var f=document.forms[frm];for(i=0;i<checkboxarray.length;i++){y="item_"+checkboxarray[i];if(f.elements[y].checked==1){any++;}}if(any==0){return "product needs specifying";}else{return "";}}
function validatetext(frm,what,req, error, onlyif){var f=eval("document.forms[\""+frm+"\"]");var e=f.elements[what];if(onlyif!=""){var c=f.elements[onlyif];}if(!e){return "Something funny with variable:"+what+"\r\n";}else{if(req==1){if(e.value==""){return "Please enter: "+error+"\r\n";}else{return "";}}else if(req==2){if(c){if(c.value!=""){if(e.selectedIndex==0){return "Please select: "+error+"\r\n";}else{return "";}}else{return "";}}else{if(e.selectedIndex==0){return "Please select: "+error+"\r\n";}else{return "";}}}else if(req==3){var goterror="error";for(i=0;i<e.length;i++){if(e[i].checked==true){goterror="";}}if(goterror=="error"){return "Please select: "+error+"\r\n";}else{return "";}}else if(req==4){if(c){if(c.value!=""){if(e.value!=c.value){return "Please ensure that passwords match\r\n";}else{return "";}}else{return "";}}}else if(req==5){if(e.value!=""){if(e.valueindexOf(".")==-1||e.valueindexOf("@")==-1){return "Please enter valid email address\r\n";}else{return "";}}else{return "";}}else if(req==6){if(e.checked==1){return "";}else{return "Please confirm that you have read our T&Cs\r\n";}}if(req==5){return "Please check format of: "+error+" should be "+format+"\r\n";}}}
function isInteger(s){var i;for(i=0;i<s.length;i++){var c=s.charAt(i);if(((c<"0")||(c>"9"))) return false;}return true;}
function stripCharsInBag(s, bag){var i;var returnString="";for(i=0;i<s.length;i++){var c=s.charAt(i);if(bag.indexOf(c)==-1){returnString +=c;}}return returnString;}
function daysInFebruary (year){return (((year % 4==0)&&((!(year % 100==0))||(year % 400==0)))?29:28 );}
function DaysArray(){for(var i=1;i<=12;i++){this[i]=31;if(i==4||i==6||i==9||i==11){this[i]=30;}if(i==2){this[i]=29;}}return this;}
function isDate(dtStr){var daysInMonth=DaysArray();var pos1=dtStr.indexOf(dtCh);var pos2=dtStr.indexOf(dtCh,pos1+1);var strDay=dtStr.substring(0,pos1);var strMonth=dtStr.substring(pos1+1,pos2);var strYear=dtStr.substring(pos2+1);strYr=strYear;if(strDay.charAt(0)=="0"&&strDay.length>1){strDay=strDay.substring(1);}if(strMonth.charAt(0)=="0"&&strMonth.length>1){strMonth=strMonth.substring(1);}for(var i=1;i<=3;i++){if(strYr.charAt(0)=="0"&&strYr.length>1){strYr=strYr.substring(1);}}month=parseInt(strMonth);day=parseInt(strDay);year=parseInt(strYr);if((pos1==-1||pos2==-1)||(strMonth.length<1||month<1||month>12)||(strDay.length<1||day<1||day>31||(month==2&&day>daysInFebruary(year))||day > daysInMonth[month])||(strYear.length!=4||year==0||year<minYear||year>maxYear)||(dtStr.indexOf(dtCh,pos2+1)!=-1||isInteger(stripCharsInBag(dtStr, dtCh))==false)){return "Please enter: A valid date";}else{return "";}}
function validatedate(frm,d,m,y,a){if(a==""||!a||a=="dr"){var dt=document.forms[frm].elements[d].options[document.forms[frm].elements[d].selectedIndex].value+"/"+document.forms[frm].elements[m].options[document.forms[frm].elements[m].selectedIndex].value+"/"+document.forms[frm].elements[y].options[document.forms[frm].elements[y].selectedIndex].value;}else if(a=="nd"){var dt="01/"+document.forms[frm].elements[m].options[document.forms[frm].elements[m].selectedIndex].value+"/"+document.forms[frm].elements[y].options[document.forms[frm].elements[y].selectedIndex].value;}else{var dt=document.forms[frm].elements[a].value;}var isdateret=isDate(dt);if(isdateret!=""){return isdateret+"\r\n";}else{return "";}}
function checknotdate(frm,d,m,y,dt_bef){var dt=document.forms[frm].elements[d].options[document.forms[frm].elements[d].selectedIndex].value+"/"+document.forms[frm].elements[m].options[document.forms[frm].elements[m].selectedIndex].value+"/"+document.forms[frm].elements[y].options[document.forms[frm].elements[y].selectedIndex].value;var isdateret=isDate(dt);if(isdateret==""){dt_aft=new Date(document.forms[frm].elements[y].options[document.forms[frm].elements[y].selectedIndex].value,(document.forms[frm].elements[m].options[document.forms[frm].elements[m].selectedIndex].value-1),document.forms[frm].elements[d].options[document.forms[frm].elements[d].selectedIndex].value);dt_cur=new Date();var day=60*1000*60*24;if(((dt_aft-dt_bef)/day)<0){return "You are entering a date before the start date of the job ("+Math.round((dt_aft-dt_bef)/day)+")\r\n";}else if(((dt_aft-dt_cur)/day)>0){return "You are entering a future date\r\n";}else{return "";}}else{return "";}}
function validateemal(frm,str){var tempemail=document.forms[frm].elements[str].value;if(tempemail!=""){var filter=/^.+@.+\..{2,4}$/;if(filter.test(tempemail)==false){return "Please enter: Valid email address (x@y.com)\r\n";}else{return "";}}else{return "";}}
function validatewith(frm,str,goodchar,error){var TheNumber=document.forms[frm].elements[str].value;var valid=1;var GoodChars="";if(TheNumber!=""){if(goodchar==4){if(TheNumber.length==12){GoodChars="0123456789";for(i=0;i<=TheNumber.length-1;i++){if(i==3||i==7){if(TheNumber.charAt(i)!="-"){valid=0;}}else{if(GoodChars.indexOf(TheNumber.charAt(i))==-1){valid=0;}}}}else{return "Please enter: Valid phone number (xxx-yyy-zzzz)\r\n";}}else if(goodchar==5){if(TheNumber.length==5){GoodChars="0123456789";for(i=0;i<=TheNumber.length-1;i++){if(GoodChars.indexOf(TheNumber.charAt(i))==-1){valid=0;}}}else{return "Please enter: Valid Zipcode (xxxxx)\r\n";}}else{if(goodchar==1){GoodChars="0123456789()-+ ";}else if(goodchar==2){GoodChars="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789 ";}else if(goodchar==3){GoodChars="0123456789";}else{GoodChars="";}for(i=0;i<=TheNumber.length-1;i++){if(GoodChars.indexOf(TheNumber.charAt(i))==-1){valid=0;}}}}if(valid==1){return "";}else{return "Please enter: Valid "+error+"\r\n";}}

function bigger(){
//	t = getAbsTop(closebox);
//	w = getAbsLeft(findw);
//	h = screen.height;
//	if(t>h){t=h-162;}
//	window.resizeTo(w+24, t+78);
	t = getAbsTop(document.getElementById('closebox')); 
	w = getAbsLeft(document.getElementById('findw'));
	h = screen.height;
	if(t>h){t=h-162;}
	window.resizeTo(w+29, t+175);
}

function showgrades(JID){
	x=window.open('pop_shopperjobinfo.php?jobid='+JID+'','info','width=450, height=275, scrollbars=1');x.focus();
}

function t(w,x){

if(w.bdwas){
x = w.bdwas;
}
w.className='line'+x+'';
}

function loadnext(drid){
	var remember=0;
	for(i=(drid+1);i<(levels.length); i++){var fempt = eval("document.theform."+levels[i]);fempt.selectedIndex=0;fempt.length = 1;}
	var fdrop = eval("document.theform."+levels[drid]);
	var fnext = eval("document.theform."+levels[drid+1]);
	if(drid==2){
		var first = eval("document.theform."+levels[drid-2]);
		var fprev = eval("document.theform."+levels[drid-1]);
		var usearray = s_md[first.selectedIndex][fprev.selectedIndex][fdrop.selectedIndex];
	}else if(drid==1){
		var fprev = eval("document.theform."+levels[drid-1]);
		var usearray = s_md[fprev.selectedIndex][fdrop.selectedIndex];
	}else{
		var usearray = s_md[fdrop.selectedIndex];
	}
	if(fnext){
	fnext.length = 1;
	if(fdrop.selectedIndex>0){
		if(loadnext.arguments.length==2){checksel=loadnext.arguments[1];}else{checksel=0;}
		for(i=1;i<usearray.length;i++){
			if(drid<2){var nextr    = (usearray[i][0]+'').split('^');}else{var nextr = (usearray[i]+'').split('^');}
			if(nextr[1]==checksel){remember=i;}
			fnext[i] = new Option(nextr[0],nextr[1]);
		}
	}}
	if (remember>0){fnext.selectedIndex=remember;}
}

function loadtype(req_mtype)	{
	var dropDown;
	selectedIndex = 0;
	if (document.theform && document.theform.mtype)  {
		dropDown = document.theform.mtype;
	}
	
	if (dropDown)  {
		dropDown.length = 0;
		for(index=0; index<types_name.length; index++)	{
			dropDown[index] = new Option(types_name[index],types_value[index]);
			if (types_value[index]==req_mtype){selectedIndex=index;}
		}
		dropDown.options[selectedIndex].selected = true;	
	}
}

function loadsubt(ranges,req_type,typename)	{
	selectedIndex = 0;
	var dropDown;
	if (document.theform && document.theform.stype)  {
		dropDown = document.theform.stype;
	}

	if (dropDown)  {
		dropDown.length = 0;
		for(index=0; index<ranges.length; index++)	{
			trange = ranges[index].split('^');
			dropDown[index] = new Option(trange[0],trange[1]);
			if (trange[1]==req_type){selectedIndex=index;}
		}
		dropDown.options[selectedIndex].selected = true;
	}
}

function colo(r,w){
	y = r.name+'';
	z =r.value;
	y = y.replace("a_","spec");
	y = y.replace("y_","spec");
	x = MM_findObj(y);

	if(z==1 || z==2 || z==3 || z==4 || z==6 || z==8 || z==9){
		x.className='line0';
	}else if(z==-9 || z==-1 || z==5 || z==7){
		x.className='liner';
	}else{
		x.className='line'+w+'';
	}
	if(r){if(r.selected){r.selected = 1;}}

}


function toggle(what){
var f = document.forms["theform"];
for(fi=0;fi<f.elements.length;fi++){
	if(f.elements["a_ALL"].checked==false){
		f.elements[fi].checked=true;
	}else{
		f.elements[fi].checked=false;
	}
	
}

f.elements["a_ALL"].checked=!f.elements["a_ALL"].checked;
}


function tickall(){
var f = document.forms["objectform"];
var n = !f.elements["t_ALL"].checked;
for(fi=0;fi<f.elements.length;fi++){
	if(f.elements[fi].name.substring(0,2)=="t_" && f.elements[fi].name!="t_ALL"){
		f.elements[fi].checked = n;
	}
}

//f.elements["t_ALL"].checked=!f.elements["t_ALL"].checked;
}


function tickall2(){
var f = document.forms["objectform"];

var n = f.elements["t_ALL"].checked;

for(fi=0;fi<f.elements.length;fi++){
	if(f.elements[fi].name.substring(0,2)=="t_" && f.elements[fi].name!="t_ALL"){
		
		f.elements[fi].checked = n;
	}
}

}


function tickall3(){
var f = document.forms["objectform"];

var n = f.elements["b_ALL"].checked;

for(fi=0;fi<f.elements.length;fi++){
	if(f.elements[fi].name.substring(0,2)=="b_" && f.elements[fi].name!="t_ALL"){
		
		f.elements[fi].checked = n;
	}
}

}

function allnodes(){
	//added lines 4, 8 and 9 to allow if only one node
	var f = document.forms["theform"];
	var n = f.elements["nodes_ALL"].checked;
	var a = f.elements["nodes[]"];
	if (a.length) {
		for(fi=0;fi<a.length;fi++){
			a[fi].checked=n;
		}
	} else {a.checked=n;}
}


function numbersonly(myfield, e, dec)
{
var key;
var keychar;
if (window.event)
key = window.event.keyCode;
else if (e)
key = e.which;
else
return true;
keychar = String.fromCharCode(key);
// control keys
if ((key==null) || (key==0) || (key==8) || 
(key==9) || (key==13) || (key==27) )
return true;
// numbers
else if ((("0123456789").indexOf(keychar) > -1))
return true;
// decimal point jump
else if (dec && (keychar == "."))
{
myfield.form.elements[dec].focus();
return false;
}
else
return false;
}


function popmap(lats,lon){
	x=window.open('http://www.retaileyes.com/shopper/zipmap.php?la='+lat+'&lo='+lon+'','info','width=600, height=600, scrollbars=0');x.focus();
}
function popcurcon(){
	x=window.open('http://www.xe.com/pca/input.cgi?&From=EUR&To=GBP','info','width=600, height=150, scrollbars=0');x.focus();
}

function ow(loc,img){
	if (img!=""){
		var myImage = new Image;
		myImage.src = img;
	}
	x=window.open(loc,'info','width=600, height=400, scrollbars=1, resize=1');x.focus();
}

function confdelc(page,id1, id2, id3, id4){
	if (confirm("Are you Sure?")){
		varlink = page+".php?"+id1+"="+id2+"&"+id3+"="+id4;
		window.location = varlink;
	}
}



function showhide(group,show){
var hed = group.replace("rep_","hed_");


if(document.getElementById(group).style.display =='none'){
 document.getElementById(group).style.display ='block';
document.getElementById(hed).style.backgroundColor ='#accff5';
}else{
 document.getElementById(group).style.display ='none';
document.getElementById(hed).style.backgroundColor ='#cdcf0e';
}
}


function popcatsupord(){
	x=window.open('profile_pop_catsuper_order.php','info','width=600, height=150, scrollbars=0');x.focus();
}
function popcatord(supcat){
	x=window.open('profile_pop_category_order.php?sup='+supcat+'','info','width=600, height=150, scrollbars=0');x.focus();
}


function popUp(url) {
    intW = 600;
    intH = 400;
    intX=(screen.width/2)-(intW/2);
    intY=(screen.height/2)-(intH/2);
    if (intX > screen.width){intX = screen.width;}
    if (intY > screen.height){intX = screen.height;}
    //eval("window.open(url, '', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1);");
    eval("window.open(url, '', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width="+intW+",height="+intH+",left="+intX+",top="+intY+"');");
}

function refPage() {setTimeout('location.reload(true)',10000);}
