//<!--
function custref() 
{
	window.location = "cgi-bin/refer.pl?session_id=" + getCookie("session_id") + "&dvalue=" + getCookie("dvalue");
}
function disclaimer() 
{
    var wnd_params='height=330,width=350,resizable=yes';
	window.open("disclaimer.html", "discl_wnd", wnd_params);
}

function deleteCookie(name) 
{
	setCookie(name,"",-1);
}

function cleanUp()
{
	deleteCookie('dvalue'); 
	deleteCookie("branch");
	deleteCookie("en");
	deleteCookie("et");
	deleteCookie("session_id");
}

function verifySession()
{
	var sessionCheckValue = getCookie("session_id");
	var envValue = getCookie("dvalue");
	if (sessionCheckValue == null )
	{
		//window.location = document.URL.substr(0, document.URL.indexOf("index0.htm") - 1) + "/expire.html";\
		cleanUp();
//		window.top.location = document.URL.substr(0, document.URL.indexOf("index0.htm") - 1) + "/expire.html";
		window.parent.location = document.URL.substr(0, document.URL.indexOf("index0.htm") - 1) + "/expire.html";
	}
	else
	{
		setCookie('dvalue', envValue); 
		setCookie("session_id", sessionCheckValue);
	}
}

function acctListChange(action_value) {
	 with (document.sel_form) {
	 	  if (!action_value) {
		   	  action="reports.pl";
		  }
		  else {
		  	  action = action_value;
		  }
	 	  acc_list_idx.value = acct_list.selectedIndex;
	 	  if (report_type.value == "monthly" ||
		  	  report_type.value == "monthly_nf" || 
		  	 report_type.value == "monthly_all" || 
			 report_type.value == "monthly_print" ||
			 report_type.value == "weekly_print" ||
			 report_type.value == "daily_print" ) {
		  	 target="report_main";
		  	 submit();
		  }
	 }
}

function join() 
{
  var wnd_param ="width=650,height=450,resizable=no,scrollbars=yes";
  window.open("http://www.choicefx.com/regist_wnd.html", "regist_wnd", wnd_param);
}

function getCookieVal (offset) 
{ 
	var endstr = document.cookie.indexOf (";", offset); 
	if (endstr == -1) 
		endstr = document.cookie.length; 
	return unescape(document.cookie.substring(offset, endstr)); 
} 

function getCookie (name) 
{ 
	var arg = name + "="; 
	var alen = arg.length; 
	var clen = document.cookie.length; 

	var i = 0; 
	while (i < clen) 
	{ 
		var j = i + alen; 
		if (document.cookie.substring(i, j) == arg) 
			return getCookieVal (j); 
		i = document.cookie.indexOf(" ", i) + 1; 
		if (i == 0) break; 
	} 
	return null; 
} 

function setCookie (name, value, exp_diff) 
{ 
		 var argv = setCookie.arguments; 
		 var argc = setCookie.arguments.length;
		 
		 var exp = new Date();  // make new date object
		 // 5 minutes expire
		 exp_diff = (exp_diff == null) ? (1000 * 60 * 30) : (1000 * 60 * exp_diff);
		 exp.setTime(exp.getTime() + exp_diff);
	  
 		 var path = (argc > 3) ? argv[3] : null; 
		 var domain = (argc > 4) ? argv[4] : null; 
		 var secure = (argc > 5) ? argv[5] : false;
		 
		 document.cookie = name + "=" + escape (value) + 
		 ((exp == null) ? "" : ("; expires=" + exp.toGMTString())) + "; path=" + 
		 ((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
} 

function isLegalChar(s) 
{
     var RefString = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ _-.@";
     s+="";
     for (var Count=0; Count < s.length; Count++) {
         var TempChar=s.substring (Count, Count+1);
         if (RefString.indexOf(TempChar, 0)==-1) { return false; }
     }
     return true;
}

function CheckFields() 
{
   with (document.login_form) {
   		if(uname.value && !isLegalChar(uname.value)) {
	      alert("Please, re-enter the login.  You have specified invalid characters for this field");
  	      uname.focus();  return false;
	    }
		  
	   // test to see if their browser is enabled for cookie, and complain otherwise
	   setCookie('test_cookie', '1');
	   var test_cookie = getCookie('test_cookie');
	   if (test_cookie != '1') {	
			alert('Please, enable your browser for cookies.  You will not be able to login without it.');
 			return false;
	   }
	   submit();
   }
}

function disclaimer() 
{
    var wnd_params='height=330,width=350,resizable=yes';
	window.open("../disclaimer.html", "discl_wnd", wnd_params);
}

function getParams() 
{
	var idx = document.URL.indexOf('?');
	var params = new Array();
	if (idx != -1) {
	   var pairs = document.URL.substring(idx+1, document.URL.length).split('&');
	   for (var i=0; i<pairs.length; i++) {
	   	   nameVal = pairs[i].split('=');
		   params[nameVal[0]] = nameVal[1];
	   }
	}
	return params;
}

function openPosRep(acct_id) 
{
   with (document.forms[0]) {
         acct_list.value=acct_id;
         submit();
   }
}

function pageReloadClearing() 
{
   with (document.forms[0]) {
         action='cl_act_sum.pl';
         submit();
   }
}
function pageReloadOpenOrdersReport()
{
	verifySession();
    with (document.forms[0]) 
	{
         action='openp_rep.pl';
         submit();
    }
}

function pageReloadOpenOrdersGroup()
{
   with (document.forms[0])
   {
         action='group_openp.pl';
         submit();
   }
}

function pageReloadPI() 
{
   with (document.forms[0]) 
   {
         action='pi_act_sum.pl';
         submit();
   }
}

function backToReportSel() 
{
	parent.main.location.href="../reports.html";         
}

function printme() 
{
	window.print();
}

function checkEmail(txt) 
{
    if (txt == 'n/a') return true;
	if (txt.indexOf("\@")<1){
		alert("The email address seems wrong. Please"+" check the prefix and '\@' sign.");
		return false;
	}
	var idx1=txt.indexOf("\@");
	var idx2=txt.lastIndexOf(".");
	var mid_part = new String(txt.substr(++idx1, (idx2-idx1)));
	if (mid_part.length<1) {
	   alert("The part between \@ and '.' seems to be wrong. Please check the email you have entered.");
	   return false;
	}
	if (txt.indexOf("\.")<1){
		alert("The email address seems wrong. Please"+" check the suffix after the '.' character");
		return false;
	}
	var suffix = txt.substr(++idx2);
	if (suffix.length<1) {
		alert("The email address seems wrong. Please"+" check the suffix after the '.' character");
		return false;
	}
	return true;
}

function ignoreSpaces(string) 
{
		var temp = "";
		string = '' + string;
		splitstring = string.split(" ");
		for(i = 0; i < splitstring.length; i++)
		 	   temp += splitstring[i];
		return temp;
}

function checkPhone(num) 
{
     var RefString = "0123456789()- ";
     num+="";
     for (cnt=0; cnt < num.length; cnt++) {
         var TempChar=num.substring(cnt, cnt+1);
         if (RefString.indexOf(TempChar, 0)==-1) { return false; }
    }
    return true;
}

function validateZip(field) 
{
	var valid = "0123456789-";
	if (field.length!=5 && field.length!=10) {
		alert("Please enter the 5 digit or 5 digit+4 zip code.");
		return false;
	}
	for (var i=0; i < field.length; i++) {
		temp = "" + field.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") {
			alert("Invalid characters in the zip code.  Please try again.");
			return false;
		}
		if (field.length==10 && ""+field.charAt(5)!="-") {
			alert("The hyphen character should be used with a properly formatted 5 digit+four zip code, like '12345-6789'.   Please try again.");
			return false;
		}
	}
	return true;
}

function checkFields_refer() 
{
	with (document.regist_frm) {
		if ((!firstname.value || (firstname.value == ""))) {
			alert("Please, enter the first name"); firstname.focus(); return;
		}	
		if (!lastname.value || (lastname.value == "")) {
			alert("Please, enter the last name"); lastname.focus(); return;
		}
		if (homephone.value && homephone.value != "" && !checkPhone(homephone.value)) {
				alert("The primary phone number you've entered seems wrong.  Please, verify");
				homephone.focus();
	  			return;
		}
		if (workphone.value && (workphone.value != "") && !checkPhone(workphone.value)) {
				alert("The secondary phone number you've entered seems wrong.  Please, verify");
				workphone.focus();
				return;
		}	
		if (email.value && (email.value == "") || !email.value) {
				alert("Please, enter the email");
				email.focus();
				return;
		} 
		var idx = email.value.indexOf('\@');
		if (idx != -1) {
			var re=/\\@/;
			email.value.replace(re, '\@');
		}
		if (!checkEmail(email.value.toLowerCase())) { email.focus();  return; }
		email.value = ignoreSpaces(email.value);
		submit();
	}
}

function chkdate(datestr) 
{
		 var strDate;
		 var strDateArray;
		 var strDay;
		 var strMonth;
		 var strYear;
		 var intday;
		 var intMonth;
		 var intYear;
		 var booFound = false;
		 var strSeparatorArray = new Array("/");
		 var intElementNr;
		 var err = 0;

		 strDate = datestr;

		 if (strDate.length < 1) { return true; }
		 
		 for (intElementNr = 0; intElementNr < strSeparatorArray.length; intElementNr++) {
		 	 if (strDate.indexOf(strSeparatorArray[intElementNr]) != -1) {
			 	strDateArray = strDate.split(strSeparatorArray[intElementNr]);
				if (strDateArray.length != 3) {
				   err = 1;
				   return false;
				}
				else {
					 strMonth = strDateArray[0];
					 strDay = strDateArray[1];
					 strYear = strDateArray[2];
				}
				booFound = true;
			 }
		 }
		 
		 if (booFound == false) { return false; }
		 
		 if (strYear.length <2) { return false; }
		 
		 intday = parseInt(strDay, 10);
		 if (isNaN(intday)) {
		 	err = 2; return false;
		 }
		 
		 intMonth = parseInt(strMonth, 10);
		 if (isNaN(intMonth)) {
		 	err = 3; return false;
		  }
		  
		  intYear = parseInt(strYear, 10);
		  if (isNaN(intYear)) {
		  	 err = 4; return false;
		  }
		  if (intMonth>12 || intMonth<1) {
		  	 err = 5; return false;
		  }
		  if ((intMonth == 1 || intMonth == 3 || intMonth == 5 || intMonth == 7 || intMonth == 8 || intMonth == 10 || intMonth == 12) && (intday > 31 || intday < 1)) {
		  	 err = 6; return false;
		  }
		  if ((intMonth == 4 || intMonth == 6 || intMonth == 9 || intMonth == 11) && (intday > 30 || intday < 1)) {
		  	 err = 7; return false;
		  }
		  if (intMonth == 2) {
		  	 if (intday < 1) {
			 	err = 8; return false;
			 }
			 if (LeapYear(intYear) == true) {
			 	if (intday > 29) {
				   err = 9; return false;
				}
			 }
			 else {
			 	  if (intday > 28) {
				  	 err = 10; return false;
				  }
			 }
		}
		if (intYear > 2050 || intYear <1900) {
		   return false;
		}
		return true;
}

function LeapYear(intYear) 
{
		 if (intYear % 100 == 0) {
		 	if (intYear % 400 == 0) { return true; }
		}
		else {
			 if ((intYear % 4) == 0) { return true; }
		}
		return false;
}

function checkdate(datestr, report) 
{
		 if (chkdate(datestr) == false) {
			alert("That date is invalid.  Please try again.");
			return false;
		}
		
		var today = new Date();
		var checkDt = new Date(datestr);

		var nToday = today.getTime(); var nCheckDt = checkDt.getTime();
		if (checkDt.getTimezoneOffset() > today.getTimezoneOffset()) {
		   nToday += (checkDt.getTimezoneOffset() - today.getTimezoneOffset()) * 60 * 1000;
		}
		else if (checkDt.getTimezoneOffset() < today.getTimezoneOffset()) {
		   nCheckDt += (today.getTimezoneOffset() - checkDt.getTimezoneOffset()) * 60 * 1000;
		}
		//
		//  7/30/03; Dima said that assumably it's only for today or smth 
		//
//		if (nCheckDt > nToday) {
//		   alert("You cannot run a report for date pass today's date.  Please, change the date and try again.")
//		   return false;
//		}
	 	return true;
}

function select_report() 
{
  with (document.reportsel_form)
  {
	if (report_type.selectedIndex ==0) return;
//	session_id =getCookie("session_id");
//alert(getCookie("session_id"));
//	dvalue =getCookie("dvalue");

	if (report_type.options[report_type.selectedIndex].value == "money_line" ||
	    report_type.options[report_type.selectedIndex].value == "comm") 
	{
		action = "rs1.pl";
	}
	else if (report_type.options[report_type.selectedIndex].value == "group_openp") 
	{
		action = "rs2.pl";
	}
	else if (report_type.options[report_type.selectedIndex].value == "pi_act_sum") 
	{
		action = "rs3.pl";
	}
	else if (report_type.options[report_type.selectedIndex].value == "cl_act_sum" ||
	    report_type.options[report_type.selectedIndex].value == "all_orders1") 
	{
		action = "rs4.pl";
	}
	else if (report_type.options[report_type.selectedIndex].value == "open_ord_share" ||
	    report_type.options[report_type.selectedIndex].value == "closed_ord_share" ||
	    report_type.options[report_type.selectedIndex].value == "open_ord_pi" ||
	    report_type.options[report_type.selectedIndex].value == "close_ord_pi") 
	{
		action = "rs5.pl";
	}
	else if (report_type.options[report_type.selectedIndex].value == "monthly_all" ||
	    report_type.options[report_type.selectedIndex].value == "monthly_print") 
	{
		action = "rs6.pl";
	}
//	else if (report_type.options[report_type.selectedIndex].value == "open_com_rep" ||
//	    report_type.options[report_type.selectedIndex].value == "close_com_rep") {
//		action = "rs7.pl";
//	}
	else if (report_type.options[report_type.selectedIndex].value == "monthly" ||
	    report_type.options[report_type.selectedIndex].value == "monthly_nf" ||
	    report_type.options[report_type.selectedIndex].value == "monthly_acc_nf" ||
	    report_type.options[report_type.selectedIndex].value == "monthly_acc") 
	{
		action = "rs8.pl";
	}
	else if (report_type.options[report_type.selectedIndex].value == "weekly") 
	{
		action = "rs9.pl";
	}
	else if (report_type.options[report_type.selectedIndex].value == "weekly_print") 
	{
		 action = "rs10.pl";
	}
	else if (report_type.options[report_type.selectedIndex].value == "dailynet") {
		 action = "rs11.pl";
	}
	else if (report_type.options[report_type.selectedIndex].value == "currentnet") 
	{
		 action = "rs12.pl";
	}
	else if (report_type.options[report_type.selectedIndex].value == "../OCP/Default.aspx")
    {
        	 action = "rs14.pl";
	}
	else 
	{
		 action = "reports.pl";
	}
	submit();
  }
}

function gotoReport() 
{
  with (document.sel_form) {
	 var report_val = new String(report_type.value);
         if (report_val.indexOf("OCP", 0) == -1)
         {
                  action=report_val+ ".pl";
         }

	// if this is prodFS and the user logged in is not the PI
	// for now only allow daily reports till end of june
	//
	// another lovely FS moment: must enable the daily's for user HICKS :)
	// ddl184 - PI
	// ddl70 - sales
	if ((report_val.indexOf("daily_", 0) != -1) && dvalue.value == "E" && 
	    utype_id.value != "DDL184" && utype_id.value != 'DDL70' && user_login.value != 'E26C151804')
	{
		var tmp_FS_dt = new Date("4/01/2003");
		var rep_date = new Date(end_date.value);
		if (rep_date <= tmp_FS_dt)
		{
	   	  alert("This information is currently not available.  Please, try again later.");
	   	  return;
		}
	}
    if ((report_val == "openp_rep" || report_val == "clpos_rep" ||
	    report_val == "all_orders1" || report_val == "open_ord_pi" ||
		report_val == "closed_ord_pi" || report_val == "act_act_c" ||
		report_val == "acct_nsv" || report_val == "client_nsv" ||
		report_val == "close_ord_pi" || report_val == "closed_ord_share" ||
		report_val == "comm" || report_val == "group_openp" ||
		report_val == "open_ord_share")  && 
	   	(!start_date.value || !checkdate(start_date.value))) {
		start_date.focus();
        alert('Please, enter a valid starting date for this report'); 
		return;
    }
	if (report_val == 'acct_stat' && end_date.selectedIndex == 0){
	   alert('Please select a valid month and year for the report');
	   return;
	}
         if(report_val != "cl_act_sum" && report_val != "pi_act_sum" &&  report_val != "open_com_rep" &&  report_val != "close_com_rep" &&
       report_val != "acct_stat" && report_val != "dep_with_sum" &&  (report_val.indexOf("weekly", 0) == -1) &&
       (report_val.indexOf("monthly", 0) == -1) && (!end_date.value || !checkdate(end_date.value)))
         {
                     end_date.focus();
             alert('Please, enter a valid ending date for this report');
             return;
         }
	if (report_val == "all_orders1") {
	   if (cl_account.selectedIndex == 0) {
	   	  alert("You need to select a clearing account.  Please try again.");
		  return;
	   }
	}
	if (report_val == "group_openp") {
	   if (group_list.selectedIndex == 0) {
	   	  alert("You need to select a valid group.  Please try again.");
		  return;
	   }
	}
	if (report_val == 'monthly' || report_val == "monthly_all" || report_val == "monthly_print") {
	   if ( monthly_dt.selectedIndex == 0) {
	   	  alert("Please select a valid month and year for the report");
		  return;
	   }
	}
	if (report_val.indexOf("weekly", 0) != -1) {
	   if ( weekly_dt.selectedIndex == 0) {
	   	  alert("Please select a valid week for the report");
		  return;
	   }
	}
        
         if (report_val.indexOf("OCP", 0) != -1)
         {
                  if (!start_date.value || !checkdate(start_date.value))
                  {
                           start_date.focus();
                           alert('Please, enter a valid starting date for this report'); 
                           return;
                  }
                  document.sel_form.action = "../ocp/Default.aspx?sDate=" + start_date.value + "&edate=" + end_date.value + "&Accid=" + acct_list.value + "&env=" + dvalue.value;
                  //alert(document.sel_form.action);
         }
        submit();
  }
  return;
}

function next_userinfo() 
{
  with (document.user_form) {
       target="_self";
       submit();
  }
}

function openUserInfo_help()
{
  var window_prop="height=270,width=370,resizable=no,scrollbars=no";
  window.open("http://bo.choicefx.com/sc_help.html", "sc_help", window_prop);
}

function checkData_UI()
{
  with (document.user_form) {
  	if (alias.value == '' || !alias.value) {
	   alert('Please enter your login alias');
	   alias.focus(); return;
	} 
  	if (fname.value == '' || !fname.value) {
	   alert('Please enter your first name');
	   fname.focus(); return;
	} 
  	if (lname.value == '' || !lname.value) {
	   alert('Please enter your last name');
	   lname.focus(); return;
	} 
  	if (tel.value == '' || !tel.value) {
	   alert('Please enter your telephone number');
	   tel.focus(); return;
	} 
	if (!checkPhone(tel.value)) {
		alert("The primary telephone number you've entered seems wrong.  Please, enter only digits.");
		tel.focus(); return;
		}
	if ((tel2.value != '' || tel2.value) && (!checkPhone(tel2.value))) {
		alert("The secondary telephone number you've entered seems wrong.  Please, enter only digits.");
		tel2.focus(); return;
		}

	if (fax.value && fax.value != "" && !checkPhone(fax.value)) {
		alert("The fax number you've entered seems wrong.  Please, enter only digits");
		fax.focus(); return;
	}	
  	if (email.value == '' || !email.value) {
	   alert('Please enter your email');
	   email.focus();
	   return;
	} 
	var idx = email.value.indexOf('\@');
	if (idx != -1) {
		var re=/\\@/;
		email.value.replace(re, '\@');
	}
	if (!checkEmail(email.value.toLowerCase())) { email.focus(); return; }
	email.value = ignoreSpaces(email.value);
	user_fl.value=1;
	submit();
	}
}

function userInfo_dataCheck()
{
  with (document.user_form)
  {
         user_fl.value=1;
         submit();
  }
}

function openDetailed_monthly(acct_id) 
{
	// used by the monthly_all.pl script
    with (document.forms[0]) {
		 acct_list.value=acct_id;
		 if (dvalue.value == "E") {
		 	action = "monthly_nf.pl";
		 }
		 else {
		 	  action = "monthly.pl";
		 }
         submit();
    }
}

function pageReload_monthlyAll() 
{
   with (document.forms[0]) {
         action='monthly_all.pl';
         submit();
   }
}
//function pageReload_monthly_print() {
function pageReload_print(action_val) 
{
   with (document.forms[0]) {
         action=action_val;
         submit();
   }
}
//function monthlyPrint(sel_env) {
function printReport(sel_env, action_value) 
{
		 with (document.print_report) {
		 	var atLeastOne=0;
			for (var i=0; i < elements.length; i++) {
			 	if (elements[i].type == 'checkbox' && elements[i].name != 'expand_all' && elements[i].checked == true) {
				 	atLeastOne++;
					i=elements.length;
				}
			}
			if (!atLeastOne)
			{
			 	alert("Please select at least one user on the left before clicking on the Print button");
				return;
			}
		 	action=action_value;
			submit();
		 }
}

function printAllcb() 
{
		with (document.print_report) {
			 var sett=false;
		 	 if (print_all.checked == true) {
			  	 sett=true;
			 }
			  
			 for (var i=0; i < elements.length; i++) {
			 	 if (elements[i].type == 'checkbox' && elements[i].name != 'expand_all')
				 	elements[i].checked = sett;
			 }
		 }
}

function printSingle() 
{
		 with (document.print_report) { 
		 	  if (print_all.checked == true)
			  	 print_all.checked = false; 
		}
}

function ExpandOpenAny(val) 
{
     with (document.forms[0])
     {
	 expand_open.value=val;
         submit();
     }
}

function ExpandOpen(val) 
{
     with (document.daily_form) {
	      expand_open.value=val;
          submit();
     }
}

function ExpandOpen_p1(objName, val) 
{
	 var expand = objName;
     with (document.forms.monthly_p1) 
	 {
	 	 for (var i=0; i < elements.length; i++) 
		 {
	 	  	 if (elements[i].name == objName)
			 {
		 	 	elements[i].value = val;
			}
	 	 }
     	 submit();
     }
}

function PasswordRequest_cf() 
{
	// test to see if their browser is enabled for cookie, and complain otherwise
	var founderr=false;	
	with (document.passwd_frm) {
		if (!founderr && ((email.value == "") || !email.value)) {
				alert("Please, enter your email");
				email.focus();
				founderr = true;
		} 
		if (!founderr && !checkEmail(email.value)) {
			email.focus();
			founderr = true;
		}
	   }
	if (!founderr) document.passwd_frm.submit();
}

function CheckFields_PasswordReset() 
{
	// test to see if their browser is enabled for cookie, and complain otherwise
	setCookie('test_cookie', '1');
	var test_cookie = getCookie('test_cookie');
	if (test_cookie != '1') {	
		alert('Please, enable your browser for cookies.  You will not be able use the Online Backoffice without cookies.');
 		return;
	}
	with (document.passwd_frm) {
		if(fname.value == '') {
			fname.focus(); alert("Please, enter all of the information"); return;
		}
		if (!isLegalChar(fname.value )) {
			fname.focus(); 
			alert("Please, enter all of the information");
 			return;
		}
		if(lname.value == '' || !lname.value) {
			lname.focus();
			alert("Please, enter all of the information");
 			return;
		}
		if (!isLegalChar(lname.value )) {
			lname.focus();
			alert("Please, enter all of the information");
 			return;
		}
		if (((email.value == "") || !email.value)) {
				alert("Please, enter your email");
				email.focus();
	 			return;
		} 
		var idx = email.value.indexOf('\@');
		if (idx != -1) {
			var re=/\\@/;
			email.value.replace(re, '\@');
		}
		email.value = ignoreSpaces(email.value);
		if (!checkEmail(email.value.toLowerCase())) {
			email.focus();
			return;
		}
		submit();
	   }
}

function gotonext() 
{
  with (document.sel_form) {
       target="_self";
//	   action="reports.pl";
	   action="";
       submit();
  }
}

function topHead_GetBranch(branch, env_type, env_name)
{
	env_name = env_name.toUpperCase();
	branch = branch.toUpperCase();
	
	if (branch && (branch.indexOf('ITRADECURRENCY') != -1 || branch.indexOf('ITC') != -1)) 
	{ 
		document.write("<img src='images/topboin_itc.gif'>"); 
	}
	else if (env_name && env_name.indexOf('TRADEPOINT') != -1)
	{ 
		if (env_type == 'DEMO')
			document.write("<img src='images/topboin_apbg-demo.gif'>"); 
		else
			document.write("<img src='images/topboin_apbg-live.gif'>");
	}
	else if (branch && (branch.indexOf('MODEL') != -1 )) 
	{ 
		document.write("<img src='images/topboin_mt.gif'>"); 
	}
	else if (branch && (branch.indexOf('AVIDUS') != -1 )) 
	{ 
		document.write("<img src='images/topboin_avd.gif'>"); 
	}
	else if (branch && (branch.indexOf('VELOCITY') != -1 )) 
	{ 
		document.write("<img src='images/topboin_vel.gif'>"); 
	}
	else if (branch && (branch.indexOf('NYFX') != -1 )) 
	{ 
		document.write("<img src='images/topboin_nyfxlive.gif'>"); 
	}
	else if (env_name == 'SD4x' && env_type == 'LIVE')
	{ 
		document.write("<img src='images/topboin_sd4x.gif'>"); 
	}
	else if (branch && (branch.indexOf('FX_WIN_TRADES') != -1 )) 
	{ 
		if (env_type == 'DEMO')
			document.write("<img src='images/topboin_fxwin.gif'>"); 
		else
			document.write("<img src='images/topboin_fxwin_live.gif'>");
	}
	else if (branch && (branch.indexOf('FOREX_LIQUIDITY') != -1 || branch.indexOf('DAY_TRADING') != -1) )
	{ 
		document.write("<img src='images/topboin_fxlq_live.gif'>"); 
	}
	else if (branch && (branch.indexOf('CBS') != -1))
	{ 
		if (env_type == 'DEMO')
			document.write("<img src='images/topboin_fxcbsdemo.gif'>"); 
		else
			document.write("<img src='images/topboin_fxcbslive.gif'>");
	}
	else if (branch && ((branch.indexOf('RCG') != -1) || (branch.indexOf('LIQUID') != -1)))
	{ 
		if (env_type == 'DEMO')
			document.write("<img src='images/topboin_lecndemo.gif'>"); 
		else
			document.write("<img src='images/topboin_lecnlive.gif'>");
	}
	else if (branch && branch.indexOf('ATLAS') != -1)
	{ 
		if (env_type == 'DEMO')
			document.write("<img src='images/topboin_atlas_demo.gif'>"); 
		else
			document.write("<img src='images/topboin_atlas_live.gif'>");
	}
	else if (branch && ( (branch.indexOf('FCSTONE') != -1) || (branch.indexOf('FC_STONE') != -1) || (branch.indexOf('SEARCH') != -1) || (branch.indexOf('WORLD') != -1)) )
	{ 
		if (env_type == 'DEMO')
			document.write("<img src='images/topboin_fcs_demo.gif'>"); 
		else
			document.write("<img src='images/topboin_fcs_live.gif'>");
	}
	else if (branch && (branch.indexOf('ADVANCED') != -1) ||  (branch.indexOf('SCMFX') != -1) )
	{ 
		if (env_type == 'DEMO')
			document.write("<img src='images/topboin_advm_demo.gif'>"); 
		else
			document.write("<img src='images/topboin_advm_live.gif'>");
	}
	else if (branch && branch.indexOf('FXQQ') != -1)
	{ 
		if (env_type == 'DEMO')
			document.write("<img src='images/topboin_fxqq_demo.gif'>"); 
		else
			document.write("<img src='images/topboin_fxqq_live.gif'>");
	}
	else if (branch && branch.indexOf('MODERN') != -1)
	{ 
		if (env_type == 'DEMO')
			document.write("<img src='images/topboin_mgf.jpg'>"); 
		else
			document.write("<img src='images/topboin_mgf.jpg'>");
	}
	else if (branch && branch.indexOf('DGFX') != -1)
	{ 
		if (env_type == 'DEMO')
			document.write("<img src='images/topboin_gifg_demo.gif'>"); 
		else
			document.write("<img src='images/topboin_gifg.gif'>");
	}
	else if (env_name && branch && (env_name.indexOf('MAREX') != -1 || (env_name.indexOf('CLIENTDEMO') != -1 && branch.indexOf('MAREX') != -1)))
	{ 
		if (env_type == 'DEMO')
			document.write("<img src='images/topboin_mrx-demo.gif'>"); 
		else
			document.write("<img src='images/topboin_mrx-live.gif'>");
	}
	else if (env_name && env_name.indexOf('CFH') != -1 && branch.indexOf('ONEPROFX') == -1)
	{ 
		if (env_type == 'DEMO')
			document.write("<img src='images/topboin_cfh-demo.gif'>"); 
		else
			document.write("<img src='images/topboin_cfh-live.gif'>");
	}
	else if (env_name && env_name.indexOf('CLIENTDEMO') != -1 && branch.indexOf('CFH') != -1)
	{ 
		if (env_type == 'DEMO')
			document.write("<img src='images/topboin_cfh-demo.gif'>"); 
		else
			document.write("<img src='images/topboin_cfh-live.gif'>");
	}
	else if (env_name && env_name.indexOf('CLIENTDEMO') != -1 && branch.indexOf('ONEPROFX') == -1 && branch.indexOf('MAREX') ==-1 && branch.indexOf('CFH') == -1)
	{ 
		document.write("<img src='images/topboin.gif'>"); 
	} 
	else if (branch && branch.indexOf('WAL_CAPITAL') != -1)
	{ 
		if (env_type == 'DEMO')
			document.write("<img src='images/topboin_wal_demo.gif'>"); 
		else
			document.write("<img src='images/topboin_wal_live.gif'>");
	}
	else if (branch && branch.indexOf('GLOBAL_TRADING') != -1)
	{ 
		if (env_type == 'DEMO')
			document.write("<img src='images/topboin_global_demo.gif'>"); 
		else
			document.write("<img src='images/topboin_global_live.gif'>");
	}
	else if (env_name && env_name.indexOf('CAMALIA') != -1)
	{ 
		if (env_type == 'DEMO')
			document.write("<img src='images/topboin_camalia_demo.gif'>"); 
		else
			document.write("<img src='images/topboin_camalia_live.gif'>");
	}
	else if (branch && branch.indexOf('ONEPROFX') != -1)
	{ 
		if (env_type == 'DEMO')
			document.write("<img src='images/topboin_oneprofx_demo.gif'>"); 
		else
			document.write("<img src='images/topboin_oneprofx_live.gif'>");
	}
	else if (branch && (branch.indexOf('CFX') != -1 || branch.indexOf('CTN') != -1))
	{ 
		document.write("<img src='images/topboin_cfx.gif'>"); 
	}
	else 
	{ 
		document.write("<img src='images/topboin.gif'>"); 
	} 
}

function front_GetBranch(branch, env_type, env_name)
{
	env_name = env_name.toUpperCase();
	branch = branch.toUpperCase();
	
	/*
	if (branch && branch.indexOf('ITRADECURRENCY') != -1) 
	{
		document.write("ITradeCurrency Backoffice (LIVE)");
	}
	else if (branch && branch.indexOf('MODEL') != -1) 
	{
		document.write("Model Trading Backoffice (LIVE)");
	}
	else if (branch && (branch.indexOf('FOREX_LIQUIDITY') != -1 || branch.indexOf('DAY_TRADING') != -1) )
	{
		document.write("FX Liquidity Backoffice (LIVE)");
	}
	*/
	if (branch && branch.indexOf('AVIDUS') != -1) 
	{
		document.write("Avidus Backoffice (LIVE)");
	}
	/*
	else if (branch && branch.indexOf('VELOCITY') != -1) 
	{
		document.write("Velocity4X Backoffice (LIVE)");
	}
	*/
	else if (env_name && env_name.indexOf('TRADEPOINT') != -1)
	{ 
		if (env_type == 'DEMO')
			document.write("APBG Backoffice (DEMO)"); 
		else
			document.write("APBG Backoffice (LIVE)"); 
	}

	else if (env_name == 'SD4x' && env_type == "LIVE")
	{
		document.write("SD4X Backoffice (LIVE)");
	}
	else if (branch && branch.indexOf('NYFX') != -1) 
	{
		document.write("NYFX Backoffice (LIVE)");
	}
	else if (branch && branch.indexOf('FX_WIN_TRADES') != -1) 
	{
		if (env_type == 'DEMO')
			document.write("FX Win Trades Backoffice (DEMO)");
		else
			document.write("FX Win Trades Backoffice (LIVE)");
	}
	else if (branch && branch.indexOf('CBS') != -1) 
	{
		if (env_type == 'DEMO')
			document.write("FX CBS Backoffice (DEMO)");
		else
			document.write("FX CBS Backoffice (LIVE)");
	}
	else if (branch && ((branch.indexOf('RCG') != -1) || (branch.indexOf('LIQUID') != -1)))
	{ 
		if (env_type == 'DEMO')
			document.write("LiquidECN Backoffice (DEMO)");
		else
			document.write("LiquidECN Backoffice (LIVE)");
	}
	else if (branch && branch.indexOf('ATLAS') != -1)
	{ 
		if (env_type == 'DEMO')
			document.write("AtlasFX Backoffice (DEMO)");
		else
			document.write("AtlasFX Backoffice (LIVE)");
	}
	else if (branch && ( (branch.indexOf('FCSTONE') != -1) || (branch.indexOf('FC_STONE') != -1) || (branch.indexOf('SEARCH') != -1) || (branch.indexOf('WORLD') != -1)) )
	{ 
		if (env_type == 'DEMO')
			document.write("FCStone FX Clear Backoffice (DEMO)");
		else
			document.write("FCStone FX Clear Backoffice (LIVE)");
	}
	else if (branch && (branch.indexOf('ADVANCED') != -1) || (branch.indexOf('SCMFX') != -1))
	{ 
		if (env_type == 'DEMO')
			document.write("Advanced Markets Backoffice (DEMO)");
		else
			document.write("Advanced Markets Backoffice (LIVE)");
	}
	else if (branch && branch.indexOf('FXQQ') != -1)
	{ 
		if (env_type == 'DEMO')
			document.write("FXQQ ECN Backoffice (DEMO)"); 
		else
			document.write("FXQQ ECN Backoffice (LIVE)"); 
	}
	else if (env_name && branch && (env_name.indexOf('MAREX') != -1 || (env_name.indexOf('CLIENTDEMO') != -1 && branch.indexOf('MAREX') != -1)))
	{ 
		if (env_type == 'DEMO')
			document.write("Webtrader Backoffice (DEMO)"); 
		else
			document.write("Webtrader Backoffice (LIVE)"); 
	}
	else if (branch && branch.indexOf('MODERN') != -1)
	{ 
		if (env_type == 'DEMO')
			document.write("Modern Global Finance LLC Backoffice (DEMO)"); 
		else
			document.write("Modern Global Finance LLC Backoffice (LIVE)"); 
	}
	else if (branch && branch.indexOf('DGFX') != -1)
	{ 
		if (env_type == 'DEMO')
			document.write("FX Trading Platform Backoffice (DEMO)"); 
		else
			document.write("FX Trading Platform Backoffice (LIVE)"); 
	}
	else if (env_name && env_name.indexOf('CFH') != -1 && branch.indexOf('ONEPROFX') == -1 )
	{ 
		if (env_type == 'DEMO')
			document.write("CFH Pro Trader Platform Backoffice (DEMO)"); 
		else
			document.write("CFH Pro Trader Platform Backoffice (LIVE)"); 
	}
	else if (env_name && env_name.indexOf('CLIENTDEMO') != -1 && branch.indexOf('CFH') != -1)
	{ 
		if (env_type == 'DEMO')
			document.write("CFH Pro Trader Platform Backoffice (DEMO)"); 
		else
			document.write("CFH Pro Trader Platform Backoffice (LIVE)"); 
	}
	else if (env_name && env_name.indexOf('CLIENTDEMO') != -1 && branch.indexOf('ONEPROFX') == -1 && branch.indexOf('MAREX') == -1 && branch.indexOf('CFH') == -1)
	{ 
		document.write("Backoffice (DEMO)"); 
	}
	else if (branch && branch.indexOf('WAL_CAPITAL') != -1)
	{ 
		if (env_type == 'DEMO')
			document.write("WalCapFX Platform Backoffice (DEMO)"); 
		else
			document.write("WalCapFX Platform Backoffice (LIVE)"); 
	}
	else if (branch && branch.indexOf('GLOBAL_TRADING') != -1)
	{ 
		if (env_type == 'DEMO')
			document.write("Global Trading Platform Backoffice (DEMO)"); 
		else
			document.write("Global Trading Platform Backoffice (LIVE)"); 
	}
	else if (env_name && env_name.indexOf('CAMALIA') != -1)
	{ 
		if (env_type == 'DEMO')
			document.write("CFX Market Backoffice (DEMO)"); 
		else
			document.write("CFX Market Backoffice (LIVE)"); 
	}
	else if (branch && branch.indexOf('ONEPROFX') != -1)
	{ 
		if (env_type == 'DEMO')
			document.write("One ProFX Backoffice(DEMO)"); 
		else
			document.write("One ProFX Backoffice (LIVE)"); 
	}
	else if (branch && (branch.indexOf('CFX') != -1 || branch.indexOf('CTN') != -1))
	{ 
		if (env_type == 'DEMO')
			document.write("CTN Clearing Backoffice (DEMO)"); 
		else
			document.write("CTN Clearing Backoffice (LIVE)"); 
	}
	else 
	{
		document.write("Backoffice");
	}
}
//-->
