// JavaScript Document

//FUNCTION LIBRARY
var funclib='../core/';

function empty(input){
	if(input==null || input==' ' || input==''){
		return true;
	}
	else{
		return false;
	}
}

function changeProv(whichProv){
	document.getElementById('please').style.display='none';
	if(whichProv==1){
		clearInterval();
		document.getElementById('paypal').style.display='none';
		document.getElementById('google').style.display='none';
		document.getElementById('please').style.display='block';
		document.getElementById('please').innerHTML='<img src="http://www.hostingmonster.co.uk/images/loading24.gif" alt="loading" />';
		setInterval(function (){
							  	document.getElementById('please').style.display='none';
								document.getElementById('paypal').style.display='none';
								document.getElementById('google').style.display='block';
								document.signup.provider.value='google';
							  }, 5000);
		clearInterval();
	}
	else if(whichProv==2){
		clearInterval();
		document.getElementById('paypal').style.display='none';
		document.getElementById('google').style.display='none';
		document.getElementById('please').style.display='block';
		document.getElementById('please').innerHTML='<img src="http://www.hostingmonster.co.uk/images/loading24.gif" alt="loading" />';
		setInterval(function (){
							  	document.getElementById('please').style.display='none';
								document.getElementById('google').style.display='none';
								document.getElementById('paypal').style.display='block';
								document.signup.provider.value='paypal';
							  },5000);
		clearInterval();
	}
}

function check(whichPack){
	if(whichPack=='year'){
		
		document.getElementById('sixmonths').checked='';
		document.getElementById('oneyear').checked='checked';
		document.getElementById('summary').style.display='block';
		document.getElementById('termhost').innerHTML='1 year ';
		document.getElementById('termcost').innerHTML='29.95';
		document.getElementById('total').innerHTML='29.95';
		document.signup.package.value='29.95';
	}
	else{
		document.getElementById('oneyear').checked='';
		document.getElementById('sixmonths').checked='checked';
		document.getElementById('summary').style.display='block';
		document.getElementById('termhost').innerHTML='6 months ';
		document.getElementById('termcost').innerHTML='19.99';
		document.getElementById('total').innerHTML='19.99';
		document.signup.package.value='19.99';
	}
}
function helpCenter(mainCat){
	if(empty(mainCat)){
		alert('There was an error expanding this catagory\n\n the page will refresh in a few seconds');
	}//if
	else{
		if(document.getElementById(mainCat).offsetHeight<5){
			$('#'+mainCat).slideDown('fast');
			var targetOffset = $('#'+mainCat).offset().top;
			$('html,body').animate({scrollTop: targetOffset-40}, 1000);
		}//if
		else{
			$('#'+mainCat).slideUp('fast');
		}//else
	}//else
}//function

var divid=Math.floor(Math.random()*100);
var scrh=window.screen.height;

function greyWindow(){
	parentdoc=document.getElementsByTagName('body')[0];
	////////////////////////////////////////////
	greyWindow=document.createElement('div');
	greyWindow.setAttribute('id','logwinbg');
	greyWindow.setAttribute('onclick','return closelogin();');
	////////////////////////////////////////////
	parentdoc.appendChild(greyWindow);
	////////////////////////////////////////////
	greyWindow.style.position='absolute';
	greyWindow.style.top=0+'px';
	greyWindow.style.left=0+'px';
	greyWindow.style.height=scrh+'px';
	greyWindow.style.width='100%';
	greyWindow.style.backgroundImage='url(http://www.hostingmonster.co.uk/images/greybg.png)';
	////////////////////////////////////////////
	mw=makeWindow();
	////////////////////////////////////////////
	document.getElementById('logwinbg').innerHTML=mw;
}//function

function makeWindow(){
	parentdiv=document.getElementsByTagName('body')[0];
	////////////////////////////////////////////
	newWindow=document.createElement('div');
	newWindow.setAttribute('id','logwin');
	////////////////////////////////////////////
	parentdiv.appendChild(newWindow);
	////////////////////////////////////////////
	newWindow.style.position='absolute';
	newWindow.style.top=(scrh/100*3)+'%';
	newWindow.style.left=(scrh/100*5)+'%';
	newWindow.style.padding='15px';
	////////////////////////////////////////////
	gc=logIn();
	////////////////////////////////////////////
	document.getElementById('logwin').innerHTML=gc;
}//function

function closelogin(id){
		document.getElementById('logwinbg').style.display='none';
		document.getElementById('logwin').style.display='none';
}

function logIn(){
	$.post(funclib,{action:'login', timestamp:divid},function(data){
		document.getElementById('logwin').innerHTML=data;
	});
}//function

$_GET = new Array
_get_set = function (_data){
	if(_data.match(/(.+?[^=])=(.*)/i)){
		eval("$_GET['" + RegExp.$1 + "'] = '" + RegExp.$2 + "';")
	}
}
_SearchIn  = location.href.replace(location.href.split('?')[0] + '?', '')
_Variables = _SearchIn.split('&')
if (_Variables.length < 2){
	_get_set(_SearchIn)
}
else{
	for(_s = 0; _s < _Variables.length; _s++){
		_get_set(_Variables[_s])
	}
}

var successEmail='<div class="greendiv">Your Password has been sent successfully</div>';
var failEmail='<div class="reddiv">There was an error sending your email please try again</div>';
var emailN='<div class="reddiv">We couldnt find the email address you provided in our database</div>';
var supportT='<div class="greendiv">Your ticket has been raised please allow up to 24 hours for a reply</div>';
var supportF='<div class="reddiv">Your Ticket was not raised please refresh and try again</div>';
var wrongUsername='<div class="reddiv">Your email address was not found!</div>';
var wrongPassword='<div class="reddiv">The password you supplied was incorrect</div>';


function doeverything(){
	$.post('../core/',$('#signup').serialize());
	document.getElementById('finalstep').display='block';
}