// JavaScript Document


var adstr = window.location.search.substring(1,6);
var locat;
if (adstr == "adloc"){
	locat = window.location.search.substring(7);
}
else if (adstr == "utm_s"){
	locat = window.location.search.substring(12);
}
if (locat) {
		var name = 'advert';
		var value = locat;
		var date = new Date();
		date.setTime(date.getTime()+(90*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
    	var path = '/';
		document.cookie = name + "=" +escape(value)+expires+"; path=/";
}

//Get cookie routine
function get_cookie(Name) {
  var search = Name + "="
  var returnvalue = "";
  if (document.cookie.length > 0) {
    offset = document.cookie.indexOf(search)
    // if cookie exists
    if (offset != -1) { 
      offset += search.length
      // set index of beginning of value
      end = document.cookie.indexOf(";", offset);
      // set index of end of cookie value
      if (end == -1) end = document.cookie.length;
      returnvalue=unescape(document.cookie.substring(offset, end))
      }
   }
  return returnvalue;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('Please fill in the required field(s):\n'+errors);
  	else {
			var valid1, valid2
			valid1=compareEmail();
			valid2=checkTerms();
			}
  document.MM_returnValue = (errors == '')&&(valid1)&&(valid2);
}

function compareEmail() {
	var valid, email1, email2
    valid = true;
	email1=document.torForm.Email_Address.value;
	email2=document.torForm.Confirm_Email.value;
    if (email1 != email2) {alert('Email addresses do not match, please check your email address.'); valid = false;}
    return valid;
}

function checkTerms() {
	var valid
	valid = true;
	if (document.torForm.Terms.checked==false) {alert('You must agree to the terms and conditions to continue.'); valid = false;}
	return valid;
}


function hilite(obj) {
	obj.style.background = '#FFFFFF';
}

function delite(obj) {
	obj.style.background = '#E2E2E9';		
}


////////////////////////////////////////////////////////
//***                                              ***//
//**                                                **//
//*      SHOW AND HIDE WEB FORM HIDDEN FIELDS        *//
//**                                                **//
//***                                              ***//
////////////////////////////////////////////////////////

////////////////////////////////////////////////////////
//*      RECOMMENDATION DROPDOWN - SHOW/HIDE         *//
////////////////////////////////////////////////////////

function display(obj,id1,id2) {
txt = obj.options[obj.selectedIndex].value;
document.getElementById(id1).style.display = 'none';
document.getElementById(id2).style.display = 'none';
if ( txt.match(id1) ) {
document.getElementById(id1).style.display = 'block';
}
if ( txt.match(id2) ) {
document.getElementById(id2).style.display = 'block';
}
}

////////////////////////////////////////////////////////
//*     CORP APP LEGAL STATUS FIELD - SHOW/HIDE      *//
////////////////////////////////////////////////////////

function display2(obj,id1) {
txt = obj.options[obj.selectedIndex].value;
document.getElementById(id1).style.display = 'none';
if ( txt.match(id1) ) {
document.getElementById(id1).style.display = 'block';
}
}

//
function display3(obj,id1) {
txt = obj.options[obj.selectedIndex].value;
document.getElementById(id1).style.display = 'none';
if ( txt.match(id1) ) {
document.getElementById(id1).style.display = 'block';
}
}

//
function display4(obj,id1) {
txt = obj.options[obj.selectedIndex].value;
document.getElementById(id1).style.display = 'none';
if ( txt.match(id1) ) {
document.getElementById(id1).style.display = 'block';
}
}

//Yes or No senario//
function display5(obj,id1) {
txt = obj.options[obj.selectedIndex].value;
document.getElementById(id1).style.display = 'none';
if ( txt.match(id1) ) {
document.getElementById(id1).style.display = 'block';
}
}

////////////////////////////////////////////////////////
// PPC CURRENCY FORECAST EXTRA CURRENCIES - SHOW/HIDE //
////////////////////////////////////////////////////////

function hidden(obj,id1) {
txt = obj.options[obj.selectedIndex].value;
document.getElementById(id1).style.display = 'none';
if ( txt.match(id1) ) {
document.getElementById(id1).style.display = 'block';
}
}

//function hidden2(obj,id1,id2) {
function hidden2(obj,id1) {
txt = obj.options[obj.selectedIndex].value;
document.getElementById(id1).style.display = 'none';
// document.getElementById(id2).style.display = 'none';
if ( txt.match(id1) ) {
document.getElementById(id1).style.display = 'block';
}
// if ( txt.match(id2) ) {
// document.getElementById(id2).style.display = 'block';
// }
}

//function hidden3(obj,id1,id2,id3) {
function hidden3(obj,id1) {
txt = obj.options[obj.selectedIndex].value;
document.getElementById(id1).style.display = 'none';
if ( txt.match(id1) ) {
document.getElementById(id1).style.display = 'block';
}
// REMOVED EXTRA FIELDS (dan 20/7/10)//if ( txt.match(id2) ) {
//document.getElementById(id2).style.display = 'block';
//}
//if ( txt.match(id3) ) {
//document.getElementById(id3).style.display = 'block';
//}
}


function hidden5(obj,id1,id2,id3) {
txt = obj.options[obj.selectedIndex].value;
document.getElementById(id1).style.display = 'none';
document.getElementById(id2).style.display = 'none';
document.getElementById(id3).style.display = 'none';
if ( txt.match(id1) ) {
document.getElementById(id1).style.display = 'block';
}
if ( txt.match(id2) ) {
document.getElementById(id2).style.display = 'block';
}
if ( txt.match(id3) ) {
document.getElementById(id3).style.display = 'block';
}
}


function hidden4(obj,id1,id2,id3,id4) {
txt = obj.options[obj.selectedIndex].value;
document.getElementById(id1).style.display = 'none';
document.getElementById(id2).style.display = 'none';
document.getElementById(id3).style.display = 'none';
document.getElementById(id4).style.display = 'none';
if ( txt.match(id1) ) {
document.getElementById(id1).style.display = 'block';
}
if ( txt.match(id2) ) {
document.getElementById(id2).style.display = 'block';
}
if ( txt.match(id3) ) {
document.getElementById(id3).style.display = 'block';
}
if ( txt.match(id4) ) {
document.getElementById(id4).style.display = 'block';
}
}

////////////////////////////////////////////////////////
//*     OPEN ACCOUNT FORMS ANZ-BANK - SHOW/HIDE      *//
////////////////////////////////////////////////////////

function anz(obj,id1,id2, id3) {
txt = obj.options[obj.selectedIndex].value;
document.getElementById(id1).style.display = 'none';
document.getElementById(id2).style.display = 'none';
document.getElementById(id3).style.display = 'none';
if ( txt.match(id1) ) {
document.getElementById(id1).style.display = 'block';
}
if ( txt.match(id2) ) {
document.getElementById(id2).style.display = 'block';
}
if ( txt.match(id3) ) {
document.getElementById(id3).style.display = 'block';
}
}

////////////////////////////////////////////////////////
//*              ADD MORE DIRECTORS JAVA             *//
////////////////////////////////////////////////////////

function director(obj,id1,id2,id3,id4,id5,id6,id7,id8,id9,id10) {
txt = obj.options[obj.selectedIndex].value;
document.getElementById(id1).style.display = 'none';
document.getElementById(id2).style.display = 'none';
document.getElementById(id3).style.display = 'none';
document.getElementById(id4).style.display = 'none';
document.getElementById(id5).style.display = 'none';
document.getElementById(id6).style.display = 'none';
document.getElementById(id7).style.display = 'none';
document.getElementById(id8).style.display = 'none';
document.getElementById(id9).style.display = 'none';
document.getElementById(id10).style.display = 'none';
if ( txt.match(id1) ) {
document.getElementById(id1).style.display = 'block';
}
if ( txt.match(id2) ) {
document.getElementById(id1).style.display = 'block';
document.getElementById(id2).style.display = 'block';
}
if ( txt.match(id3) ) {
document.getElementById(id1).style.display = 'block';
document.getElementById(id2).style.display = 'block';
document.getElementById(id3).style.display = 'block';
}
if ( txt.match(id4) ) {
document.getElementById(id1).style.display = 'block';
document.getElementById(id2).style.display = 'block';
document.getElementById(id3).style.display = 'block';
document.getElementById(id4).style.display = 'block';
}
if ( txt.match(id5) ) {
document.getElementById(id1).style.display = 'block';
document.getElementById(id2).style.display = 'block';
document.getElementById(id3).style.display = 'block';
document.getElementById(id4).style.display = 'block';
document.getElementById(id5).style.display = 'block';
}
if ( txt.match(id6) ) {
document.getElementById(id1).style.display = 'block';
document.getElementById(id2).style.display = 'block';
document.getElementById(id3).style.display = 'block';
document.getElementById(id4).style.display = 'block';
document.getElementById(id5).style.display = 'block';
document.getElementById(id6).style.display = 'block';
}
if ( txt.match(id7) ) {
document.getElementById(id1).style.display = 'block';
document.getElementById(id2).style.display = 'block';
document.getElementById(id3).style.display = 'block';
document.getElementById(id4).style.display = 'block';
document.getElementById(id5).style.display = 'block';
document.getElementById(id6).style.display = 'block';
document.getElementById(id7).style.display = 'block';
}
if ( txt.match(id8) ) {
document.getElementById(id1).style.display = 'block';
document.getElementById(id2).style.display = 'block';
document.getElementById(id3).style.display = 'block';
document.getElementById(id4).style.display = 'block';
document.getElementById(id5).style.display = 'block';
document.getElementById(id6).style.display = 'block';
document.getElementById(id7).style.display = 'block';
document.getElementById(id8).style.display = 'block';
}
if ( txt.match(id9) ) {
document.getElementById(id1).style.display = 'block';
document.getElementById(id2).style.display = 'block';
document.getElementById(id3).style.display = 'block';
document.getElementById(id4).style.display = 'block';
document.getElementById(id5).style.display = 'block';
document.getElementById(id6).style.display = 'block';
document.getElementById(id7).style.display = 'block';
document.getElementById(id8).style.display = 'block';
document.getElementById(id9).style.display = 'block';
}
if ( txt.match(id10) ) {
document.getElementById(id1).style.display = 'block';
document.getElementById(id2).style.display = 'block';
document.getElementById(id3).style.display = 'block';
document.getElementById(id4).style.display = 'block';
document.getElementById(id5).style.display = 'block';
document.getElementById(id6).style.display = 'block';
document.getElementById(id7).style.display = 'block';
document.getElementById(id8).style.display = 'block';
document.getElementById(id9).style.display = 'block';
document.getElementById(id10).style.display = 'block';
}
}

////////////////////////////////////////////////////////
//*********************** END ************************//
////////////////////////////////////////////////////////




////////////////////////////////////////////////////////
//*              IPOD HANDSET REDIRECT               *//
////////////////////////////////////////////////////////

if ((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))) {
	var qryStr = window.location.search.substring(0);
	location.replace("http://www.torfx.mobi/index.htm"+qryStr);
}

////////////////////////////////////////////////////////
//*********************** END ************************//
////////////////////////////////////////////////////////




////////////////////////////////////////////////////////
//*             ANDRIOD HANDSET REDIRECT             *//
////////////////////////////////////////////////////////

if (screen.width <= 639) {
	var qryStr = window.location.search.substring(0);
	document.location = "http://www.torfx.mobi/index.htm"+qryStr;
}

////////////////////////////////////////////////////////
//*********************** END ************************//
////////////////////////////////////////////////////////
