var blnBorder 	= false;
var loc_prfx 	= 'http://www.kln-design.co.uk/';
var img_prfx 	= 'http://www.kln-design.co.uk/images/';
a1a 			= new Image;
a1a.src			= img_prfx + "leftcurve_mo.gif";
a2a 			= new Image;
a2a.src			= img_prfx + "leftcurve.gif";
a3a 			= new Image;
a3a.src			= img_prfx + "rightcurve.gif";
a4a 			= new Image;
a4a.src			= img_prfx + "rightcurve_mo.gif";

function setBorder(id,bOn)
{
	var oTab    = document.all.item(id+"Tab");
	var oTab1   = document.all.item(id+"Tab1");
	var oTab2   = document.all.item(id+"Tab2");
	var oTab3   = document.all.item(id+"Tab3");
	var oBorder = document.all.item(id+"Content");

	if (!oTab || !oTab1 || !oTab2 || !oBorder) 
		return;

	if (bOn)
	{
		oBorder.style.borderColor = "#ffd849";
		oTab.bgColor = "#b0c4de";
		oTab1.src    = img_prfx + "leftcurve_mo.gif";
		oTab2.color  = "#FFFFFF";
		oTab3.src    = img_prfx + "rightcurve_mo.gif";
	}
	else
	{
		oBorder.style.borderColor = blnBorder?  "#cccccc" : "#f0f4fe";
		oTab.bgColor = "#f0f4fe";
		oTab1.src    = img_prfx + "leftcurve.gif";
		oTab2.color  =  "#336699";
		oTab3.src    = img_prfx + "rightcurve.gif";
	}
}

function setBorder2(id,bOn)
{
	var oTab    = document.all.item(id);

	if (!oTab) 
		return;

	if (bOn)
	{
		oTab.style.borderColor = "#ffd849";
	}
	else
	{
		oTab.style.borderColor = blnBorder? "#cccccc" : "#f0f4fe";
	}
}

window.onerror = null;
var topMargin = 29;
var slideTime = 1200;
var ns6 = (!document.all && document.getElementById);
var ie4 = (document.all);
var ns4 = (document.layers);
function layerObject(id,left) {
if (ns6) {
this.obj = document.getElementById(id).style;
this.obj.left = left;
return this.obj;
}
else if(ie4 && document.all[id]) {
this.obj = document.all[id].style;
this.obj.left = left;
return this.obj;
}
else if(ns4) {
this.obj = document.layers[id];
this.obj.left = left;
return this.obj;
   }
}
function layerSetup() {
floatLyr = new layerObject('floatLayer', 20);
window.setInterval("main()", 10)
}
function floatObject() {
if (ns4 || ns6) {
findHt = window.innerHeight;
} else if(ie4) {
findHt = document.body.clientHeight;
   }
} 
function main() {
if (ns4) {
this.currentY = document.layers["floatLayer"].top;
this.scrollTop = window.pageYOffset;
mainTrigger();
}
else if(ns6) {
this.currentY = parseInt(document.getElementById('floatLayer').style.top);
this.scrollTop = scrollY;
mainTrigger();
} else if(ie4 && document.all("floatLayer") != null) {
this.currentY = document.all("floatLayer").style.pixelTop;
this.scrollTop = document.body.scrollTop;
mainTrigger();
   }
}
function mainTrigger() {
var newTargetY = this.scrollTop + this.topMargin + 110;
if ( this.currentY != newTargetY ) {
if ( newTargetY != this.targetY ) {
this.targetY = newTargetY;
floatStart();
}
animator();
   }
}
function floatStart() {
var now = new Date();
this.A = this.targetY - this.currentY;
this.B = Math.PI / ( 2 * this.slideTime );
this.C = now.getTime();
if (Math.abs(this.A) > this.findHt) {
this.D = this.A > 0 ? this.targetY - this.findHt : this.targetY + this.findHt;
this.A = this.A > 0 ? this.findHt : -this.findHt;
}
else {
this.D = this.currentY;
   }
}
function animator() {
var now = new Date();
var newY = this.A * Math.sin( this.B * ( now.getTime() - this.C ) ) + this.D;
newY = Math.round(newY);
if (( this.A > 0 && newY > this.currentY ) || ( this.A < 0 && newY < this.currentY )) {
if ( ie4 )document.all.floatLayer.style.pixelTop = newY;
if ( ns4 )document.layers["floatLayer"].top = newY;
//if ( ns6 )document.getElementById('floatLayer').style.top = newY + "px";
   }
}
function start() {
if(ns6||ns4) {
pageWidth = innerWidth;
pageHeight = innerHeight;
layerSetup();
floatObject();
}
else if(ie4) {
pageWidth = document.body.clientWidth;
pageHeight = document.body.clientHeight;
layerSetup();
floatObject();
   }
}

// Macromedia Javascript Routines - (c) Macromedia

function MM_findObj(n, d) { //v4.01
  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 && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

// Image Routines - (c) KLN Design

klnfadeidFadeObjects = new Object();
klnfadeidFadeTimers = new Object();


function klnfadeidFade(object, destOp, rate, delta){
if (!document.all)
return
    if (object != "[object]"){
        setTimeout("klnfadeidFade("+object+","+destOp+","+rate+","+delta+")",0);
        return;
    }
        
    clearTimeout(klnfadeidFadeTimers[object.sourceIndex]);
    
    diff = destOp-object.filters.alpha.opacity;
    direction = 1;
    if (object.filters.alpha.opacity > destOp){
        direction = -1;
    }
    delta=Math.min(direction*diff,delta);
    object.filters.alpha.opacity+=direction*delta;

    if (object.filters.alpha.opacity != destOp){
        klnfadeidFadeObjects[object.sourceIndex]=object;
        klnfadeidFadeTimers[object.sourceIndex]=setTimeout("klnfadeidFade(klnfadeidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
    }
}


function tree (a_items, a_template) {
	this.a_tpl      = a_template;
	this.a_config   = a_items;
	this.o_root     = this;
	this.a_index    = [];
	this.o_selected = null;
	this.n_depth    = -1;
	
	var o_icone = new Image(),
		o_iconl = new Image();
	o_icone.src = a_template['icon_e'];
	o_iconl.src = a_template['icon_l'];
	a_template['im_e'] = o_icone;
	a_template['im_l'] = o_iconl;
	for (var i = 0; i < 64; i++)
		if (a_template['icon_' + i]) {
			var o_icon = new Image();
			a_template['im_' + i] = o_icon;
			o_icon.src = a_template['icon_' + i];
		}
	
	this.toggle = function (n_id) {	var o_item = this.a_index[n_id]; o_item.open(o_item.b_opened) };
	this.select = function (n_id) { return this.a_index[n_id].select(); };
	this.mout   = function (n_id) { this.a_index[n_id].upstatus(true) };
	this.mover  = function (n_id) { this.a_index[n_id].upstatus() };

	this.a_children = [];
	for (var i = 0; i < a_items.length; i++)
		new tree_item(this, i);

	this.n_id = trees.length;
	trees[this.n_id] = this;
	
	for (var i = 0; i < this.a_children.length; i++) {
		document.write(this.a_children[i].init());
		this.a_children[i].open();
	}
}
function tree_item (o_parent, n_order) {

	this.n_depth  = o_parent.n_depth + 1;
	this.a_config = o_parent.a_config[n_order + (this.n_depth ? 2 : 0)];
	if (!this.a_config) return;

	this.o_root    = o_parent.o_root;
	this.o_parent  = o_parent;
	this.n_order   = n_order;
	this.b_opened  = !this.n_depth;

	this.n_id = this.o_root.a_index.length;
	this.o_root.a_index[this.n_id] = this;
	o_parent.a_children[n_order] = this;

	this.a_children = [];
	for (var i = 0; i < this.a_config.length - 2; i++)
		new tree_item(this, i);

	this.get_icon = item_get_icon;
	this.open     = item_open;
	this.select   = item_select;
	this.init     = item_init;
	this.upstatus = item_upstatus;
	this.is_last  = function () { return this.n_order == this.o_parent.a_children.length - 1 };
}

function item_open (b_close) {
	var o_idiv = get_element('i_div' + this.o_root.n_id + '_' + this.n_id);
	if (!o_idiv) return;
	
	if (!o_idiv.innerHTML) {
		var a_children = [];
		for (var i = 0; i < this.a_children.length; i++)
			a_children[i]= this.a_children[i].init();
		o_idiv.innerHTML = a_children.join('');
	}
	o_idiv.style.display = (b_close ? 'none' : 'block');
	
	this.b_opened = !b_close;
	var o_jicon = document.images['j_img' + this.o_root.n_id + '_' + this.n_id],
		o_iicon = document.images['i_img' + this.o_root.n_id + '_' + this.n_id];
	if (o_jicon) o_jicon.src = this.get_icon(true);
	if (o_iicon) o_iicon.src = this.get_icon();
	this.upstatus();
}

function item_select (b_deselect) {
	if (!b_deselect) {
		var o_olditem = this.o_root.o_selected;
		this.o_root.o_selected = this;
		if (o_olditem) o_olditem.select(true);
	}
	var o_iicon = document.images['i_img' + this.o_root.n_id + '_' + this.n_id];
	if (o_iicon) o_iicon.src = this.get_icon();
	get_element('i_txt' + this.o_root.n_id + '_' + this.n_id).style.fontWeight = b_deselect ? 'normal' : 'bold';
	
	this.upstatus();
	return Boolean(this.a_config[1]);
}

function item_upstatus (b_clear) {
	window.setTimeout('window.status="' + (b_clear ? '' : this.a_config[0] ) + '"', 10);
}

function item_init () {
	var a_offset = [],
		o_current_item = this.o_parent;
	for (var i = this.n_depth; i > 1; i--) {
		a_offset[i] = '<img src="' + this.o_root.a_tpl[o_current_item.is_last() ? 'icon_e' : 'icon_l'] + '" border="0" align="absbottom">';
		o_current_item = o_current_item.o_parent;
	}
	return '<table cellpadding="0" cellspacing="0" border="0"><tr><td nowrap>' + (this.n_depth ? a_offset.join('') + (this.a_children.length
		? '<a href="javascript: trees[' + this.o_root.n_id + '].toggle(' + this.n_id + ')" onmouseover="trees[' + this.o_root.n_id + '].mover(' + this.n_id + ')" onmouseout="trees[' + this.o_root.n_id + '].mout(' + this.n_id + ')"><img src="' + this.get_icon(true) + '" border="0" align="absbottom" name="j_img' + this.o_root.n_id + '_' + this.n_id + '"></a>'
		: '<img src="' + this.get_icon(true) + '" border="0" align="absbottom">') : '') 
		+ '<a href="' + this.a_config[1] + '" target="' + this.o_root.a_tpl['target'] + '" onclick="return trees[' + this.o_root.n_id + '].select(' + this.n_id + ')" ondblclick="trees[' + this.o_root.n_id + '].toggle(' + this.n_id + ')" onmouseover="trees[' + this.o_root.n_id + '].mover(' + this.n_id + ')" onmouseout="trees[' + this.o_root.n_id + '].mout(' + this.n_id + ')" class="t' + this.o_root.n_id + 'i" id="i_txt' + this.o_root.n_id + '_' + this.n_id + '"><img src="' + this.get_icon() + '" border="0" align="absbottom" name="i_img' + this.o_root.n_id + '_' + this.n_id + '" class="t' + this.o_root.n_id + 'im">' + this.a_config[0] + '</a></td></tr></table>' + (this.a_children.length ? '<div id="i_div' + this.o_root.n_id + '_' + this.n_id + '" style="display:none"></div>' : '');
}

function item_get_icon (b_junction) {
	return this.o_root.a_tpl['icon_' + ((this.n_depth ? 0 : 32) + (this.a_children.length ? 16 : 0) + (this.a_children.length && this.b_opened ? 8 : 0) + (!b_junction && this.o_root.o_selected == this ? 4 : 0) + (b_junction ? 2 : 0) + (b_junction && this.is_last() ? 1 : 0))];
}

var trees = [];
get_element = document.all ?
	function (s_id) { return document.all[s_id] } :
	function (s_id) { return document.getElementById(s_id) };



var TREE_ITEMS = [

	['Home', '../index.php',
	
		['About Us', '../index.php'],
		
		['Clients Area', '../client-area/index.php'],
		
		['Contact Us', '../contact/index.php',	
			['Postal Address', '../contact/postal/index.php'],
			['Job Vacancys', '../contact/jobs/index.php'],
			['Contact Us Form', '../contact/form/index.php'],
			['Quotation', '../contact/quote/index.php'],
		],
		
		['Downloads', '../downloads/index.php'],
	
		['Information', '#',	
			['Do I Need a Website', '../info/index.php?action=w'],
			['Development Stages', '../info/index.php?action=d'],
			['Privacy Policy', '../info/index.php?action=p'],
			['Terms and Conditions', '../info/index.php?action=t'],
		],
					
		['Newsletter', '../newsletter/index.php'],
		
		['Portfolio', '../portfolio/index.php'],	
	
		['Services', '../services/index.php',	
			['Business Stationary', '../services/business/index.php'],
			['Search Engine Submission', '../services/search/index.php'],
			['E-Commerce', '../services/ecommerce/index.php',
				['KLN-Shop', '../services/ecommerce/kln-shop/index.php',
				 	['KLN-Shop Demonstartion','../services/ecommerce/kln-shop/domo/index.htm'],
				 	['KLN-Shop Download','../services/ecommerce/kln-shop/download/kln-shop.zip'],
				],
					['Q-Shop', '../services/ecommerce/q-shop/index.php',
				 	['Q-Shop Demo [User]','../services/ecommerce/q-shop/demo/catalog/index.php'],
				 	['Q-Shop Demo [Admin]','../services/ecommerce/q-shop/demo/admin/index.php'],
				 ],
			],
			
			['Hardware / Upgrades', '../services/hardware/index.php'],
			
			['Website Design', '../services/website/index.php',
				['Website Costs', '../services/website/cost/index.php'],
				['Website Samples', '../services/website/samples/index.php'],
				['Website Templates', '../services/website/templates/index.php'],
			],
			
			['Website Hosting', 'services/hosting/index.php',
				['Bronze Package', '../services/hosting/bronze/index.php'],
				['Silver Package', '../services/hosting/silver/index.php'],
				['Gold Package', '../services/hosting/gold/index.php'],
				['Platinum Package', '../services/hosting/platinum/index.php'],
			],
			
		],
		
		['Site Map', '../sitemap/index.php'],
	],
	

];

var tree_tpl = {
	'target'  : '_self',	// name of the frame links will be opened in
							// other possible values are: _blank, _parent, _search, _self and _top

	'icon_e'  : '../images/icons/empty.gif', // empty image
	'icon_l'  : '../images/icons/line.gif',  // vertical line
	
	'icon_48' : '../images/icons/base.gif',   // root icon normal
	'icon_52' : '../images/icons/base.gif',   // root icon selected
	'icon_56' : '../images/icons/base.gif',   // root icon opened
	'icon_60' : '../images/icons/base.gif',   // root icon selected
	
	'icon_16' : '../images/icons/folder.gif', // node icon normal
	'icon_20' : '../images/icons/folderopen.gif', // node icon selected
	'icon_24' : '../images/icons/folder.gif', // node icon opened
	'icon_28' : '../images/icons/folderopen.gif', // node icon selected opened

	'icon_0'  : '../images/icons/page.gif', // leaf icon normal
	'icon_4'  : '../images/icons/page.gif', // leaf icon selected
	'icon_8'  : '../images/icons/page.gif', // leaf icon opened
	'icon_12' : '../images/icons/page.gif', // leaf icon selected
	
	'icon_2'  : '../images/icons/joinbottom.gif', // junction for leaf
	'icon_3'  : '../images/icons/join.gif',       // junction for last leaf
	'icon_18' : '../images/icons/plusbottom.gif', // junction for closed node
	'icon_19' : '../images/icons/plus.gif',       // junctioin for last closed node
	'icon_26' : '../images/icons/minusbottom.gif',// junction for opened node
	'icon_27' : '../images/icons/minus.gif'       // junctioin for last opended node
};


function  doMath() {
var qty1 = eval(document.invoice.qty1.value);
var qty2 = eval(document.invoice.qty2.value);
var qty3 = eval(document.invoice.qty3.value);
var qty4 = eval(document.invoice.qty4.value);
var qty5 = eval(document.invoice.qty5.value);
var cost1 = eval(document.invoice.cost1.value);
var cost2 = eval(document.invoice.cost2.value);
var cost3 = eval(document.invoice.cost3.value);
var cost4 = eval(document.invoice.cost4.value);
var cost5 = eval(document.invoice.cost5.value);
var tax = eval(document.invoice.vat.value);
var item1 = qty1  *   cost1;
var item2 = qty2  *   cost2;
var item3 = qty3  *   cost3;
var item4 = qty4  *   cost4;
var item5 = qty5  *   cost5;
var subt = item1 + item2 + item3 + item4 + item5;
var prod = subt * tax;
document.invoice.subtotal.value=custRound(subt,3);
document.invoice.total.value=custRound(prod,3);
}

function custRound(x,places) {
return (Math.round(x*Math.pow(10,places)))/Math.pow(10,places)
}