///quicklinks dropdown select
function surfto(form) {
	var myindex = form.select1.selectedIndex;
	
	if (form.select1.options[myindex].value != "0") {
		location = form.select1.options[myindex].value;
	}
}

function productPopup(url) {
	var width = 525;
	var height = 350;
	var left = (screen.width-width)/2;
	var top = (screen.height*0.8-height)/2;
		
	newWin = window.open(url, "popup", "width="+width+",height="+height+",toolbar=no,location=no,directories=no,resizable=no,status=no,menubar=no,screenX=100,screenY=100, left="+left+", top="+top);
}


function productPopupbig(url) {
	var width = 625;
	var height = 630;
	var left = (screen.width-width)/2;
	var top = (screen.height*0.8-height)/2;
		
	newWin = window.open(url, "popup", "width="+width+",height="+height+",toolbar=no,location=no,directories=no,resizable=no,status=no,menubar=no,screenX=100,screenY=100, left="+left+", top="+top);
}



//Dedicated servers sign up popup

function dedicatedPopup() {
	var width = 460;
	var height = 550;
	var left = (screen.width-width)/2;
	var top = (screen.height*0.8-height)/2;
		
	newWin = window.open("https://signup.fasthosts.co.uk/dedicated/signup.exe?choose=2", "dedicatedsignup", "width="+width+",height="+height+",scrollbars=yes,toolbar=yes,location=yes,directories=yes,resizable=yes,status=yes,menubar=yes,screenX=100,screenY=100, left="+left+", top="+top);
}


//Hosting account sign up popup

function hostingSignup (url) {
	var width = 800;
	var height = 600;
	var left = (screen.width-width)/2;
	var top = (screen.height*0.8-height)/2;
		
	newWin = window.open(url, "hostingsignup", "width="+width+",height="+height+",scrollbars=yes,toolbar=yes,location=yes,directories=yes,resizable=yes,status=yes,menubar=yes,screenX=100,screenY=100, left="+left+", top="+top);
}


//Screenshot popup

function screenShot (url) {
	var width = 500;
	var height = 400;
	var left = (screen.width-width)/2;
	var top = (screen.height*0.8-height)/2;
		
	newWin = window.open(url, "screenshot", "width="+width+",height="+height+",scrollbars=no,toolbar=no,location=no,directories=no,resizable=no,status=no,menubar=no,screenX=100,screenY=1024, left="+left+", top="+top);
}


// Animates a button when clicked.
// To call, use onClick="startAnim(this);"

var objClickedBtn = '';
var i = 0;
var bolAnimating = false;

function startAnim(btn) {
	if (!bolAnimating) {
		objClickedBtn = btn;
		objClickedBtn.style.backgroundColor = '#999999';
		objClickedBtn.value = 'Please wait   ';
		bolAnimating = true;
		btnanim = setInterval('moretext()', 250);
	}
}
 
function moretext() {
	if (i == 0) {
		objClickedBtn.value = 'Please wait.  ';
	}
	else if (i == 1) {
		objClickedBtn.value = 'Please wait.. ';
	}
	else if (i == 2) {
		objClickedBtn.value = 'Please wait...';
	}
	else if (i == 3) {
		objClickedBtn.value = 'Please wait   ';
		i = -1;
	}
	i++;
}

//Opens a new popup window based on the URL provided

function popupWindow(url) {
	var width = 500;
	var height = 450;
	var left = (screen.width-width)/2;
	var top = (screen.height*0.8-height)/2;
	
	newWin = window.open(url, "FHDetails", "width="+width+", height="+height+", status=no, scrollbars, resizable=no, screenX=20, screenY=40, left="+left+", top="+top);
}

function newWindowResize(url, width, height, name) {
	var left = (screen.width-width)/2;
	var top = (screen.height*0.8-height)/2;
	
	newWin = window.open(url, name, "width="+width+", height="+height+", status=yes, scrollbars, resizable=yes, location=yes, toolbar=yes, menubar=yes, screenX=20, screenY=40, left="+left+", top="+top);
	newWin.focus();
}

/* Countdown */

function format(num) {
	if(num < 10) {
		return "0" + num;
	}
	else {
		return num;
	}
}

function updateCountdown(countdownDate) {
	var now = new Date();
	var event = new Date(countdownDate);
	
	if((event-now) > 0)	{
		var seconds = (event - now) / 1000;
		var minutes = seconds / 60;
		var hours = minutes / 60;
		var days = hours / 24;
								
		days = Math.floor(days);
		hours = Math.floor(hours - (days * 24)); 
		minutes = Math.floor(minutes - ((days * 1440) + (hours * 60)));
		seconds = Math.floor(seconds - (((days * 1440)*60) + ((hours * 60)*60) + (minutes * 60)));

		document.getElementById('countdown').innerHTML = days + " days " + hours + "h " + minutes + "m " + format(seconds) + "s";
		bob = window.setTimeout("updateCountdown('" + countdownDate + "')", 1000);
	}
}


function openURL(url, target, closewindow)	{
	if(!target)
		window.location = url;
	else
		window.open(url, target);
		
	if(closewindow)
		window.close(); 

	return false;
}

function openInParent(url, closewindow) {
	window.opener.location.href = url;
	
	if(closewindow)
		window.close(); 
		
	return false;
}
