// Variable names required: Iloc = Image Location (i.e. 'images/nav/'), Ext = Extension (i.e. '.gif')
Ext='.gif'; Numx='x'; Stateon='_on'; Stateoff='_off';
Iloc = 'images/buttons/';
////////////////// GENERAL MOUSEOVER FUNCTIONS ///////////////////
i = "0"
function MouseCLICK(Num){
	document.images[Num].src = Iloc+document.images[Num].name+Stateon+Ext;
	if (Numx != Num && Numx != 'x'){document.images[Numx].src = Iloc+document.images[Numx].name+Stateoff+Ext;}
	Numx = Num
	window.status="";
}
function MouseON(Num,Srs){
	document.images[Num].src = Iloc+document.images[Num].name+Stateon+Ext;
	if (Srs == null){Srs = document.images[Num].alt}
	window.status=Srs;
}
function MouseOFF(Num){
	if (Num != Numx){document.images[Num].src = Iloc+document.images[Num].name+Stateoff+Ext;}
	window.status="";
}
function ImageOn(){
	MouseCLICK(ImgOn)
}
function MouseStick(Num){
	document.images[Num].src = Iloc+document.images[Num].name+'_on'+Ext; Numx = Num
	window.status="";
}
/////////////////////////////////////////////////////////////
// Icon mouseover functions

function IconOn(Num,imagename){
	document.images[Num].src = Iloc+imagename+Stateon+Ext;
	Srs = document.images[Num].alt
	window.status=Srs;
}
function IconOff(Num,imagename){
	if (Num != Numx){document.images[Num].src = Iloc+imagename+Stateoff+Ext;}
	window.status="";
}

/////////////////////////////////////////////////////////////
// Layer functions
/////////////////////////////////////////////////////////////
if (document.layers)
	var doc = 'document.document.', vis = '.visibility', pos = '.top';;
if (document.all)
   var doc = 'document.all.', vis = '.style.visibility', pos = '.style.top';;

// get layer's position
function getSize(layerName, value){
  layer = (document.all) ? eval(layerName).style : document.eval(layerName);
    if(value=="left") return parseInt(layer.left);
    if(value=="top") return parseInt(layer.top);
    if(value=="width") return parseInt(layer.width);
    if(value=="height") return parseInt(layer.height);
}
function moveLayerTo(layerName,L,T){
	layer = (document.all) ? eval(layerName).style : document.eval(layerName);
	LX=parseInt(layer.left);
	TX=parseInt(layer.top);
	if (L > LX){LX=LX+5}
	if (L < LX){LX=LX-5}
	if (T > TX){TX=TX+5}
	if (T < TX){TX=TX-5}
	if(document.all){
		eval(layerName).style.pixelLeft = LX;
		eval(layerName).style.pixelTop = TX;
	}
	if(document.layers){
		document.layers[layerName].moveTo(LX,TX);
	}
	if (L!=LX || T!=TX){
		timer = setTimeout("moveLayerTo('"+layerName+"',"+L+","+T+")",1);
	}

}
function moveLayerBy(layerName,L,T){
	LX=0; TX=0;
	if (L >= 1){L--; LX=1}
	if (L < 0) {L++; LX=-1}
	if (T >= 1){T--; TX=1}
	if (T < 0) {T++; TX=-1}

	if(document.all){
		eval(layerName).style.pixelLeft += LX;
		eval(layerName).style.pixelTop += TX;
	}
	if(document.layers){
		document.layers[layerName].moveBy(LX,TX);
	}
	if (T!=0 || L!=0){
		timer = setTimeout("moveLayerBy('"+layerName+"',"+L+","+T+")",30);
	}

}


function show(object) {
	if (document.layers || document.all)
		eval(doc + object + vis + ' = "visible"');
}

function hide(object) {
	if (document.layers || document.all)
		eval(doc + object + vis + ' = "hidden"');
}

function WriteToLayer(object,content){
	if (document.layers) {
		document.layers[object].document.open();
		document.layers[object].document.write("&nbsp;"+content);
		document.layers[object].document.close();
	}
	else if (document.all){
		document.all(object).innerHTML = "&nbsp;" + content;
	}
}
/////////////////////////////////////////////////////////////
function SearchFocus(FormName){
	document.forms[FormName].searchtext.focus()
}
/////////////////////////////////////////////////////////////
function rnd() {
		rnd.today=new Date();
		rnd.seed=rnd.today.getTime();
        rnd.seed = (rnd.seed*9301+49297) % 233280;
        return rnd.seed/(233280.0);
};
function rand(number) {
        return Math.ceil(rnd()*number);
};
/////////////////////////////////////////////////////////////

/////////////////////////////////////////////////////////////
// Function to higlight text boxes, uses obj=Ojbect name, bg=#BackGround Colour, bc=#BorderColour
function MarkMe(obj,bg,bc) {
	blurred=false;
    if (obj.style.backgroundColor == "")
	{
	   if (obj.value == "(optional)"){obj.value=''}
	   obj.style.backgroundColor = bg;
	   obj.style.borderColor = bc;
	}
    else {
    	obj.style.backgroundColor = "";
		obj.style.borderColor = "";
	}
}
function Disable()
{
	// for IE 4.0+
	if (document.all)
	{
		document.all.Submit.setAttribute("disabled", true);
		document.all.Submit.value="Submitting...";
		document.all.Submit.style.borderColor = "#FF0000";
		document.all.Submit.style.backgroundColor = "#FFFFFF";
		//document.all.login.submit();
	}
}
/////////////////////////////////////////////////////////////
function SearchValidate(){
validated = false;
if (document.Search.terms.value == ''){
	alert('Please enter a keyword to search');
	return false;}
	else {validated = true}
if (validated){return true};
}
/////////////////////////////////////////////////////////////
// Print page function - does not work in Netscape (what does!)
function PrintPage(){
if (navigator.appName.indexOf("Netscape") != -1){alert("Sorry, Netscape does not offer the option to print this way,\nplease use your printer option from the browser itself.")}
bg=document.body.background
bgc=document.body.bgColor
document.body.background='';
document.bgColor='#FFFFFF';
window.print();
document.body.background=bg;
document.bgColor=bgc
}

function BookMark(){
if ((navigator.appVersion.indexOf("MSIE") > 0)&& (parseInt(navigator.appVersion) >= 4)){window.external.AddFavorite(self.document.location.href, document.title);}
else {alert('why not bookmark this web site?')}
}

/////////////////////////////////////////////////////////////
function PageLoaded(){
	// this requires tooltip.js
	tip = new uberToolTip( null , 50 );
   	tip.init();
}
/////////////////////////////////////////////////////////////

function OpenPopup(URL,width,height){
var WLoc = 0, HLoc = 0; // default values

if (document.all) {
  WLoc = window.screenTop + 580;
  HLoc = window.screenLeft + 100;
}
else if (document.layers) {
  WLoc = window.screenX + 580;
  HLoc = window.screenY + 100;
}
var WLoc = 0, HLoc = 0;
setTimeout("window.open('"+URL+"','PopUp','height="+height+",width="+width+",top="+HLoc+",left="+WLoc+",screenY="+HLoc+",screenX="+WLoc+",alwaysLowered=0,alwaysRaised=0,channelmode=0,dependent=0,directories=0,fullscreen=0,hotkeys=1,location=0,menubar=0,resizable=1,scrollbars=1,status=0,titlebar=1,toolbar=0,z-lock=0')",1);
}
function EditImageShow(Num,Name){
	document.images[Num].src = 'images/'+Name
}
// Replaces text with by in string //////////////////////////////////////
function Replace(string,text,by) {
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;

    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;

    var newstr = string.substring(0,i) + by;

    if (i+txtLength < strLength)
        newstr += Replace(string.substring(i+txtLength,strLength),text,by);

    return newstr;
} // End Replace function
/////////////////////////////////////////////////////////////
//var message="(c) 2003 Kiln Plc.";
//function clickIE() {if (document.all){(message);return false;}}
//function clickNS(e) {if
//(document.layers||(document.getElementById&&!document.all)) {
//if (e.which==2||e.which==3) {(message);return false;}}}
//if (document.layers)
//{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
//else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
//document.oncontextmenu=new Function("return false")
/////////////////////////////////////////////////////////////
function Register(){
	height="475";
	width="340";
	EmailWindow('register.asp');
}
function ForgotPassword(){
	height = "250";
	width="325";
	EmailWindow('forgotpassword.asp');
	
}
function GeneralEnquiries(){
	height = "450";
	width="260";
	EmailWindow('http://www.kilnplc.com/emailer.asp?u=GeneralEnquiries');
}
function EmailPage(){
	height = "450";
	width="260";
	EmailWindow('email_page.html');
//	EmailWindow('loading_email.html');
}
function Emailer(user_name, user_title, user_email, user){
	height = "450";
	width="260";
	
	MailName = user_name;
	MailTo = user_email;
	MailNameTitle = user_title;
	MailUser = user;
	EmailWindow('loading.html');
} // end Email function
function EmailWindow(URL){
	Point=1;
	if (top.screen) {
		if (screen.width >=800){var Point=20;}
		if (screen.width >=1024){var Point=40;}
	}
	setTimeout("window.open('"+URL+"','Kilnmailer','height="+ height + ",width=" + width + ",top="+Point+",left="+Point+",screenY="+Point+",screenX="+Point+",alwaysLowered=0,alwaysRaised=0,channelmode=0,dependent=0,directories=0,fullscreen=0,hotkeys=1,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0,z-lock=0')",1);
} // end EmailWindow function

/////////////////////////////////////////////////////////////
function popup(str_url, int_width, int_height, str_name) {
	var winX = (screen.width - int_width) / 2;
	var winY = (screen.height - int_height) / 2;
	str_WinParams = 'height=' + int_height +',width=' + int_width + ',top=' + winY+',left=' + winX + ',menubar=1,toolbar=0,scrollbars=1,resizable=0,status=0,toolbar=0';
	win = window.open(str_url, str_name, str_WinParams);
	if ((parseInt(navigator.appVersion) >= 4)|| (navigator.appName = 'Netscape')) { win.window.focus(); }
}

/////////////////////////////////////////////////////////////
//// Pageloader function

function LeavePage(Text){
	//document.body.style.filter="alpha(opacity=50, style=0, enabled=1);";
	//tip.show('<img src=\'images/loadingbox.gif\' align=\'absmiddle\'>  Loading '+Text+' page...')

	LoaderSetPos(); setLoadingvalues(); refresh_wm();

	HTML = "<span class='SectionTitle'>&nbsp;Loading...</span><br><br>"
	HTML += "<span class='linehigh'><img src='images/linelight.gif' width='230' height='1'><br>&nbsp;&nbsp;"
	HTML += Text
	HTML += "<br><img src='images/linelight.gif' width='230' height='1'></span><br><br>"

	WriteToLayer('LoadingText',HTML)
	show('LoadingText');
	show('Loading');
	//document.all['Loading'].style.filter="alpha(opacity=75, style=0, enabled=1);"
}

/////////////////////////////////////////////////////////////
//// WaterMark features

function LoaderSetPos(){
	width = 210; // width in pixels
	height = 50; // height in pixels
	rightx = 50; // move to the right x percent
	downy = 50; // move down x percent
	wm_reload = 100; // milliseconds to reload the position of the watermark

	if (!document.all) document.all = document;
	if (!document.all.Loading.style) document.all.Loading.style = document.all.Loading;

	wm = document.all.Loading.style;
	wm.width = width;
	wm.height = height;
	navDOM = window.innerHeight; // navigator handles it a little differently
}

function setLoadingvalues() {
  barwidth = 0; // compensate for the scrollbar on PC width
  barheight = 0; // height
  if (navDOM) {
    if (document.height > innerHeight) barwidth = 20;
    if (document.width > innerWidth) barheight = 20;
  } else {
    innerWidth = document.body.clientWidth;
    innerHeight = document.body.clientHeight;
  }
  posX = ((innerWidth - width)-barwidth) * (rightx/100);
  posY = ((innerHeight - height)-barheight) * (downy/100);
}

function refresh_wm() {
  wm.left = posX + (navDOM?pageXOffset:document.body.scrollLeft);
  wm.top = posY + (navDOM?pageYOffset:document.body.scrollTop);
}

function resize_wm() {
  setLoadingvalues();
  window.onresize=setLoadingvalues;
  markID = setInterval ("refresh_wm()",wm_reload);
}


//////////// Hide Form Drop down  items ///////////////
/* hides <select> and <applet> objects (for IE only) */

// Call with hideElement( 'SELECT', document.getElementById(id+'Container') );

function hideElement( elmID, overDiv ){
  if(document.all){
	for( i = 0; i < document.all.tags( elmID ).length; i++ )
	{
	  obj = document.all.tags( elmID )[i];
	  if( !obj || !obj.offsetParent ){continue;}
	  // Find the elements offsetTop and offsetLeft relative to the BODY tag.
	  objLeft   = obj.offsetLeft;
	  objTop    = obj.offsetTop;
	  objParent = obj.offsetParent;
	  while( objParent.tagName.toUpperCase() != "BODY" )
	  {
		objLeft  += objParent.offsetLeft;
		objTop   += objParent.offsetTop;
		objParent = objParent.offsetParent;
	  }
	  objHeight = obj.offsetHeight;
	  objWidth = obj.offsetWidth;
	  if(( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft );
	  else if(( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop );
	  else if( overDiv.offsetTop >= ( objTop + objHeight ));
	  else if( overDiv.offsetLeft >= ( objLeft + objWidth ));
	  else
	  {
		obj.style.visibility = "hidden";
	  }
	}
  }
}

function showElement( elmID ){
  if(document.all){
	for( i = 0; i < document.all.tags( elmID ).length; i++ ){
	  obj = document.all.tags( elmID )[i];
	  if( !obj || !obj.offsetParent ){continue;}
	  obj.style.visibility = "";
	}
  }
}



/*4continuity relevant only */

PageName =  self.document.title.substring(21,45)
URL      =  self.location.href