// JavaScript Document
var op = 100;
var browser = "";
var timeoutInterval = 0;
detectBrowser();


function detectBrowser(){
	browser=navigator.appName;
	//alert(browser);
}

function DistributorLogin_onClick(){	
	timeoutInterval = setInterval("descreaseOpacity()",50);	
}
/*
function displayLogin(){
	var x = screen.width;
	var pos = (x-346)/2;
	var ie_pos = pos - 125;
	document.getElementById("error").innerHTML="";
	document.getElementById("login_error").innerHTML="";
	if(document.getElementById('contentDisplay').style.display != 'block'){
		if(browser == "Netscape" || browser == "Opera"){
			document.getElementById('contentDisplay').style.marginLeft = pos+"px";
		}
		if(browser == "Microsoft Internet Explorer"){
			document.getElementById('contentDisplay').style.marginLeft = ie_pos+"px";
		}
		document.getElementById('contentDisplay').style.display='block';
		//document.getElementById('contentDisplay').style.zIndex='99';
		document.getElementById('page').style.cursor = "crosshair";
		op = 100;				
	}else{
		if(browser == "Netscape" || browser =="Opera"){
			document.getElementById('header').style.opacity = 1.0;
			document.getElementById('container').style.opacity =1.0;
			document.getElementById('footer').style.opacity = 1.0;
			document.getElementById('navwrap').style.opacity = 1.0;
			document.getElementById('contentDisplay').style.display='none';
		}
		if(browser == "Microsoft Internet Explorer"){
			document.getElementById('contentDisplay').style.display = 'none';
			document.getElementById('header').style.filter = 'alpha(opacity=100)';
			document.getElementById('navwrap').style.filter = 'alpha(opacity=100)';
			document.getElementById('container').style.filter = 'alpha(opacity=100)';
			document.getElementById('footer').style.filter = 'alpha(opacity=100)';					
			document.getElementById('page').style.cursor = "default";
			refreshURL = unescape(window.location.pathname);
			//alert(refreshURL);
			window.location.href = refreshURL;
		}
	}
}
*/
function validateLogin(){
	if(document.getElementById('email').value == "" || document.getElementById('password').value == ""){
		//document.getElementById("login_error").innerHTML="";
		document.getElementById("login_error").innerHTML="<center><span style='color:#FF0000;font-weight:bolder; font-size:11px'>Please Provide Email Address And Password</span></center>";
		
		return false;
	}
	else{
		login();
	}
}

function login(){
	params = "?email="+document.getElementById("email").value;
	params += "&password="+document.getElementById("password").value;
	loginXML = new XmlConnector(window.location.protocol+"//"+window.location.hostname+"/includes/loginA.php"+params);
	loginXML.XMLReq.onreadystatechange = login_onDataLoad;
}

function login_onDataLoad(){
	if(loginXML.XMLReq.readyState == 4){	
		document.getElementById("login_error").innerHTML = '<center><img src="/images/indicatorwhite.gif" alt = "Authorization Check"/><br><b>Please Wait ..</b></center>';
        if(loginXML.XMLReq.status  == 200){
			if(loginXML.XMLReq.responseText != "ok"){
				//document.getElementById("error").innerHTML = "";
				document.getElementById("login_error").innerHTML = loginXML.XMLReq.responseText;
				document.getElementById("login_error").innerHTML = document.getElementById("login_error").innerHTML;
			}
			else{
				window.location.href = window.location.protocol+"//"+window.location.hostname+"/index.php?men=81&submen=0";	
			}
		}
	}
}
/*
function descreaseOpacity(){
	op = op - 10;
	_op = op/100 ;
	if(op > 30){
		if(browser == "Netscape" || browser == "Opera"){
			document.getElementById('header').style.opacity = _op;
			document.getElementById('container').style.opacity = _op ;
			document.getElementById('footer').style.opacity = _op;
			document.getElementById('navwrap').style.opacity = _op;
		}
		if(browser == "Microsoft Internet Explorer"){
			document.all['navwrap'].style.filter = "alpha(opacity="+op+")";
			document.all['footer'].style.filter = "alpha(opacity="+op+")";
			document.all['container'].style.filter = "alpha(opacity="+op+")";
			document.all['header'].style.filter = "alpha(opacity="+op+")";
		}	
	}else{
		clearInterval(timeoutInterval);	
		displayLogin();
	}
}*/