// JavaScript Document for empavenue.php

function SymError()
{
  return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
  return (new Object());
}

window.open = SymWinOpen;


// Code No.2
var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_safari = (agt.indexOf("safari") != -1);
var is_nav = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1)
&& (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1)
&& (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1)
&& (!is_safari) );
var is_nav2 = (is_nav && (is_major == 2));
var is_nav3 = (is_nav && (is_major == 3));
var is_nav4 = (is_nav && (is_major == 4));
var is_nav4up = (is_nav && (is_major >= 4));
var is_navonly = (is_nav && ((agt.indexOf(";nav") != -1) ||
(agt.indexOf("; nav") != -1)) );
var is_nav6 = (is_nav && (is_major == 5));
var is_nav6up = (is_nav && (is_major >= 5));
var is_gecko = (agt.indexOf('gecko') != -1);
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1)
&& (!is_safari) );
var is_ie3 = (is_ie && (is_major < 4));
var is_ie4 = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4up = (is_ie && (is_major >= 4));
var is_ie5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5 = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up = (is_ie && !is_ie3 && !is_ie4);
var is_ie5_5up =(is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6 = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
var is_ie6up = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);
var is_opera = (agt.indexOf("opera") != -1);
var is_mac = (agt.indexOf("mac")!=-1);
var is_iemac = (is_ie && is_mac);


current = '://empave.erpanalysts.com/webmail.php';
changessl = 0;
function changeSSL(obj) {
	var formobj = document.getElementById('formobj');

	var thisnew = 'https';
	if(obj.checked != true)
		thisnew = 'http';

	formobj.action = thisnew + current;
	changessl = 1;
}
function doSubmit() {
   loadLogin();
	//set or not set cookie
	if(document.getElementById('public').checked != true) {
		Set_Cookie("FuseLastUser",document.getElementById('user').value);
	}else{
		Delete_Cookie("FuseLastUser");
	}
	if(changessl == 1)
		Set_Cookie("FuseLastSSL",document.getElementById('SSL').checked);
	if(changeversion == 1)
		Set_Cookie("FuseLastVersion",document.getElementById('myversion').selectedIndex);
	

}

function changeDatacenter(obj) {
	var vers = document.getElementById('myversion');
	if(vers.selectedIndex != 0)
		return;

	var pre = 'http';
	//if(document.getElementById('SSL').checked != true)
	//	pre = 'http';

	if(obj.selectedIndex == 0)
		current =  "://empave.erpanalysts.com/webmail.php";
	else if(obj.selectedIndex == 1)
		current =  "://webmail.iad.mailanyone.net/webmail.php";
	else if(obj.selectedIndex == 2)
		current =  "://webmail.kcy.mailanyone.net/webmail.php";
	else if(obj.selectedIndex == 3)
		current =  "://webmail.sjc.mailanyone.net/webmail.php";	
	document.getElementById('formobj').action = pre + current;
}

changeversion = 0;
function changeVersion(obj) {
	var pre = 'https';
	if(document.getElementById('SSL').checked != true)
		pre = 'http';

	if(obj.selectedIndex == 0)
		current =  "://empave.erpanalysts.com/webmail.php";
	else if(obj.selectedIndex == 1)
		current = "://www.mailanyone.net/sq/src/webmail.php";
	else if(obj.selectedIndex == 2)
		current = "://www.mailanyone.net/mobile/src/redirect.php";

	document.getElementById('formobj').action = pre + current;
	changeversion = 1;
}
function Get_Cookie(name) {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
}
                        
function Set_Cookie(name,value,expires,path,domain,secure) {
//alert('set cookie name='+name+' value ='+value);
    document.cookie = name + "=" +escape(value) +
        ( (expires) ? ";expires=" + expires.toGMTString() : "") +
        ( (path) ? ";path=" + path : "") +
        ( (domain) ? ";domain=" + domain : "") +
        ( (secure) ? ";secure" : "");
}
                        
function Delete_Cookie(name,path,domain) {
    if (Get_Cookie(name)) document.cookie = name + "=" +
       ( (path) ? ";path=" + path : "") +
       ( (domain) ? ";domain=" + domain : "") +
       ";expires=Thu, 01-Jan-70 00:00:01 GMT";
}
function loadLogin() {
	var formobj = document.getElementById('formobj');

	var lastUser = Get_Cookie("FuseLastUser");
	var lastVers = Get_Cookie("FuseLastVersion");
	var lastSSL = Get_Cookie("FuseLastSSL");

	if(lastVers == null) {
		//if(is_ie5up || is_nav6up) {
			current = "://empave.erpanalysts.com/webmail.php";
			if(document.getElementById('myversion'))
				document.getElementById('myversion').selectedIndex = 0;
		//}else{
		//	current = "://www.mailanyone.net/sq/src/webmail.php";
		//	if(document.getElementById('myversion'))
		//		document.getElementById('myversion').selectedIndex = 1;
		//}
	}else{
		if(document.getElementById('myversion'))
			document.getElementById('myversion').selectedIndex = lastVers;
		if(lastVers == 1)
			current = "://www.mailanyone.net/sq/src/webmail.php";
		else if(lastVers == 2)
			current = "://www.mailanyone.net/mobile/src/redirect.php";			
	}

	var pre = 'https';
	if(lastSSL != null) {
		if(lastSSL != true) {
			pre = 'http';
			document.getElementById('SSL').checked = false;
		}
	}
	if(lastUser != null) {
		document.getElementById('user').value = lastUser;
		document.getElementById('password').focus();
	}else	
		document.getElementById('user').focus();

	formobj.action = pre + current;
}