// JavaScript Document

var sMenu = 1;
var tMenu =1;
var tParent = null;
var currentPage = null;
var currentSMenu = null;
var currentSBG = null;
var currentSC = null;
var pageId = null;
var sectionId = null;
var pageType;
var promoInterval;
var Ypos = 0;
var	Xpos = 0;
var hoverClassName = 'briefImage';
function init(){
	//new Resizable('columnOne', {constraint:'horizontal', onResize:updateColOne});
	//new Resizable('header', {constraint:'vertical'});
	if($('secondul')){
		$('secondul').onmousedown = $('secondul').onselectstart = function(){return false;}
	}
	
	/*
	if($('promoLine')){
		loadPromoLine();
		promoInterval = setInterval(loadPromoLine, 5000);
	}
	*/
 
  
}



function userSearch(){
	var searchVal = $('searchInput').value;
	redirect('page.php?section=85&searchString='+searchVal);
}

function showTotalBrief(id){
	
	
	// <![CDATA[	
	showBriefSolution = 1;			
	var ajax;
	var d = new Date();
	var t = d.getTime();
	
	ajax =  new
	Ajax.Updater(
		 "solutionBriefText",        		// DIV id must be declared before the method was called
		 'ajax/tsBrief.php?t='+t+'&id='+id,{method:'get',asynchronous:true, onComplete:startBubbleFollow});

	// ]]>
	
}

function startBubbleFollow(){
	document.onmousemove=MouseFollow;
	fadein('solutionBrief');
	//MouseFollow(event);
	
}

function checkMouseOver(e){
	BrowserDetect.init();
	if(BrowserDetect.browser == 'Firefox' || BrowserDetect.browser == 'Safari' || BrowserDetect.browser == 'Chrome'){
		var eSrc = e.target;
		var trimmed = eSrc.className.replace(/^\s+|\s+$/g, '') ;
		hoverClassName = trimmed;
		
		
	}else{
		var eSrc = event.srcElement;
		var trimmed = eSrc.className.replace(/^\s+|\s+$/g, '') ;
		hoverClassName =trimmed;
		
	}
}

function MouseFollow(e){
	document.onmouseover = checkMouseOver; 
	
	if(hoverClassName == 'briefImage'){
		BrowserDetect.init();
		if(BrowserDetect.browser == 'Firefox' || BrowserDetect.browser == 'Safari' || BrowserDetect.browser == 'Chrome'){
			$('solutionBrief').style.top = (window.pageYOffset+e.clientY)-35+"px";
			$('solutionBrief').style.left = (window.pageXOffset+e.clientX)+20+"px";
		}else{
			$('solutionBrief').style.top = document.documentElement.scrollTop+event.clientY-35;
			$('solutionBrief').style.left = document.documentElement.scrollLeft+event.clientX+20;
		}
	}else{
		hideDivQuick('solutionBrief');		
	}
}

function hideTotalBrief(id){
	$('solutionBrief').style.display = 'none';
	// alertTimerId = setTimeout ( "hideDivQuick('solutionBrief')", 500 );	
	
}
function hideDivQuick(divId){
	 $(divId).style.display = 'none';	
}

function hideDiv(divId){
		
	new Effect.Fade(divId);
}

function displayTotalSolution(id){
	//$('solutionContent').style.display = 'none';	

	switch(id){
		case 55:
			document.location.href='page.php?section=118';
		break;
		case 57:
			document.location.href='page.php?section=118';
		break;
		case 58:
			document.location.href='page.php?section=118';
		break;
		case 59:
			document.location.href='page.php?section=118';
		break;
		case 60:
			document.location.href='page.php?section=118';
		break;
		case 61:
			document.location.href='page.php?section=118';
		break;
		case 56:
			document.location.href='page.php?section=117';
		break;
		
	}
	/*
	this is what we use to do but alas another change was made.
	// <![CDATA[	
	var ajax;
	var d = new Date();
	var t = d.getTime();
	
	ajax =  new
	Ajax.Updater(
		 "solutionContent",        		// DIV id must be declared before the method was called
		 'ajax/totalSolution.php?t='+t+'&id='+id,{method:'get',asynchronous:true, onComplete:showSolution});

	// ]]>
	*/
}

function showSolution(){
	new Effect.Appear('solutionContent');	
}

function fadein(divid){
	
	new Effect.Appear(divid, {duration:0.5, from:0.0, to:1.0});	
}


function loadPromoLine()
{
	
   
	
	$('promoLine').style.display = 'none';	
	// <![CDATA[	
	var ajax;
	var d = new Date();
	var t = d.getTime();
	
	ajax =  new
	Ajax.Updater(
		 "promoLine",        		// DIV id must be declared before the method was called
		 'ajax/promoLine.php?t='+t,{method:'get',asynchronous:true, onComplete:showPomoLine});

	// ]]>
	
}


function showPomoLine(){
	new Effect.Appear('promoLine');	
}


function displayVideo()
{

	// <![CDATA[	
	clearInterval(promoInterval);
	var ajax, ajax2;
	var d = new Date();
	var t = d.getTime();
	//$('promoLine').style.display = 'none';	
	$('homeBanner').style.display = 'none';
	$('leftTopCorner').style.display = 'block';
	$('leftBottomCorner').style.display = 'block';
	$('videoContainer').style.display = 'block';
	
	$('homeContentText').style.display='none';
	$('homeContent1_left').style.backgroundImage = 'none';
	
	
	
	ajax = new Ajax.Updater(
		 "homeContentText",        		// DIV id must be declared before the method was called
		 'ajax/displayVideoText.php?t='+t,{method:'get',asynchronous:true, onComplete:showVideoText});

	// ]]>
	
}


function showVideoText()
{
			
	new Effect.Appear('homeContentText');

}

function showVideo(){
		
}

function updateColOne(resizable, event){
	var delta = resizable.currentDelta();
	$('columnTwo').style.width = (970 - delta[0]-55)+"px";
	$('columnOne').innerHTML = delta[0];
}

function redirect(url){
	document.location.href=url;	
}


function openWindow(url){
	myRef = window.open(url,'mywin',
'left=0,top=0,width=1024,height=600,toolbar=0,resizable=1,scrollbars=1');

}
function primaryMenu(id)
{
	// <![CDATA[	
	alert('test');
	var ajax;
	var d = new Date();
	var t = d.getTime();
	
	ajax =  new Ajax.Updater(
		 "pageContent",        		// DIV id must be declared before the method was called
		 'ajax/pageContent.php?id='+id+'&t='+t,{method:'get',asynchronous:true, onSuccess:showPage});

	// ]]>
}



function setMenuOn(){
	sMenu = 1;	
}

function setTMenuOn(){
	tMenu = 1;	
}
 
function rollover(divId){
	//$('header').innerHTML = divId +':'+tParent;
	
	if($(divId).className != 'on'){
		$(divId).style.backgroundColor = '#d1d1d1';
		$(divId).style.color = '#3F78A1';
	}
	
}
function rollout(divId){
	if($(divId).className != 'on'){
		$(divId).style.backgroundColor = '#f8f8f8';
		$(divId).style.color = '#333';
	}
	parentId = null;
}

function rollover2(divId, parentId){
	tParent = parentId;
	if(divId != currentSMenu){
		
		$(divId).style.backgroundColor = '#d1d1d1';
		$(divId).style.color = '#FFF';
	}
}
function rollout2(divId){
	
	tParent = null;
	if(currentSMenu != divId){
		$(divId).style.backgroundColor = '#FFFFFF';
		$(divId).style.color = '#5b5b5b';
	}
}

function closeSubMenu(pId){
	
	if($('tert_'+pId).style.display == ''){
		
		new Effect.BlindUp('tert_'+pId);
	}
	
}

function secondaryMenu(pId, sId, obj){	
	// <![CDATA[
	currentSMenu = sId;			
	document.location.href='page.php?section='+sId;			
	pageId = pId;
	sectionId = sId;
	
	if($('tert_'+pId)){	
		if($('tert_'+pId).style.display == 'none'){	
			
			new Effect.Appear('tert_'+pId);
			new Effect.Fade('arrow_'+pId);
		}
	}
	setTimeout ( "setMenuOn()",500);
	
	
	
	if(sMenu == 1){
		if(currentSMenu != null){
			$(currentSMenu).morph("background-color:"+currentSBG+";color:"+currentSC+";");
		}
		currentSMenu = 'secondLi_'+pId;
		currentSBG = "#f8f8f8";
		currentSC = "#333";
		$('secondLi_'+pId).morph("background-color:#ababab;color:#FFF;");	
		
		var ajax;
		var d = new Date();
		var t = d.getTime();
		
		ajax =  new Ajax.Updater(
			 "pageContent",        		// DIV id must be declared before the method was called
			 'ajax/pageContent.php?pId='+pId+'&sId='+sId+'&t='+t,{method:'get',asynchronous:true, onSuccess:showPage, onFailure:showError});
	
		sMenu = 0;	
	}
	// ]]>
}

function tertiaryMenu(pId, sId, obj){	
	// <![CDATA[
	document.location.href='page.php?section='+sId;				
	pageId = pId;
	sectionId = sId;
	
	if($('tert_'+pId)){			
		new Effect.Appear('tert_'+pId);
	}
	setTimeout ( "setMenuOn()",1000);
	
	
	if(sMenu == 1){
		if(currentSMenu != null){
			$(currentSMenu).morph("background-color:"+currentSBG+";color:"+currentSC+";");
		}
		currentSMenu = 'secondLi_'+pId;
		currentSBG = "#FFFFFF";
		currentSC = "#5b5b5b";
		$('secondLi_'+pId).morph("background-color:#ababab;color:#FFF;");
		
		var ajax;
		var d = new Date();
		var t = d.getTime();
		
		ajax =  new Ajax.Updater(
			 "pageContent",        		// DIV id must be declared before the method was called
			 'ajax/pageContent.php?pId='+pId+'&sId='+sId+'&t='+t,{method:'get',asynchronous:true, onSuccess:showPage, onFailure:showError});
	
		sMenu = 0;	
	}
	// ]]>
}

function showError(req){
	$('pageContent').innerHTML = req.responseText+"<br />Please try again";
}

function showPage(){

	if($('pageContent')){
		
	//	new Effect.Appear('pageContent');	
	}
	
}

function showJournal(id){
	$('journal_'+id).morph("height:100%");
	
}
function divOn(div)
{	
	document.getElementById(div).style.display = 'block';	
}

function getAddress(postcode, divId){
	// <![CDATA[
		if((postcode.length >= 2 && postcode.length <= 8) && IsAlphaNumeric(postcode)){
			
			new Effect.Appear('saRow');	
			
			
			new Effect.Appear('addressDisplay');
			$('addressDisplay').innerHTML = ' <img src="images/loader.gif" /> <span style="background:transparent;">loading...</span>';
			/*
			if($('mainError') != null){	 
				new Effect.Fade('mainError');
			}
			
			if($('selectedAddress') != null){	 
				new Effect.Fade('selectedAddress');
			}
		*/
			var ajax;
			var d = new Date();
			var t = d.getTime();
			
			ajax =  new Ajax.Updater(
				 divId,        		// DIV id must be declared before the method was called
				 'ajax/getAddress.php?postcode='+postcode+'&divId=selectedAddress&t='+t,{method:'get',asynchronous:true, onSuccess:maybeShow});
		}else{
			alert('The postcode must be alpha-numeric and between 2 and 8 characters.');	
		}
		
		
	// ]]>
}


function maybeShow(req){
	var resp = req.responseText; 
	
	if(resp.indexOf('<span>') >= 0){
		addr = resp.substring((resp.indexOf('value="')+7),resp.indexOf('">',resp.indexOf('value="') ) ); 
		
		//new Effect.Appear('finalAddress');	
		//showFinalAddress(addr);
	}
	$('address').focus();
	$('address').select();
	
}
	
function showFinalAddress(address, divId){
	// <![CDATA[
		//new Effect.Appear('addieTimeRow');		
		//if($('addieTime0').checked == true){
			//checkapply2($('page1'));
		//}
		
		new Effect.Appear('address1');
		new Effect.Appear('selectedAddress');
		
		
		var ajax;
		var d = new Date();
		var t = d.getTime();
		
		ajax =  new Ajax.Updater(
			 divId,        		// DIV id must be declared before the method was called
			 'ajax/displayAddress.php?address='+address+"&t="+t,{method:'get',asynchronous:true});
		/*if(effects){	
		 new Effect.toggle('hide_'+divId);
		}*/
	 
	// ]]>
}	
	
function IsNumeric(strString){
  //  check for valid numeric strings	

   var strValidChars = "0123456789.";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
	  {
	  strChar = strString.charAt(i);
	  if (strValidChars.indexOf(strChar) == -1)
		 {
		 blnResult = false;
		 }
	  }
   return blnResult;
}

function IsAlphaNumeric(strString){
  //  check for valid numeric strings	

   var strValidChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
	  {
	  strChar = strString.charAt(i);
	  if (strValidChars.indexOf(strChar) == -1)
		 {
		 blnResult = false;
		 }
	  }
   return blnResult;
}

function updateEmail(val, id){
		var ajax;
		var d = new Date();
		var t = d.getTime();	
		new Ajax.Request('ajax/checkEmail.php?address='+val+'&t='+t, {method: 'get', asynchronous:'true',
		  onSuccess: function(transport) {
			  	
				if (transport.responseText =="false"){
					alert('This email address is invalid.');
				}else{
					new Ajax.Request('ajax/updateEmail.php?email='+val+'&id='+id+'&t='+t, {method: 'get', asynchronous:'true', onSuccess: function(transport){
																																				   	
						if (transport.responseText !=""){
							$('emailCheckYes').checked = true;
							$('validateEmail').value = transport.responseText;
							$('previewEmail').innerHTML = "<b>"+transport.responseText+"</b>";
							hideEmailValidate();
						}else{
							alert('This process was not completed, please try again.');	
						}
				  }, onFailure: function(transport) {
					  alert("error".transport.responseText);
						
				  }
				});
			 }
		  }
		});
				
		
	}
	
	
	function hideEmailValidate(){
		$('validateEmail').style.display = 'none';
		$('euer').style.display = 'none';
		new Effect.Appear('previewEmail')
	}
	
	function showEmailValidate(){
		new Effect.Appear('euer');
		new Effect.Appear('validateEmail');
		$('previewEmail').style.display = 'none';
	}
	
	function compileStartDate(){
		alert($('start_month').value+''+$('start_year').value);
		$('StartDate').value = $('start_month').value+''+$('start_year').value;	
	}	
	
	function compileExpiryDate(){
		$('ExpiryDate').value = $('expiry_month').value+''+$('expiry_year').value;	
	}

	function compileStartDateWed(){
		$('StartDate').value = $('start_month').options[$('start_month').selectedIndex].value+''+$('start_year').options[$('start_year').selectedIndex].value;
		
	}	
	
	function compileExpiryDateWed(){
		$('ExpiryDate').value = $('expiry_month').options[$('expiry_month').selectedIndex].value+''+$('expiry_year').options[$('expiry_year').selectedIndex].value;
			
	}	
	
	function removeSpaces(text){
		var tstring = "";	
		splitstring = text.split(" ");
		for(i = 0; i < splitstring.length; i++)	{
			tstring += splitstring[i];
		}
		return tstring;
	}
	
	function checkapplycc(theform){
	// <![CDATA[
					
		fields = "";
		valid = true;
		
		if(theform.introFriend.value == 1 && theform.Amount.value<10){
			fields += "You must enter at least £10.\n";
			$('loadAmountRow').style.backgroundColor = "#FED9D9";
			$('loadAmountRow').style.backgroundImage = "none";
			valid = false;	
		}
		if(theform.cardCost_temp.value == 0 && theform.Amount.value<10){
			fields += "You must enter at least £10.\n";
			$('loadAmountRow').style.backgroundColor = "#FED9D9";
			$('loadAmountRow').style.backgroundImage = "none";
			valid = false;	
		}
		
		if(theform.Amount.value == ""){
			fields += "You must enter a Load Amount.\n";
			$('loadAmountRow').style.backgroundColor = "#FED9D9";
			$('loadAmountRow').style.backgroundImage = "none";
			valid = false;
		}
		
		
		
		if(theform.cardHolderName.value == ""){
			fields += "You must enter a Card Holder Name.\n";
			$('cardHolderRow').style.backgroundColor = "#FED9D9";
			$('cardHolderRow').style.backgroundImage = "none";
			valid = false;
		}
		if(theform.CardType.value == ""){
			fields += "You must enter a Card Type.\n";
			$('cardTypeRow').style.backgroundColor = "#FED9D9";
			$('cardTypeRow').style.backgroundImage = "none";
			valid = false;
		}
		if(theform.expiry_month.value == ""){
			fields += "You must enter an Expiry Month.\n";
			$('expiryDateRow').style.backgroundColor = "#FED9D9";
			$('expiryDateRow').style.backgroundImage = "none";
			valid = false;
		}
		
		if(theform.expiry_year.value == ""){
			fields += "You must enter an Expiry Year.\n";
			$('expiryDateRow').style.backgroundColor = "#FED9D9";
			$('expiryDateRow').style.backgroundImage = "none";
			valid = false;
		}
		
		if(theform.securityCode.value == ""){
			fields += "You must enter a Security Code.\n";
			$('securityCodeRow').style.backgroundColor = "#FED9D9";
			$('securityCodeRow').style.backgroundImage = "none";
			valid = false;
		}
		
		if (IsNumeric(theform.Amount.value) == false){
			fields += "The load amount must only contain numeric characters.\n";
			$('loadAmountRow').style.backgroundColor = "#FED9D9";
			$('loadAmountRow').style.backgroundImage = "none";
			valid = false;
		}
		
	
		
		if (IsNumeric(theform.CardNumber.value) == false){
			fields += "The card number must only contain numeric characters.\n";
			$('cardNumberRow').style.backgroundColor = "#FED9D9";
			$('cardNumberRow').style.backgroundImage = "none";
			valid = false;
		}
		if(theform.CardNumber.value.length > 20){
			fields += "The card number must only be 20 characters or less.\n";
			$('cardNumberRow').style.backgroundColor = "#FED9D9";
			$('cardNumberRow').style.backgroundImage = "none";
			valid = false;	
		}
		
		
		
		if(valid == false){
			message = "Please address the highlighted fields\n";
			message += "--------------------------------------------------\n";
			message += fields;
			alert(message);
			return(false);
		}
		
		// ]]>
	}
	
	function checkcc(theform){
	// <![CDATA[
					
		fields = "";
		valid = true;
		if(loadAmountErrors == 1){
			fields += loadAmountMessage+'\n';
			$('loadAmountRow').style.backgroundColor = "#FED9D9";
			$('loadAmountRow').style.backgroundImage = "none";
			valid = false;
		}
		if(theform.Amount.value == ""){
			fields += "You must enter a Load Amount.\n";
			$('loadAmountRow').style.backgroundColor = "#FED9D9";
			$('loadAmountRow').style.backgroundImage = "none";
			valid = false;
		}
		
		
		
		if(theform.cardHolderName.value == ""){
			fields += "You must enter a Card Holder Name.\n";
			$('cardHolderRow').style.backgroundColor = "#FED9D9";
			$('cardHolderRow').style.backgroundImage = "none";
			valid = false;
		}
		if(theform.CardType.value == ""){
			fields += "You must enter a Card Type.\n";
			$('cardTypeRow').style.backgroundColor = "#FED9D9";
			$('cardTypeRow').style.backgroundImage = "none";
			valid = false;
		}
		if(theform.expiry_month.value == ""){
			fields += "You must enter an Expiry Month.\n";
			$('expiryDateRow').style.backgroundColor = "#FED9D9";
			$('expiryDateRow').style.backgroundImage = "none";
			valid = false;
		}
		
		if(theform.expiry_year.value == ""){
			fields += "You must enter an Expiry Year.\n";
			$('expiryDateRow').style.backgroundColor = "#FED9D9";
			$('expiryDateRow').style.backgroundImage = "none";
			valid = false;
		}
		
		if(theform.securityCode.value == ""){
			fields += "You must enter a Security Code.\n";
			$('securityCodeRow').style.backgroundColor = "#FED9D9";
			$('securityCodeRow').style.backgroundImage = "none";
			valid = false;
		}
		
		if (IsNumeric(theform.Amount.value) == false){
			fields += "The load amount must only contain numeric characters.\n";
			$('loadAmountRow').style.backgroundColor = "#FED9D9";
			$('loadAmountRow').style.backgroundImage = "none";
			valid = false;
		}
		
		
		
		
		if (IsNumeric(theform.CardNumber.value) == false){
			fields += "The card number must only contain numeric characters.\n";
			$('cardNumberRow').style.backgroundColor = "#FED9D9";
			$('cardNumberRow').style.backgroundImage = "none";
			valid = false;
		}
		if(theform.CardNumber.value.length > 20){
			fields += "The card number must only be 20 characters or less.\n";
			$('cardNumberRow').style.backgroundColor = "#FED9D9";
			$('cardNumberRow').style.backgroundImage = "none";
			valid = false;	
		}
		
		
		
		if(valid == false){
			message = "Please address the highlighted fields\n";
			message += "--------------------------------------------------\n";
			message += fields;
			alert(message);
			return(false);
		}else{
			theform.action = 'application_topup.php';
			theform.submit();
		}
		return(false);
		// ]]>
	}	
	
function checkAddie1(){
	
	if(checkapply1($('page1'))){
		if($('address').value != ""){ 
			checkapply2($('page1'));
		}else{
			alert('Please select an address');	
		}
	}
	return(false);
}



function showPrevious()
	{
		new Effect.toggle('postcodeRow2');		
		
		new Effect.toggle('saRow2');	
		
	}
	
function restoreRowBg(rowId){
	
	$(rowId).style.background = "none";
}	

function IsAlpha(strString){
  //  check for valid numeric strings	

   var strValidChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";

  if (strValidChars.indexOf(strString) == -1){
		return false;
  }else{
		return true;	  
  }
	  
}

function IsNumber(strString){
  //  check for valid numeric strings	

   var strValidChars = "0123456789";

  if (strValidChars.indexOf(strString) == -1){
		return false;
  }else{
		return true;	  
  }
	  
}
	
	
function checkPass(password)
{
	
	var bits = "";	
	var containsNumber = false;
	var containsAlpha = false;
	if(password != ""){
		for(i=0;i<password.length;i++){
		
			if(IsNumber(password.charAt(i)) == true){
				
				containsNumber = true;
			}
			if(IsAlpha(password.charAt(i)) == true){
				
				containsAlpha = true;
			}
		}
		
		if(password != $('username').value){
			if(password.length < 6 || containsAlpha == false || containsNumber == false){
				alert("Your password does not meet the criteria, please try again.");	
			}
		}else{
			alert('You can not use your username as your password.');	
		}
	}
	
}


function checkusername(theform){
	// <![CDATA[
		
	var d = new Date();
	var t = d.getTime(); 
	
	fields = "";
	valid = true;

	if(theform.username.value == ""){
		fields += "You must enter a username.\n";
		$('usernameRow').style.backgroundColor = "#cef1ff";
		$('usernameRow').style.backgroundImage = "none";
		valid = false;
	}
	if(theform.password.value == ""){
		fields += "You must enter a password.\n";
		$('passwordRow').style.backgroundColor = "#cef1ff";
		$('passwordRow').style.backgroundImage = "none";
		valid = false;
	}
	if(theform.confirmpassword.value == ""){
		fields += "You must enter a confirmation password.\n";
		$('confirmpasswordRow').style.backgroundColor = "#cef1ff";
		$('confirmpasswordRow').style.backgroundImage = "none";
		valid = false;
	}
	
	if(theform.securityquestion.value == ""){
		fields += "You must select a security question.\n";
		$('securityQuestionRow').style.backgroundColor = "#cef1ff";
		$('securityQuestionRow').style.backgroundImage = "none";
		valid = false;
	}
	if(theform.securityanswer.value == ""){
		fields += "You must enter a security answer.\n";
		$('securityAnswerRow').style.backgroundColor = "#cef1ff";
		$('securityAnswerRow').style.backgroundImage = "none";
		//Effect.Pulsate('titleRow');
		valid = false;
	}
	if(theform.confirmpassword.value != theform.password.value){
		fields += "You're confirmation password does not match your password.\n";
		$('confirmpasswordRow').style.backgroundColor = "#cef1ff";
		$('confirmpasswordRow').style.backgroundImage = "none";
		valid = false;
	}
	
	
	if(valid == false){
		message = "Please address the highlighted fields\n";
		message += "--------------------------------------------------\n";
		message += fields;
		alert(message);
		return(false);
	}else{
		new Ajax.Request('ajax/checkUsername.php?username='+theform.username.value+'&date='+t, {method: 'get', asynchronous:'true',
			  onSuccess: function(transport) {
					var valErrror = $('usernameError');
					if (transport.responseText > 0){
						new Effect.Appear('usernameError');
						valErrror.update('<span style=\"color:#ff0000;font-weight:bold;\">This username has already been used, please try something else.</span>');
						
					}else{
						theform.submit();
					}
			  }
		});
	}
	
 return(false);
	// ]]>
}
	
function checkUsernameExists(username){
			// <![CDATA[
			
			var d = new Date();
			var t = d.getTime(); 
			
			new Ajax.Request('ajax/checkUsername.php?username='+username+'&date='+t, {method: 'get', asynchronous:'true',
				  onSuccess: function(transport) {
						var valErrror = $('usernameError');
						if (transport.responseText > 0){
							new Effect.Appear('usernameError');
							valErrror.update('<span style=\"color:#ff0000;font-weight:bold;\">This username has already been used, please try something else.</span>');
						}else{
							new Effect.Fade('usernameError');
						}
				  }
			});
			// ]]>
	}
	
	
function checkapply1(theform){
		// <![CDATA[
		fields = "";
		valid = true;
		
		
		
		if(theform.title.value == ""){
			fields += "You must enter your title.\n";
			$('titleRow').style.backgroundColor = "#cef1ff";
			$('titleRow').style.backgroundImage = "none";
			//Effect.Pulsate('titleRow');
			valid = false;
		}
		
		if(theform.firstname.value.length < 2){
			fields += "You must enter a valid first name.\n";
			$('firstnameRow').style.backgroundColor = "#cef1ff";
			$('firstnameRow').style.backgroundImage = "none";
			valid = false;
		}
		
		if(theform.firstname.value == ""){
			$('firstnameRow').style.backgroundColor = "#cef1ff";
			$('firstnameRow').style.backgroundImage = "none";
			//Effect.Pulsate('firstnameRow');
			fields += "You must enter your first name.\n";
			valid = false;
		}
		
		if(theform.surname.value.length < 2){
			fields += "You must enter a valid surname.\n";
			$('surnameRow').style.backgroundColor = "#cef1ff";	
			$('surnameRow').style.backgroundImage = "none";
			
			valid = false;
		}
		
		if(theform.surname.value == ""){
			$('surnameRow').style.backgroundColor = "#cef1ff";	
			$('surnameRow').style.backgroundImage = "none";
			fields += "You must enter your surname.\n";
			valid = false;
		}
		if(theform.email.value == ""){
			$('emailRow').style.backgroundColor = "#cef1ff";
			$('emailRow').style.backgroundImage = "none";
			//Effect.Pulsate('emailRow');
			fields += "You must provide us with an email address.\n";
			valid = false;
		}
		if(theform.email.value.indexOf("@") == -1 || theform.email.value.indexOf(".") == -1){
			$('emailRow').style.backgroundColor = "#cef1ff";	
			$('emailRow').style.backgroundImage = "none";
			//Effect.Pulsate('emailRow');
			fields += "You must provide us with a valid email address.\n";
			valid = false;
		}
		
		if(theform.gender.value == "Unspecified"){
			$('genderRow').style.backgroundColor = "#cef1ff";
			$('genderRow').style.backgroundImage = "none";
			//Effect.Pulsate('emailRow');
			fields += "You must select a gender.\n";
			valid = false;	
		}
		/*if(theform.confirmEmail.value != theform.email.value){
			$('confirmEmailRow').style.backgroundColor = "#cef1ff";
			$('confirmEmailRow').style.backgroundImage = "none";
			//Effect.Pulsate('confirmEmailRow');
			fields += "The confirmation email address must match the email address.\n";
			valid = false;
		}*/
		
		if(theform.mobilePhone.value.length != 11 || theform.mobilePhone.value.charAt(0) != 0){
			$('mobilePhoneRow').style.backgroundColor = "#cef1ff";
			$('mobilePhoneRow').style.backgroundImage = "none";
			//Effect.Pulsate('homePhoneRow');
			fields += "You must enter a valid mobile phone number.\n";
			valid = false;
		}
		
		if(theform.mobilePhone.value == ""){
			$('mobilePhoneRow').style.backgroundColor = "#cef1ff";
			$('mobilePhoneRow').style.backgroundImage = "none";
			//Effect.Pulsate('homePhoneRow');
			fields += "You must enter your mobile phone number.\n";
			valid = false;
		}
		if(theform.homePhone.value == ""){
			$('homePhoneRow').style.backgroundColor = "#cef1ff";
			$('homePhoneRow').style.backgroundImage = "none";
			//Effect.Pulsate('homePhoneRow');
			fields += "You must enter your home phone number.\n";
			valid = false;
		}
		
		if((theform.homePhone.value.length < 9 || theform.homePhone.value.length > 15) || theform.homePhone.value.charAt(0) != 0){
			$('homePhoneRow').style.backgroundColor = "#cef1ff";
			$('homePhoneRow').style.backgroundImage = "none";
			//Effect.Pulsate('homePhoneRow');
			fields += "You must enter a valid home phone number.\n";
			valid = false;
		}
		
		if(theform.source.value == ""){
			$('sourceRow').style.backgroundImage = "none";
			$('sourceRow').style.backgroundColor = "#cef1ff";
			//Effect.Pulsate('sourceRow');
			fields += "You must select a source from where you heard about the card.\n";
			valid = false;
		}
		if(theform.postcode.value == ""){
			$('postcodeRow').style.backgroundImage = "none";
			$('postcodeRow').style.backgroundColor = "#cef1ff";
			//Effect.Pulsate('sourceRow');
			fields += "You must enter a postcode.\n";
			valid = false;
		}
		if(theform.source.value == "other" && theform.other.value == ""){
			$('sourceRow').style.backgroundImage = "none";
			$('sourceRow').style.backgroundColor = "#cef1ff";
			//Effect.Pulsate('sourceRow');
			fields += "You must enter where you heard about the card.\n";
			valid = false;
		}
		if(theform.dob_day.value == "" || theform.dob_month.value == "" || theform.dob_year.value == ""){
			$('dobRow').style.backgroundImage = "none";
			$('dobRow').style.backgroundColor = "#cef1ff";
			fields += "You must enter a valid date of birth.\n";
			valid = false;
		}
		var year = parseInt(theform.dob_year.value);
		var month = parseInt(theform.dob_month.value) - 1;
		var day = parseInt(theform.dob_day.value);
		var min_age = 18;
		var theirDate = new Date((year + min_age), month, day);
		var today = new Date;

		if ( (today.getTime() - theirDate.getTime()) < 0) {
			fields += "You are too young to apply for this card.\n";
			$('dobRow').style.backgroundImage = "none";
			$('dobRow').style.backgroundColor = "#cef1ff";
			valid = false;
		}
		var terms = false;
		
		if(!theform.acceptRisk.checked){
			$('acceptRiskRow').style.backgroundColor = "#cef1ff";
			$('acceptRiskRow').style.backgroundImage = "none";
			//Effect.Pulsate('termsRow');
			terms = true;
			fields += "You must agree to the terms and conditions.\n";
			valid = false;	
		}	
		
		if(!theform.terms.checked){
			$('termsRow').style.backgroundColor = "#cef1ff";
			$('termsRow').style.backgroundImage = "none";
			if(terms == false){
				fields += "You must agree to the terms and conditions.\n";
			}
			valid = false;	
		}	
		if(valid == false){
			message = "Please address the highlighted fields\n";
			message += "--------------------------------------------------\n";
			message += fields;
			alert(message);
			return(false);
		}
		return(true);
	}
	
	
function checkapply2(theform){
	// <![CDATA[
	 
	 
	var ajax, ajax2;
	var d = new Date();
	var t = d.getTime(); 
	var validation = "false";
	new Effect.Appear('validationError');
	var title = theform.title.value;
	var firstname = theform.firstname.value;
	var surname = theform.surname.value;
	var initial = theform.initial.value;
	var gender = theform.gender.value;
	var email = theform.email.value;
	var homePhone = theform.homePhone.value;
	var mobilePhone = theform.mobilePhone.value;
	var dob_day = theform.dob_day.value;
	var dob_month = theform.dob_month.value;
	var dob_year = theform.dob_year.value;
	var source = theform.source.value;
	var postcode = theform.postcode.value;
	
	var address = theform.address.value;
	
	new Effect.Appear('validationError');
		
	if(theform.address){ 
		
		new Ajax.Request('ajax/URUcheck2.php'+'?date='+t,{
		  method: 'post',evalScripts: true, asynchronous:'true',parameters: { title: title ,firstname: firstname,surname:surname ,initial:initial ,gender:gender, email:email,homePhone:homePhone, mobilePhone:mobilePhone, dob_day:dob_day, dob_month:dob_month, dob_year:dob_year, source:source, postcode:postcode,address:address  },
	  onSuccess: function(transport) {
		var valErrror = $('validationError');
		alert(transport.responseText);
		if (transport.responseText < 1001){
			//document.location.href='apply2.php?error=points';	
		}else if(transport.responseText >= 1001 && transport.responseText <= 1109){
		  $('continueHolder').innerHTML = "<input type=\"submit\" name=\"submitter\" class=\"input\" value=\"Continue\" />";
		  new Effect.Appear('drivingLicenseRow');	
		  new Effect.Appear('passport1Row');	
		  new Effect.Appear('passport2Row');	
		  validation = "false";		
		  valErrror.update('<span style=\"color:#ff0000;font-weight:bold;\">Your details do not provide us with enough information, please provide either your Drivers license or Passport number. ');
		}else{
			
		  validation = "true";
		  valErrror.update('<span style=\"color:#0A8326;font-weight:bold;\">Your details have been confirmed, please wait.......</span>');
		 // theform.submit();
		 // document.location.href='page.php?section=3';
		}
	  }
	});
	}else{
		//document.location.href='apply2.php?error=points';
	}
	// ]]>
	return false;
}


function checkContactForm(theform)
{
	// <![CDATA[
	fields = "";
	valid = true;

	if(theform.firstname.value == ""){
		fields += "You must enter a First name.\n";
		theform.firstname.className='inputError';
		valid = false;
	}
	if(theform.surname.value == ""){
		fields += "You must enter a Surname.\n";
		theform.surname.className='inputError';
		valid = false;
	}
	
	if(theform.email.value == ""){
		fields += "You must enter an Email Address.\n";
		theform.email.className='inputError';
		valid = false;
	}
	
	if(theform.postcode.value == ""){
		fields += "You must enter a Postcode.\n";
		theform.postcode.className='inputError';
		valid = false;
	}
	
	if(theform.enquiry.value == ""){
		fields += "You must enter an Enquiry.\n";
		theform.enquiry.className='inputError';
		valid = false;
	}

	
	
	if(valid == false){
		new Effect.Appear('formError');
		return(false);
	}else{
		var d = new Date();
		var t = d.getTime(); 
		var crypticVal = theform.cryptic.value.toUpperCase();	
		
		var result = new Ajax.Request('ajax/checkCrypt.php?cryptic='+crypticVal+'&date='+t, {method: 'get', asynchronous:'true',
		  onSuccess: function(transport) {
				
				if (transport.responseText == "false"){
					alert("You must enter the correct security code");
					secureCheck = "false";
					
				}else{
					document.getElementById('contactor').submit();
				}
		  }
		});
		
		return(false);	
	}
		
	// ]]>
}


function refreshCryptImage(){
		var randomnumber=Math.floor(Math.random()*11);
		document.images['cryptImage'].src = 'includes/crypt.php?t='+randomnumber;	
	}




var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};

function load(userId) {
	 
	 getNotes(userId,0);
	 
      if (GBrowserIsCompatible()) {
          var map = new GMap2(document.getElementById("map"));

     	  map.addControl(new GMapTypeControl()); 
          map.setCenter(new GLatLng(49.4,5.4), 2); 
	 	  map.removeMapType(G_NORMAL_MAP);
		  map.removeMapType(G_HYBRID_MAP);
		  map.removeMapType(G_SATELLITE_MAP);
		  map.setMapType(G_NORMAL_MAP);
		  map.disableDoubleClickZoom();
		  
		  TextualZoomControl.prototype = new GControl();
		  
		  TextualZoomControl.prototype.initialize = function(map) {
		  var container = document.createElement("div");
		
		  var zoomInDiv = document.createElement("div");
		  this.setButtonStyle_(zoomInDiv);
		  container.appendChild(zoomInDiv);
		  zoomInDiv.appendChild(document.createTextNode("+"));
		  GEvent.addDomListener(zoomInDiv, "click", function() {
		  
		  map.zoomIn();
		  });
		
		  var zoomOutDiv = document.createElement("div");
		  this.setButtonStyle_(zoomOutDiv);
		  container.appendChild(zoomOutDiv);
		  zoomOutDiv.appendChild(document.createTextNode("-"));
		  GEvent.addDomListener(zoomOutDiv, "click", function() {
		  if(map.getZoom() > 2){
		  map.zoomOut();  
		  }
		  
		  });
		
		  map.getContainer().appendChild(container);
		  return container;
		}
		
		// By default, the control will appear in the top left corner of the
		// map with 7 pixels of padding.
		TextualZoomControl.prototype.getDefaultPosition = function() {
		  return new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(7, 7));
		}
		
		// Sets the proper CSS for the given button element.
		TextualZoomControl.prototype.setButtonStyle_ = function(button) {
		 // button.style.textDecoration = "";
		  button.style.color = "#62C4DB";
		  button.style.backgroundColor = "white";
		  button.style.border = "1px solid #62C4DB";
		  button.style.padding = "";
		  button.style.marginBottom = "2px";
		  button.style.paddingBottom = "3px";
		  button.style.textAlign = "center";
		  button.style.width = "1.4em";
		  button.style.cursor = "pointer";
		  button.style.fontSize = "15pt";
		}
	 
	 	GEvent.addListener(map, "move", function() {
        var allowedBounds = new GLatLngBounds(new GLatLng(48,-9), new GLatLng(65,20));
        // Perform the check and return if OK
        if (allowedBounds.contains(map.getCenter())) {
          return;
        }
        // It`s not OK, so find the nearest allowed point and move there
        var C = map.getCenter();
        var X = C.lng();
        var Y = C.lat();
 
        var AmaxX = allowedBounds.getNorthEast().lng();
        var AmaxY = allowedBounds.getNorthEast().lat();
        var AminX = allowedBounds.getSouthWest().lng();
        var AminY = allowedBounds.getSouthWest().lat();
 
        if (X < AminX) {X = AminX;}
        if (X > AmaxX) {X = AmaxX;}
        if (Y < AminY) {Y = AminY;}
        if (Y > AmaxY) {Y = AmaxY;}
        //alert ("Restricting "+Y+" "+X);
        map.setCenter(new GLatLng(Y,X));
        });
	 
		 var new_icon = new GIcon()  
		 new_icon.image = "images/pin.gif"  
		 new_icon.size = new GSize(16,16)  
		 new_icon.iconAnchor = new GPoint(8,9)  
		 new_icon.infoWindowAnchor = new GPoint(7,7)  
		 var opt  
		 opt = {}  
		 opt.icon = new_icon  
		 opt.draggable = false  
		 opt.clickable = true  
		 opt.dragCrossMove = true 

		 var result = new Ajax.Request('ajax/getPoints.php', {method: 'post',parameters: {userId:userId, type:"getPoints"}, asynchronous:'true',
		 onSuccess: function(transport) {
			  
			 data = transport.responseText;
			 
			 var brokenstring = data.split("|");
			
			 for (var i=0;i< brokenstring.length-1 ;i++)	{
					
					var newbrokenstring = brokenstring[i].split("&");
					var lonlat = newbrokenstring[0].split(",");
					var oldMarker = new GMarker(new GLatLng(lonlat[0],lonlat[1]), opt); 
					
					GEvent.addListener(oldMarker, "mouseover", function(point) {
					
					 var result = new Ajax.Request('ajax/getPoints.php', {method: 'post',parameters: {userId:userId, coords:"|"+point+"|"}, asynchronous:'true',
					 onSuccess: function(transport) {
					 new Effect.Appear('spotsDescription');
					 document.getElementById('spotsDescription').innerHTML = transport.responseText;;
					 }
												 
					});
					
					
					});
					
					GEvent.addListener(oldMarker, 'dblclick', function(point,i){
				 	if (confirm("Are you sure you want to delete this location?")) {//if yes
				 	var longLat = "|"+point+"|";
				 	var d = new Date();
					var t = d.getTime();
					//alert(point); 
					var result = new Ajax.Request('ajax/deleteMarker.php', {method: 'post',parameters: {userId:userId, coords:longLat}, asynchronous:'true',
					 onSuccess: function(transport) {
						location.reload(true)
					 //map.removeOverlay(oldMarker);
						}
					});	
					}
								 });
					
					
			map.addOverlay(oldMarker);	
			  }
			

		  }
	   	 });
			  
   		 GEvent.addListener(map, 'dblclick', function(overlay,point){
		
		 var newMarker = new GMarker(point, opt);
		
		// var note = prompt("Do you want to write anything?", "e.g. Barcelona was beautiful in July");
		 var note = confirm("Do you want to place a marker here?");
			// if(note != null){
				if(note != false){
				 addNote(userId, point, note);
				 
				 GEvent.addListener(newMarker, "mouseover", function() {
				 document.getElementById('spotsDescription').innerHTML = note;
				 new Effect.Appear('spotsDescription');
				 });
				 
				 GEvent.addListener(newMarker, 'dblclick', function(point){
			     if (confirm("Are you sure you want to delete this location?")) {//if yes

				 
				 
				 	var coords = "|"+point+"|";
				 	var d = new Date();
					var t = d.getTime(); 
					var result = new Ajax.Request('ajax/deleteMarker.php', {method: 'post',parameters: {userId:userId, coords:coords}, asynchronous:'true',
					  onSuccess: function(transport) {
						 map.removeOverlay(newMarker);
						}
					});		
				}
				 });
				
				 map.addOverlay(newMarker);
			 }
		});
		
		
	
	  }
        
	 map.addControl(new TextualZoomControl());

      }//end function

function TextualZoomControl() {
	
}

function addNote(userId, point, note){

		var d = new Date();
		var t = d.getTime(); 
		//var array = new Array();
		//array['asd'] = userId;
		point = "|"+point+"|";
		//array['dfg'] = note;
 		
		
		var result = new Ajax.Request('ajax/saveMap.php', {method: 'post',parameters: {userId:userId, point:point, note:note}, asynchronous:'true',
		  onSuccess: function(transport) {
			  
		    }
		});		

}

function tabIt(div){
	//alert(div);
	var divArray = Array("mapContainer", "notesContainer");
	//var imagesArray = Array("mymaps", "mynotes");
	
	for (var i=0;i< divArray.length ;i++)	{
	
		if(div == divArray[i]){
		document.getElementById(div).style.display = "";
		//document.getElementById(div+"Tab").style.bgColor = "#cccccc" ;
		document.getElementById(divArray[i]+"Link").style.textDecoration  = "underline";
		document.getElementById(divArray[i]+"Note").style.display = "";
		}
		else{
		document.getElementById(divArray[i]).style.display = "none";
		//document.getElementById(imagesArray[i]).src  = "images/"+imagesArray[i]+".gif";
		document.getElementById(divArray[i]+"Link").style.textDecoration  = "";
		document.getElementById(divArray[i]+"Note").style.display = "none";
		}
	
	}
	
	
}

function getNotes(userId, newNote){
var ajax;
	var d = new Date();
	var t = d.getTime();
	
	ajax =  new
	Ajax.Updater(
		 "noteArea", // DIV id must be declared before the method was called
		 'ajax/getNotes.php?t='+t+'&userId='+userId,{method:'get'});
	
			//}

}

function highlightNote(){
	new Effect.Highlight('newNote');
}


function addNotes(userId){
		
		var note = document.getElementById('noteContent').value;
		
		var d = new Date();
		var t = d.getTime(); 
		var result = new Ajax.Request('ajax/addNote.php', {method: 'post',parameters: {userId:userId, note:note}, asynchronous:'false'
		});		
		getNotes(userId,1)
		

}

function deleteNote(userId,noteId){
	
	
	    var d = new Date();
		var t = d.getTime(); 

		var result = new Ajax.Request('ajax/deleteNote.php', {method: 'post',parameters: {noteId:noteId}, asynchronous:'true'
 
		});		
		getNotes(userId)
	
}

function showThis(type){
	
	var divArray = Array("myCity", "myNews", "myWeather", "myWorkArea", "myMusic" ,"myMovies");
	
	for (var i=0;i< divArray.length ;i++)	{
	//alert(divArray[i]);
		if(type == divArray[i]){
		document.getElementById(divArray[i]).style.display = "";
		
		}
		else{
		document.getElementById(divArray[i]).style.display = "none";
		}
	
	}	
}

function getWeather(value){
	
	var ajax;
	var d = new Date();
	var t = d.getTime();
	
		document.getElementById('weatherArea').innerHTML = "<p style='text-align:center'><img src='images/loader.gif'><br />Please Wait.....</p>";
					
		var result = new Ajax.Request('ajax/getWeather.php?t='+t+'&id='+value, {method: 'get', asynchronous:'true',
		onSuccess: function(transport) {
		document.getElementById('weatherArea').innerHTML = transport.responseText;
		}
					
		});			

}

function startTime(){
	var today=new Date();
	var h=today.getHours();
	var m=today.getMinutes();
	var s=today.getSeconds();
	// add a zero in front of numbers<10
	m=checkTime(m);
	s=checkTime(s);
	document.getElementById('txt').innerHTML=h+":"+m+":"+s;
	t=setTimeout('startTime()',500);
}

function checkTime(i){
	if (i<10)
	  {
	  i="0" + i;
	  }
	return i;
}

function updateCashBonus(id, title, tier,sectionId){
	var ajax;
	var d = new Date();
	var t = d.getTime();
	var newTitle = title.replace('&',"and");
	document.getElementById('instantDiscountCol2').innerHTML = "<p style='text-align:center'><img src='images/loader.gif'><br />Please Wait.....</p>";
	
	var result = new Ajax.Request('ajax/getCashBonus.php?t='+t+'&id='+id+'&title='+newTitle+'&tier='+tier+'&sectionId='+sectionId, {method: 'get', asynchronous:'true',
	onSuccess: function(transport) {
	document.getElementById('instantDiscountCol2').innerHTML = transport.responseText;
	}})
	
}



function updateCashBonus2(id, title, tier){
	var ajax;
	var d = new Date();
	var t = d.getTime();
	var newTitle = title.replace('&',"and");
	
	document.getElementById('instantDiscountCol3').style.display = '';
	document.getElementById('instantDiscountCol3').innerHTML = "<p style='text-align:center'><img src='images/loader.gif'><br />Please Wait.....</p>";
	
	var result = new Ajax.Request('ajax/getCashBonus.php?t='+t+'&id='+id+'&title='+newTitle+'&tier='+tier, {method: 'get', asynchronous:'true',
	onSuccess: function(transport) {
	document.getElementById('instantDiscountCol3').innerHTML = transport.responseText;
	document.getElementById('instantDiscountCol2').style.display = 'none';
	}})
	
}

function restoreCashBack()
{
	document.getElementById('instantDiscountCol3').style.display = 'none';
	document.getElementById('instantDiscountCol2').style.display = '';
}


function updateDiscount(id, div,title,sectionId){
	
	var ajax;
	var d = new Date();
	var t = d.getTime();
	document.getElementById(div).innerHTML = "<p style='text-align:center'><img src='images/loader.gif'><br />Please Wait.....</p>";
	
	var result = new Ajax.Request('ajax/getInstantDiscount.php?t='+t+'&id='+id+"&title="+title+"&sectionId="+sectionId, {method: 'get', asynchronous:'true',
	onSuccess: function(transport) {
	document.getElementById(div).innerHTML = transport.responseText;
	}})
	
}
function redeemPoints(reward,id){
	
	var ajax;
	var d = new Date();
	var t = d.getTime();
	
	//document.getElementById('redeemPoints').innerHTML = "<img src='images/loader.gif'><br />Please Wait.....";
	
	var result = new Ajax.Request('ajax/redeemPoints.php?t='+t+'&id='+id+'&reward='+reward, {method: 'get', asynchronous:'true',
	onSuccess: function(transport) {
	document.getElementById('redeemPoints').innerHTML = transport.responseText;
	}})
	
}

function tabFAQ(div, divwithin, type){

var oDiv = document.getElementById(divwithin);
if(oDiv.firstChild) { // check for children
   var oChild = oDiv.firstChild;
   while(oChild) { // run over them
     if(oChild.nodeType==1) { // element
	 var title = oChild.id.split("_")

      if(div != oChild.id && oChild.id != '' && oChild.style.display == '' && title[1] != 'title' && title[1] != 'h2'){
		 //alert(oChild.id);
		  if(type==2){
		  Effect.BlindUp(oChild, { duration: 0.3 });
		  }
		  else{
		  oChild.style.display = "none";  
		  } 
	   }
		  if(title[1] == "title" && div != title[0]){
			  oChild.style.color = "#000000";  
		  }
		
		  if(title[1] == "title" && div == title[0]){
			   oChild.style.color = "#4f6e8d";  
		  }
		  
	  
	  if (div == oChild.id && oChild.id != '' ){ 
	 
		 if(type==2){
		 Effect.BlindDown(oChild, { duration: 0.3 });
		 }
		 else{
		 Effect.Appear(oChild, { duration: 1.0 });
		 }
	 
	  }
    }
    oChild = oChild.nextSibling;
   }
}

}

function doIt(div){
	var divs = new Array("545_a","553_a","554_a","555_a","556_a");
	
	for (var i=0;i< divs.length ;i++)	{
		if(divs[i] == div){
	    document.getElementById(div).style.textDecoration = 'underline';
		
		}else{
		document.getElementById(divs[i]).style.textDecoration = 'none';
		}
	}
	
}

function getExUsage(id, title, sectionId, link,table){
//alert(id);
var ajax;
	var d = new Date();
	var t = d.getTime();
	//document.getElementById(div).innerHTML = "<p style='text-align:center'><img src='images/loader.gif'><br />Please Wait.....</p>";
	
	var result = new Ajax.Request('ajax/usageLog.php?t='+t+'&uid='+id+"&title="+title+"&sectionId="+sectionId+"&link="+link+"&table="+table, {method: 'get', asynchronous:'true',
	onSuccess: function(transport) {
	//document.getElementById(div).innerHTML = transport.responseText;
	
	}})
}


