/*//////////////////////////////////////////////////////////
	Onload
//////////////////////////////////////////////////////////*/
	
	$(document).ready(function(){
		
		// load drop down js
		sfHover();
		
		// entire div clickable in extras
		$("ul#extraServices li").css('cursor', 'pointer');
		$("ul#extraServices li").hover(function() {
			$(this).addClass('hover');
		}, function() {
			$(this).removeClass('hover');
		});
		$("ul#extraServices li").click(function(){
			window.location=$(this).find("a").attr("href");return false;
		});
		
		// lightbox
		$('a.lightbox').lightBox();
		
	});	

/*//////////////////////////////////////////////////////////
	Dropdown
//////////////////////////////////////////////////////////*/

	// drop down menu
	function fnApplyHover(sfEls) {
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+="sfHover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace("sfHover", "");
			}
		}
	}
	sfHover = function() {
		var sfEls = document.getElementById("header").getElementsByTagName("LI");
		fnApplyHover(sfEls);
	}

/*//////////////////////////////////////////////////////////
	SWF Object
//////////////////////////////////////////////////////////*/

	var flashvars = {};
	flashvars.sXMLFile = "/flash/subad/web.xml";
	var params = {};
	params.menu = "false";
	params.wmode = "transparent";
	var attributes = {};
	attributes.id = "miniFlash";
	
	swfobject.embedSWF("/flash/subad/sub-ad.swf", "miniFlashAd", "298", "298", "9.0.0",false, flashvars, params, attributes);

/*//////////////////////////////////////////////////////////
	Previous Site - Calc Stuff
//////////////////////////////////////////////////////////*/

	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_showHideLayers() { //v6.0
	  var i,p,v,obj,args=MM_showHideLayers.arguments;
	  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
		if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
		obj.visibility=v; }
	}
	//
	// The URL of the live web site
	var myURL = "";
	var numberOfPics = 7;
	//
	/* Global browser sniffs */
	//
	var agt			=	navigator.userAgent.toLowerCase();
	var is_mac    	= 	(agt.indexOf("mac")!=-1);
	var is_pc    	= 	(agt.indexOf("win")!=-1);
	var is_ie     	= 	(agt.indexOf("msie")!= -1);
	var is_firefox 	= 	(agt.indexOf("firefox")!= -1);
	var is_opera	=	(agt.indexOf("opera")!= -1);
	var is_safari	=	(agt.indexOf("safari")!=-1);
	//
	// calculate wmv costs
	function getPrice(f, price) {
	   // windows media price
	   wprice = Math.round(((price/250) * f.wbitrate.value * f.wconcurrents.value) * 100) / 100;
	   // quicktime price
	   qprice = Math.round(((price/250) * f.qbitrate.value * f.qconcurrents.value) * 100) / 100;
	   // total price
	   tprice = "&pound;"+(wprice+qprice);
	   // total price per annum
	   tpricea =  "&pound;"+((wprice+qprice)*12);
		if (document.getElementById) {
			// windows media price
			document.getElementById('wPrice').innerHTML = wprice;
			// quicktime price
			document.getElementById('qPrice').innerHTML = qprice;
			// total price
			document.getElementById('tPrice').innerHTML = tprice;
			// total price per annum
			if (d = document.getElementById('tPriceA')) {
				d.innerHTML = tpricea;
			}
		} else if (document.all) {
			// windows media price
			document.all.wPrice.innerHTML = wprice;
			// quicktime price
			document.all.qPrice.innerHTML = qprice;
			// total price
			document.all.tPrice.innerHTML = tprice;
			// total price per annum
			if (d = document.all.tPriceA) {
				d.innerHTML = tpricea;
			}
		}
	}

	function getDSVPrice(f) {
		dos = f.dos.value;
		dCap = f.dcap.value;
		dmem = f.dmem.value;
		dtrans = f.dtrans.value;
		dbackup = f.dbackup.value;
		dcpu = f.dcpu.value;

		annual = 0;

		//	Operating system
		if (dos=="windows") annual += 100;

		//	Capacity
		annual += dCap * 4;

		//	Memory
		switch(dmem) {
			case "256" :
				annual += 100;
				break;
			case "512" :
				annual += 250;
				break;
			case "1024" :
				annual += 500;
				break;
			case "2048" :
				annual += 950;
				break;
			case "4096" :
				annual += 1500;
		}

		//CPU
		annual += dcpu * 500;

		//	Transfer
	//	if (btrans > 1) {
			annual += dtrans * 720;
	//	} else {
	//		annual += 480;
	//	}

		//	Backup
		if (dbackup)	annual += dbackup * 12.5;

		tpricea = Math.round((annual)*100) / 100;	//	Annual Price
		tprice = Math.round((annual/12)*100) / 100;	//	Monthly (from annual)

		tpricea = new Number(tpricea);
		tprice = new Number(tprice);

		tpricea = "&pound;"+tpricea.toFixed(2);
		tprice = "&pound;"+tprice.toFixed(2);

		if (document.getElementById) {
			// total price
			document.getElementById('tPrice').innerHTML = tprice;
			// total price per annum
			if (d = document.getElementById('tPriceA')) {
				d.innerHTML = tpricea;
			}
		} else if (document.all) {
			// total price
			document.all.tPrice.innerHTML = tprice;
			// total price per annum
			if (d = document.all.tPriceA) {
				d.innerHTML = tpricea;
			}
		}
	}