/*
PROJECT      Broyce Control Ltd
OWNERSHIP    Optimised Web Design, Philip Kay
ADDRESS      Duken House, Wootton, Bridgnorth, WV15 6EA, UK
TEL          +44 (0) 1746 781 653
MOBILE       +44 (0) 7711 317 681
EMAIL        kay@osltd.co.uk
RIGHTS       The contents and design of these pages are the property of
             the author who grants no rights for copying, distribution
             or reselling without prior written agreement.
COPYRIGHT    Copyright (c) 2009 Optimised Web Design
*/


var Broyce = new Cookie(document, "broyce", 8760); // 1 year
Broyce.load();
if(!Broyce.basket) Broyce.basket = ".";
Broyce.store();


function searching(Folder){
	var Str = document.search.query.value;
	var From = document.search.from.value;
	var Num = document.search.num.value;
	window.location = Folder+"SEARCH.PHP?query="+Str+"&amp;from="+From+"&amp;num="+Num;
}

function logged_in(){
	document.getElementsByTagName("*").login.style.display = "none";
	document.getElementsByTagName("*").logout.style.display = "inline";
}

function logged_out(){
	document.getElementsByTagName("*").login.style.display = "inline";
	document.getElementsByTagName("*").logout.style.display = "none";
}

function toggle(Id, Im){
	if(document.getElementById(Id)){
 	if(document.getElementById(Id).style.display == "none"){
 		document.getElementById(Im).style.display = "none";
 		document.getElementById(Id).style.display = "inline";
 	}
 	else{
 		document.getElementById(Im).style.display = "inline";
 		document.getElementById(Id).style.display = "none";
 	}
	}
	return true;
}

function pdf_in(Id){
	if(document.getElementById(Id)) document.getElementById(Id).bgColor = "#FF4B28";
}

function pdf_out(Id){
	if(document.getElementById(Id)) document.getElementById(Id).bgColor = "#809FE9";
}

function continue_pdf(){
	var Url = 'http://www.broycecontrol.com/' + Broyce.pdf.substr(3);
	var Args = 'left=0,top=0,width=800,height=580,resizable=yes';
	action = window.open(Url, 'pdfs', Args);
	window.location = 'HOME.PHP';
}

function pdf_show(Pdf, Show){
 if(session.keepLogin.value != "" || session.validUser.value == "1"){
		if(location.protocol.indexOf('file:') != -1){
			var Url = Pdf;
		}
		else if(Pdf.indexOf('../') != -1){
			var Url = 'http://www.broycecontrol.com/' + Pdf.substr(3);
		}
		else{
			var Url = 'http://www.broycecontrol.com/' + Pdf;
		}
		Args = 'left=0,top=0,width=800,height=580,resizable=yes';
		action = window.open(Url, 'pdfs', Args);
	}
	else{
		window.alert("This page is only available if you Register & Login");
		document.location = 'REGISTER.PHP';
	}
}

/* display img popup window - used for photos, maps, tech drawings, etc. */
function display_img(Title, Rel, Img, Width, Height){
	W = Width + 15;
	H = Height + 40;
	Args = 'screenX=0,screenY=0,left=0,top=0,width='+W+',height='+H+',outerWidth='+W+',outerHeight='+H+',resizable=yes';
	action = window.open('', 'img', Args);

	action.document.open();
	action.document.writeln('<html>');
	action.document.writeln('<head>');
	action.document.writeln('<title>'+Title+'</title>');
	action.document.writeln('<link rel=stylesheet href="'+Rel+'WHITE.CSS" type="text/css">');
	action.document.writeln('</head>');
	action.document.writeln('<body topmargin=5 leftmargin=5>');
	action.document.writeln('<table border=0 cellpadding=2 cellspacing=0 width=100%>');
	action.document.writeln('<tr bgcolor=#809FE9><td class=head>&nbsp;'+Title+'</td><td align=right>');
	action.document.writeln('<img OnMouseUp=window.print() align=center src="'+Rel+'IMAGES/PRINT.GIF" width=20 height=20 border=0 alt="Print image">');
	action.document.writeln('</td></tr>');
	action.document.writeln('<tr><td valign=center align=center colspan=2>');
	action.document.writeln('<img src='+Img+' border=1 width='+Width+' height='+Height+'>');
	action.document.writeln('</td></tr>');
	action.document.writeln('</table>');
	action.document.writeln('</body>');
	action.document.writeln('</html>');
	action.document.close();
	action.focus();
}

/* debugging prints */
function print1(A){printout(A, 'null', 'null', 'null', 'null', 'null', 'null', 'null');}
function print2(A, B){printout(A, B, 'null', 'null', 'null', 'null', 'null', 'null');}
function print3(A, B, C){printout(A, B, C, 'null', 'null', 'null', 'null', 'null');}
function print4(A, B, C, D){printout(A, B, C, D, 'null', 'null', 'null', 'null');}
function print5(A, B, C, D, E){printout(A, B, C, D, E, 'null', 'null', 'null');}
function print6(A, B, C, D, E, F){printout(A, B, C, D, E, F, 'null', 'null');}
function print7(A, B, C, D, E, F, G){printout(A, B, C, D, E, F, G, 'null');}
function print7(A, B, C, D, E, F, G, H){printout(A, B, C, D, E, F, G, H);}

function printout(A, B, C, D, E, F, G, H){
	Args = 'screenX=10,screenY=10,left=10,top=10,width=200,height=200,resizable';
	bugger = window.open('', 'bugger', Args);
	bugger.window.document.open();
	bugger.window.document.writeln('<html><head></head><body>');
	bugger.window.document.writeln('A='+A+'<br>B='+B+'<br>C='+C+'<br>D='+D+'<br>E='+E+'<br>F='+F+'<br>G='+G+'<br>H='+H);
	bugger.window.document.writeln('</body></html>');
	bugger.window.document.close();
	bugger.window.focus();
}

