/* 
var mine = window.open('','','width=1,height=1,left=0,top=0,scrollbars=no');
 if(mine)
    var popUpsBlocked = false
 else
    var popUpsBlocked = true
 mine.close()
*/

/*	Get tips Detail From Table using Ajax */

/*var req = createXMLHttpRequest();
function getCat(cat)
{ 
	req3.open("POST", "bin/getTipsCat.php",true);	
	req3.onreadystatechange = handleResponse3;
	req3.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	req3.send("cat="+cat);
	return false;
}

function handleResponse3() {
if(req3.readyState == 4){
  var response = req3.responseText;  
 window.location = "tips-detail-"+response+"-page.htm"; 
 }
}
/*	Get tips Detail From Table using Ajax */

var req2 = createXMLHttpRequest();
function getArticlesCat(cat)
{ 
	req2.open("POST", "bin/getArticlesDetail.php",true);	
	req2.onreadystatechange = handleResponse2;
	req2.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	req2.send("cat="+cat);
	return false;
}

function handleResponse2() {
if(req2.readyState == 4){
  var response = req2.responseText;  
  if(response.match("#"))
   {
	  res_array = response.split("#");
	  cat_url = res_array[0].toLowerCase(); 
	  window.location = "no-articles-for-category-"+cat_url+".htm";  
   }
  else
	window.location = "articles-detail-"+response+".htm"; 
 }
}

/*	Get tips Detail From Table using Ajax */

var req3 = createXMLHttpRequest();
function getTipsCat(cat)
{ 
	req3.open("POST", "bin/getTipsDetail.php",true);	
	req3.onreadystatechange = handleResponse3;
	req3.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	req3.send("cat="+cat);
	return false;
}

function handleResponse3() {
if(req3.readyState == 4){
  var response = req3.responseText;
  if(response.match("#"))
   {
	  res_array = response.split("#");
	  cat_url = res_array[0].toLowerCase(); 
	  window.location = "no-tips-for-category-"+cat_url+".htm";  
   }
  else
	window.location = "tips-detail-"+response+".htm"; 
 }
}

function createXMLHttpRequest() {
		 var xmlHttp;
		
		if(!xmlHttp && typeof XMLHttpRequest != 'undefined')
		{
			try
			{
				xmlHttp = new XMLHttpRequest();
			}
			catch (e)
			{
				alert("Your browser is not supporting XMLHttpRequest");
				xmlHttp = false;
			}
		}
  	else
		{
			xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
		}
		return xmlHttp;
}

function formwindow(mypage)
{
	myname = "form";
	w =  screen.width;
	h = screen.height;	
	var win = null;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =
	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
	win = window.open(mypage,myname,settings);	
}

function validate_credit()
{
	var return_value = 1;
	document.form2.inst_name_mess.value			= "";
	document.form2.product_name_mess.value		= "";
	document.form2.email_mess.value		        = "";
	document.form2.contact_number_mess.value	= "";
	document.form2.mobile_number_mess.value		= "";
	document.form2.business_contact_time_mess.value	= "";
	document.form2.evenings_contact_time_mess.value	= "";
	document.form2.privacy_auth_mess.value		= "";
	document.form2.first_name_mess.value		= "";
	document.form2.last_name_mess.value		    = "";
	document.form2.state_mess.value		        = "";

	
	if(!is_empty(document.form2.inst_name,"Empty Institution Name",document.form2.inst_name_mess))
		return_value = 0;
				
	if(!is_empty(document.form2.product_name,"Empty Product Name",document.form2.product_name_mess))
		return_value = 0;
	
	if(!is_empty(document.form2.first_name,"Enter First Name",document.form2.first_name_mess))
		return_value = 0;

	if(!is_empty(document.form2.last_name,"Enter Last Name",document.form2.last_name_mess))
		return_value = 0;


	if(!is_empty(document.form2.email,"Empty Email Address",document.form2.email_mess))
		return_value = 0;
	else
		if(!is_email(document.form2.email,"Invalid Email Address",document.form2.email_mess))
			return_value = 0;
		else
			if(!is_maxlength(document.form2.email,"Too Big Email Id",document.form2.email_mess,100))
				return_value = 0;

	if(!is_empty_both(document.form2.contact_number,document.form2.mobile_number,"Empty Contact Number",document.form2.mobile_number_mess))
		return_value = 0;
	else
		if(!is_contact_number(document.form2.contact_number,document.form2.mobile_number,"Invalid Number",document.form2.contact_number_mess,document.form2.mobile_number_mess))
			return_value = 0;
	
		if(!is_contact_time(document.form2.business_contact_time,document.form2.business_contact_mint,document.form2.evenings_contact_time,document.form2.evenings_contact_mint,"Select Contact Time",document.form2.evenings_contact_time_mess))
			return_value = 0;
	
	if(!is_empty(document.form2.state,"Select State",document.form2.state_mess))
		return_value = 0;

	if(document.form2.privacy_auth.checked==false)
		{
			document.form2.privacy_auth_mess.value  = "Check Privacy Authorization";  		  			
			return false;
		}
	

if(return_value == 0)	
	return false;
else
	return true;	
}

function validate()
{
	var return_value = 1;
	document.form1.product_id_mess.value		= "";
	document.form1.title_name_mess.value		= "";                         
	document.form1.first_name_mess.value		= "";
	document.form1.last_name_mess.value		    = "";
	document.form1.email_mess.value		        = "";
	document.form1.contact_number_mess.value	= "";
	document.form1.town_name_mess.value			= "";
	document.form1.state_mess.value				= "";
	document.form1.post_code_mess.value			= "";
	document.form1.gross_income_mess.value		= "";
	document.form1.buying_stage_mess.value		= "";
	document.form1.number_of_applicants_mess.value	= "";
	document.form1.purpose_of_enquiry_mess.value	= "";
	document.form1.promo_sign_mess.value		= "";
	document.form1.income_range_mess.value		= "";
	document.form1.cat_mess.value				= "";
	
	if(!is_empty(document.form1.product_id,"Empty Product Name",document.form1.product_id_mess))
		return_value = 0;
				
	if(!is_empty(document.form1.title_name,"Empty Title",document.form1.title_name_mess))
		return_value = 0;
	else
		if(!is_valid_title(document.form1.title_name,"Invalid Title",document.form1.title_name_mess))
			return_value = 0;
		
	if(!is_empty(document.form1.first_name,"Empty First Name",document.form1.first_name_mess))
		return_value = 0;
	else
		if(!is_alpha(document.form1.first_name,"Invalid First Name",document.form1.first_name_mess))
			return_value = 0;
		else
			if(!is_maxlength(document.form1.first_name,"Too Big First Name",document.form1.first_name_mess,50))
				return_value = 0;
		
	if(!is_empty(document.form1.last_name,"Empty Last Name",document.form1.last_name_mess))
		return_value = 0;
	else
		if(!is_alpha(document.form1.last_name,"Invalid Last Name",document.form1.last_name_mess))
			return_value = 0;
		else
			if(!is_maxlength(document.form1.last_name,"Too Big Last Name",document.form1.last_name_mess,50))
				return_value = 0;

	if(!is_empty(document.form1.email,"Empty Email",document.form1.email_mess))
		return_value = 0;
	else
		if(!is_email(document.form1.email,"Invalid Email",document.form1.email_mess))
			return_value = 0;
		else
			if(!is_maxlength(document.form1.email,"Too Big Email Id",document.form1.email_mess,100))
				return_value = 0;

		
	if(!is_number_area(document.form1.contact_code,"Invalid Number",document.form1.contact_number_mess))
			return_value = 0;
		
	
	if(!is_empty(document.form1.contact_number,"Empty Contact Number",document.form1.contact_number_mess))
		return_value = 0;
	else
		if(!is_number(document.form1.contact_number,"Invalid Number",document.form1.contact_number_mess))
			return_value = 0;

	
	if(!is_empty(document.form1.town_name,"Empty Town Name",document.form1.town_name_mess))
		return_value = 0;
	else
		if(!is_alpha_numeric(document.form1.town_name,"Invalid Town Name",document.form1.town_name_mess))
			return_value = 0;
		else
			if(!is_maxlength(document.form1.town_name,"Too Big Town Name",document.form1.town_name_mess,50))
				return_value = 0;


	if(!is_empty(document.form1.post_code,"Empty Post Code",document.form1.post_code_mess))
		return_value = 0;
	else
		if(!is_alpha_numeric(document.form1.post_code,"Invalid Post Code",document.form1.post_code_mess))
			return_value = 0;
		else
			if(!is_maxlength(document.form1.post_code,"Too Big Post Code",document.form1.post_code_mess,15))
				return_value = 0;

	if(!is_empty(document.form1.state,"Empty State",document.form1.state_mess))
		return_value = 0;
	else
		if(!is_alpha_numeric(document.form1.state,"Invalid Sate Name",document.form1.state_mess))
			return_value = 0;
		else
			if(!is_maxlength(document.form1.state,"Too Big State Name",document.form1.state_mess,50))
				return_value = 0;
	
	if(!is_empty(document.form1.gross_income,"Empty Gross Income",document.form1.gross_income_mess))
		return_value = 0;
	else
		if(!is_valid_income(document.form1.gross_income,"Invalid Gross Income",document.form1.gross_income_mess))
			return_value = 0;
		
	if(!is_select(document.form1.buying_stage,"Buying Stage not Selected",document.form1.buying_stage_mess))
		return_value = 0;

	if(!is_select(document.form1.number_of_applicants,"Number of Applicants not Selected",document.form1.number_of_applicants_mess))
		return_value = 0;
	
	if(!is_select(document.form1.purpose_of_enquiry,"Purpose of Enquiry not Selected",document.form1.purpose_of_enquiry_mess))
		return_value = 0;

	
	rad_val = get_radio_value();			
	if(rad_val==1) 
	{
		if((document.form1.credit.checked==false)&&(document.form1.personal.checked==false)&&(document.form1.car.checked==false)&&
		(document.form1.home.checked==false)&&(document.form1.wealth.checked==false))
		{		
				document.form1.cat_mess.value  = "Select Category to receive promotions";  		
  				return_value = 0;				
		}

		if(document.form1.income_range.value==0)
		{		
				document.form1.income_range_mess.value  = "Select Income Range";  							
  				return_value = 0;
		}
	}
	else if(rad_val==0) 
	{
		
		if((document.form1.credit.checked==true)||(document.form1.personal.checked==true)||(document.form1.car.checked==true)||
		(document.form1.home.checked==true)||(document.form1.wealth.checked==true)||(document.form1.income_range.value!=0))
		{
			document.form1.promo_sign_mess.value  = "Check Promotional Sign up";  					
  			return_value = 0;
		}
	
	}

	

if(return_value == 0)	
	return false;
else
	return true;
	
	
}


/*	
	*	this function gives the radio button value
	
*/
	
	function get_radio_value()
	{
		for (var i=0; i < document.form1.promo_sign.length; i++)
		{
			if (document.form1.promo_sign[i].checked)
			{
				var rad_val = document.form1.promo_sign[i].value;
			}
		}
		return rad_val;
	}

/*	
	*	this function checks the given string is empty or not
	*	and return true or false accordingly & first letter alphabet
*/
	
	function is_empty_both(fld1,fld2,message,fld_mess)
	{
  		if ((fld1.value=="")&&(fld2.value==""))
		{
			fld_mess.value  = message;  		  			
			return false;
		}
		 return true;
	}


	/*
	*	this function checks the given number is signed/unsigned number
	*	and return true or false accordingly.
*/

	function is_contact_number(fld1,fld2,message,fld1_mess,fld2_mess)
	{
		if (fld1.value!="")
		{
			if(!fld1.value.match(/^[\-+0-9 ]+$/))
			{
				fld1_mess.value  = message;  		  			
				return false;
			}
		}
		if (fld2.value!="")
		{
			if(!fld2.value.match(/^[\-+0-9 ]+$/))
			{
				fld2_mess.value  = message;  		  			
				return false;
			}
		}
		return true;
	}
/*
	*	this function checks the given number is signed/unsigned number
	*	and return true or false accordingly.
*/

	function is_contact_time(fld1,fld2,fld3,fld4,message,fld_mess)
	{
  		if ((fld1.value=="0")&&(fld2.value=="0")&&(fld3.value=="0")&&(fld4.value=="0"))
		{
			fld_mess.value  = message;  		  			
			return false;
		}
		 return true;
	}
/*	
	*	this function checks the given string is empty or not
	*	and return true or false accordingly & first letter alphabet
*/
	
	function is_empty(fld,message,fld_mess)
	{
  		if ((fld.value.length==0)||(fld.value==null)||(fld.value==""))
		{
			fld_mess.value  = message;  		  			
			return false;
		}
		 return true;
	}

/*	
	*	this function checks the given select is selected or not
	*	and return true or false accordingly 
*/
	
	function is_select(fld,message,fld_mess)
	{
		if ((fld.value==0)||(fld.value==""))
		{
			fld_mess.value  = message;  		  			
			return false;
		}
		 return true;
	}

/*	
	*	this function checks the given string is alphabets only
	*	and return true or false accordingly.
*/
	
	function is_alpha(fld,message,fld_mess)
	{
		if(!fld.value.match(/^[A-Za-z ]+$/))
		{
			fld_mess.value  = message;  		  			
			return false;
		}
		return true;
	}

/*  
	*	this function checks the email format is correct or not
	*	and return true or false accordingly.
*/
	function is_email(fld,message,fld_mess)
	{
		if(!fld.value.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/))
		{
			fld_mess.value  = message;  		  			
			return false;
		}
		return true;
	}

/*	
	*	this function checks the given string has max length
	*	and return true or false accordingly.
*/
	
	function is_maxlength(fld,message,fld_mess,maxlength)
	{
		if(fld.value.length > maxlength)
		{
			fld_mess.value  = message;  		  			
			return false;			
		}
		return true;
	}

	/*
	*	this function checks the given number is signed/unsigned number
	*	and return true or false accordingly.
*/

	function is_number(fld,message,fld_mess)
	{
		if(!fld.value.match(/^[\-+0-9 ]+$/))
		{
			fld_mess.value  = message;  		  			
			return false;
		}
		return true;
	}

/*
	*	this function checks the given number is signed/unsigned number
	*	and return true or false accordingly.
*/

	function is_number_area(fld,message,fld_mess)
	{
		if ((fld.value.length==0)||(fld.value==null)||(fld.value==""))
		{
			return true;
		}
		else if(!fld.value.match(/^[\-+0-9 ]+$/))
			{
				fld_mess.value  = message;  		  			
				return false;
			}
		
	return true;
	}

/*	
	*	this function checks the given string is alphanumeric word or not
	*	and return true or false accordingly.
*/
	
	function is_alpha_numeric(fld,message,fld_mess)
	{
		if(!fld.value.match(/^[A-Za-z0-9 ]+$/))
		{
			fld_mess.value  = message;  		  			
			return false;			
		}
		return true;
	}

/*	
	*	this function checks the given string does not contain special characters
	*	and return true or false accordingly.
*/
	
	function is_valid_income(fld,message,fld_mess)
	{
		if(!fld.value.match(/^[0-9\._\,\$\-+]+$/))
		{
			fld_mess.value  = message;  		  			
			return false;
		}
		return true;
	}

/*	
	*	this function checks the given string does not contain special characters
	*	and return true or false accordingly.
*/
	
	function is_valid_title(fld,message,fld_mess)
	{
		if(!fld.value.match(/^[0-9\._A-Za-z ]+$/))
		{
			fld_mess.value  = message;  		  			
			return false;
		}
		return true;
	}
	
var highlightcolor="FFFF99"

var ns6=document.getElementById&&!document.all
var previous=''
var eventobj

//Regular expression to highlight only form elements
var intended=/INPUT|TEXTAREA|SELECT|OPTION|RADIOBUTTON/

//Function to check whether element clicked is form element
function checkel(which){
if (which.style&&intended.test(which.tagName)){
if (ns6&&eventobj.nodeType==3)
eventobj=eventobj.parentNode.parentNode
return true
}
else
return false
}

//Function to highlight form element
function highlight(e){
eventobj=ns6? e.target : event.srcElement
if (previous!=''){
if (checkel(previous))
previous.style.backgroundColor=''
previous=eventobj
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
}
else{
if (checkel(eventobj))
eventobj.style.backgroundColor=highlightcolor
previous=eventobj
}
}



var winheight=100
var winsize=100
var x=5

function openwindow(thelocation){
temploc=thelocation

if (!(window.resizeTo&&document.all)&&!(window.resizeTo&&document.getElementById)){
window.open("bin/wizard.page.php?wiz=1","wizard","600","600","yes")
return
}

win2=window.open("bin/wizard.page.php?wiz=1","wizard","600","600","yes")
win2.moveTo(250,250)
win2.resizeTo(100,100)
go2()
}

function go2(){
if (winheight>=600)
x=0
win2.resizeBy(5,x)
winheight+=5
winsize+=5
if (winsize>=600){
win2.location=temploc
winheight=100
winsize=100
x=5
return
}
setTimeout("go2()",50)
}


function NewWindow(mypage,myname,w,h,scroll){
var win = null;
LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
settings =
'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable'
win = window.open(mypage,myname,settings);
}

function noclass(type)
{
	if (type==1)
	  for (i=1; i<13; i++)
  	{
    	var elem = document.getElementById('link'+i);
    	elem.className='';
  	}
}

function classy(nr,type)
{
  noclass(type);
  
  var elem = document.getElementById('link'+nr);
  
  elem.className='current';
}

function testwrite(nr)
{
  var elem = document.getElementById('what');
  switch (nr)
  {
    case 0:
      elem.innerHTML='No search performed';
      break;
    case 1:
      elem.innerHTML='Credit Cards';
      break;
    case 2:
      elem.innerHTML='Home Loans';
      break;
    case 3:
      elem.innerHTML='Personal Loans';
      break;
    case 4:
      elem.innerHTML='Low Doc Home Loans';
      break;
    case 5:
      elem.innerHTML='Debentures';
      break;
    case 6:
      elem.innerHTML='Reverse Mortgages';
      break;
    case 7:
      elem.innerHTML='Non-conforming Loans';
      break;
    case 8:
      elem.innerHTML='At-call Savings Account';
      break;
    case 9:
      elem.innerHTML='Internet Banking';
      break;
    case 10:
      elem.innerHTML='Short Term Deposits';
      break;
    case 11:
      elem.innerHTML='Long Term Deposits';
      break;
    case 12:
      elem.innerHTML='Car Loans';
      break;
  }
}

function send(nr)
{
	var string='document.cuc'+eval(nr)+'.submit()';
	eval(string);
}

function toggleclass()
{
  var elem = document.getElementById('sfooter');
  
  if (elem.className == 'product_search_footer')
    elem.className = 'product_search_footer1';
  else
    elem.className = 'product_search_footer';
}

function activ(aidi)
{
  var elem = document.getElementById(aidi);
  
  if (elem.className != 'selected')
  	elem.className = 'selected';
  else
  	elem.className = '';
}

function toggle(verify)
{
	var toggleEl = document.getElementById('div_'+verify);
  
  if (toggleEl.style.display == 'none')
    toggleEl.style.display = '';
  else 
    toggleEl.style.display = 'none';
}

function activateMenu(verify)
{
	var toggleEl = document.getElementById(verify);
	 var elem = document.getElementById('sfooter');
	 elem.className = 'product_search_footer1';
  	toggleEl.style.display = '';
  	document.getElementById("product_search").style.height = '275px';
  	document.getElementById("product_search_list").style.height = '300px';
  	document.getElementById("product_criterias_list").style.height = '300px';
}



function toggleMenu(verify,off,nr)
{
  var toggleEl = document.getElementById(verify);
  
  if (toggleEl.style.display == 'none')
  {
  	toggleEl.style.display = '';
  	document.getElementById('cucudebambus'+nr).style.display='';
  	document.getElementById("product_search").style.height = '275px';
  	document.getElementById("product_search_list").style.height = '300px';
	  //document.getElementById("product_navigator").style.height = '235px';
  	document.getElementById("product_criterias_list").style.height = '300px';
  	//document.getElementById("product_navigator").style.margin = '60px 263px';
  }
  else
  {
    toggleEl.style.display = 'none';
    
    var max=off.length;
  	var k=0;
  	for (i=0;i<max;i++)
  	{
  		if (off.charAt(i)==' ')
  			k++;
  	}
  	var off1 = new Array();
  	off1=off.split(' ')
  	for(i=0;i<k;i++)
  	{ 
  		nr=off1[i];
  		disableEl = document.getElementById('cucudebambus'+nr);
  		disableEl.style.display = 'none';
  	}
    
    document.getElementById("product_search").style.height = '30px';
    document.getElementById("product_search_list").style.height = '45px';
    //document.getElementById("product_navigator").style.height = '1px';
    document.getElementById("product_criterias_list").style.height = '45px';
    //document.getElementById("product_navigator").style.margin = '55px 263px';
  }
}

function disable(verify,on)
{
  var max=verify.length;
  var k=0;
  for (i=0;i<max;i++)
  {
  	if (verify.charAt(i)==' ')
  		k++;
  }
  
  var verify1 = new Array();
  verify1=verify.split(' ')
  for(i=0;i<k;i++)
  { 
  	nr=verify1[i];
  	disableEl = document.getElementById('cucudebambus'+nr);
  	disableEl.style.display = 'none';
  }
  var toggleEl = document.getElementById('cucudebambus'+on);

  if(on!='')
  	if (toggleEl.style.display == 'none')
    	toggleEl.style.display = '';
}


function openNewWindow(msg) 
{
//  window.location = msg;
  //sau
  /*popupWin = window.open(msg,
    'open_window',
    'menubar, toolbar, location, directories, status, scrollbars, resizable, dependent, width=800, height=600, left=0, top=0')*/

}

function MsgBox(msg1)
{
    spring = window.confirm(msg1);
  if (spring == true)
   {
     document.product.reset();
	     return true;
   }

}

function submitenter(myfield,e)
{
var keycode;
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;

 
  if (keycode == 13)
  {
    myfield.form.submit();
    return false;
  }
  else
    return true;
}

function search_panel_text(which)
{
	sc=document.getElementById('search_closed');
	so=document.getElementById('search_open');
	ss=document.getElementById('search_selected');
	if ((which==1)&&(so.style.display=='none')&&(ss.style.display=='none'))
	{
		sc.style.display='none';
		so.style.display='';
		ss.style.display='none';
	}
	else
		if ((which==1)&&(sc.style.display=='none'))
		{
			sc.style.display='';
			so.style.display='none';
			ss.style.display='none';
		}
		else
			if (which==2)
			{
				sc.style.display='none';
				so.style.display='none';
				ss.style.display='';
			}
			else
				{
					sc.style.display='';
					so.style.display='none';
					ss.style.display='none';
				}
}





var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="template_default/img/arrow.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip

/*	Get best credit rate for Purch Rate using Ajax */

var req5 = createXMLHttpRequest();
function getPurchRate()
{ 
	req5.open("POST", "bin/getPurchRate.php",true);	
	req5.onreadystatechange = handleResponse5;
	req5.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	req5.send("");
	return false;
}

function handleResponse5() {
  if(req5.readyState == 4){
    var response = req5.responseText;
	document.getElementById('show_results').innerHTML = "";
	document.getElementById('show_results').innerHTML = response;
	document.getElementById('td_1').className = "black-box";
	document.getElementById('td_2').className = "grey-box";
	document.getElementById('td_3').className = "grey-box";
	document.getElementById('td_4').className = "grey-box";

	document.getElementById('td_11').className = "orange-back";
	document.getElementById('td_22').className = "white-back";
	document.getElementById('td_33').className = "white-back";
	document.getElementById('td_44').className = "white-back";
  }
}

/*	Get best credit rate for Balance Transfer Rate using Ajax */

var req6 = createXMLHttpRequest();
function getBalanceTranfer()
{ 
	req6.open("POST", "bin/getBalanceTranfer.php",true);	
	req6.onreadystatechange = handleResponse6;
	req6.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	req6.send("");
	return false;
}

function handleResponse6() {
  if(req6.readyState == 4){
    var response = req6.responseText;
	document.getElementById('show_results').innerHTML = "";
	document.getElementById('show_results').innerHTML = response;
	document.getElementById('td_2').className = "black-box";
	document.getElementById('td_1').className = "grey-box";
	document.getElementById('td_3').className = "grey-box";
	document.getElementById('td_4').className = "grey-box";

	document.getElementById('td_22').className = "orange-back";
	document.getElementById('td_11').className = "white-back";
	document.getElementById('td_33').className = "white-back";
	document.getElementById('td_44').className = "white-back";
  }
}

/*	Get best credit rate for Interest Free days using Ajax */

var req7 = createXMLHttpRequest();
function getFreeDays()
{ 
	req7.open("POST", "bin/getFreeDays.php",true);	
	req7.onreadystatechange = handleResponse7;
	req7.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	req7.send("");
	return false;
}

function handleResponse7() {
  if(req7.readyState == 4){
    var response = req7.responseText;  
	document.getElementById('show_results').innerHTML = "";
	document.getElementById('show_results').innerHTML = response;
	document.getElementById('td_3').className = "black-box";
	document.getElementById('td_1').className = "grey-box";
	document.getElementById('td_2').className = "grey-box";
	document.getElementById('td_4').className = "grey-box";

	document.getElementById('td_33').className = "orange-back";
	document.getElementById('td_11').className = "white-back";
	document.getElementById('td_22').className = "white-back";
	document.getElementById('td_44').className = "white-back";
  }
}

/*	Get best credit rate for Annual Fee using Ajax */

var req8 = createXMLHttpRequest();
function getAnnualFee()
{ 
	req8.open("POST", "bin/getAnnualFee.php",true);	
	req8.onreadystatechange = handleResponse8;
	req8.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	req8.send("");
	return false;
}

function handleResponse8() {
  if(req8.readyState == 4){
    var response = req8.responseText;
	document.getElementById('show_results').innerHTML = "";
	document.getElementById('show_results').innerHTML = response;
	document.getElementById('td_4').className = "black-box";
	document.getElementById('td_1').className = "grey-box";
	document.getElementById('td_2').className = "grey-box";
	document.getElementById('td_3').className = "grey-box";

	document.getElementById('td_44').className = "orange-back";
	document.getElementById('td_11').className = "white-back";
	document.getElementById('td_22').className = "white-back";
	document.getElementById('td_33').className = "white-back";
  }
}

function validate_promo() { 
	document.getElementById('message_td').className = "small-font";
	document.getElementById('message_td').value = "*Required Fields";
	email_value = document.form1.email.value;
	income_value = document.form1.income.value;
	postcode_value = document.form1.postcode.value;

	if ((email_value.length==0)||(email_value==null)||(email_value=="")) {
		//document.getElementById('message_td').className = "small-font-red";
		document.getElementById('message_td').innerHTML = "Enter Email Address";
		return false;
	} else if(!email_value.match(/^[A-Za-z0-9\._\-+]+@[A-Za-z0-9_\-+]+(\.[A-Za-z0-9_\-+]+)+$/)) {
	   //document.getElementById('message_td').className = "small-font-red";
	   document.getElementById('message_td').innerHTML = "Invalid Email Address";
		return false;	
	}

	if (income_value!="") {
		if(!income_value.match(/^[ 0-9\._\,\$\-+]+$/)) {
		   //document.getElementById('message_td').className = "small-font-red";
		   document.getElementById('message_td').innerHTML = "Invalid Income Format";		  			
			return false;
		}
	}

	if(postcode_value.length > 4) {
	   //document.getElementById('message_td').className = "small-font-red";
	   document.getElementById('message_td').innerHTML = "Postcode should be 4 digits only";		  			
		return false;
	}

	if((document.form1.credit.checked==false)&&(document.form1.homeloan.checked==false)&&(document.form1.personal.checked==false)&&
		(document.form1.annuation.checked==false)&&(document.form1.consolidation.checked==false) && (document.form1.savings.checked==false)) {		
		 //   document.getElementById('message_td').className = "small-font-red";
			document.getElementById('message_td').innerHTML = "At least one offer must be selected";		  			
			return false;
	}
	return true;
}

function privacyWindow(mypage,myname,w,h,scroll){
	var win = null;
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =
	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable,menubar=no,location=no,titlebar=no,toolbar=no,directories=no,status=0';
	win = window.open(mypage,myname,settings);
}

function showPolicy() {
	if(document.getElementById('privacy_div').style.visibility=="visible") {
		document.getElementById('privacy_div').style.visibility="hidden";
		document.getElementById('privacy_text').innerHTML="Privacy Policy";		
	}
	else {
		document.getElementById('privacy_div').style.visibility="visible";
		document.getElementById('privacy_text').innerHTML="Close Privacy Policy";
	}
}









