function openWindow()
{
	open("https://www.genscript.com/ssl-bin/gs_login");
}
function show_it(id)
{
	
	if(getCookie("GSACCOUNTCookie")||getCookie("GSCookie")||getCookie("APPCookie"))
	{
		if(id=="submitflow5")
 		{
 			var e1 = document.getElementById("email");
 			var e2 = document.getElementById("email2");
 
 			if (e1.value != e2.value){
	 			var str="";
				str+='<table cellspacing=0 width=300 style="z-index:200;filter:Alpha(Opacity=88);opacity:.9">';
				str+='<tr>';
				str+='<td width="90%">';
				str+='&nbsp;';
				str+='</td>';
				str+='<td width="10%">&nbsp;';
				str+='</td>';
				str+='</tr>';
				str+='<tr>';
				str+='<td style="font-size: 12pt">';
				str+='Please check your Email.';
				str+='</td>';
				str+='<td>';
				str+='<a onClick="hide_it()"><img src="/images/close.gif" alt="Close" /></a>';
				str+='</td>';
				str+='</tr>';
				str+='</table>';
				
				var obj1 = document.getElementById("popupBoxf");
				obj1.innerHTML=str;
				obj1.style.left = 420;
	 			obj1.style.top = 600;
				obj1.style.visibility = "visible";
				return false; 				
 			}
	
 		}			
		return true;
	}
	else
     	{	
     		var obj = document.getElementById(id);
     		
		var curleftpop = 0;
		var curtoppop = 0;
		if(obj)
		{	
			if (obj.offsetParent)
			{
				while (obj.offsetParent)
				{
					curtoppop += obj.offsetTop;
					curleftpop += obj.offsetLeft;
					obj = obj.offsetParent;
				}
			}
			else
			{
				if (obj.x)
				{
					curleftpop += obj.x;
				}
				if(obj.y)
				{
					curtoppop += obj.y;
				}
			}
		}
		
		if(id=="submitflow")
     		{
     			var str="";
			str+='<table cellspacing=0 width=250 style="z-index:200;filter:Alpha(Opacity=70);opacity:.7">';
			str+='<tr>';
			str+='<td width="95%">';
			str+='&nbsp;';
			str+='</td>';
			str+='<td width="5%">&nbsp;';
			str+='</td>';
			str+='</tr>';
			str+='<tr>';
			str+='<td style="font-size: 8pt">';
			str+='please <a style="cursor:pointer;cursor:hand" onClick="openWindow()"'+'>login</a> first or <a style="cursor:pointer;cursor:hand" onClick="openWindow()"'+');"'+'>register with</a> GenScript!';
			str+='</td>';
			str+='<td>';
			str+='<a onClick="hide_it()"><img src="/images/close.gif" alt="Close" /></a>';
			str+='</td>';
			str+='</tr>';
			str+='</table>';
			
			var obj1 = document.getElementById("popupBoxf");
			obj1.innerHTML=str;
			
			obj1.style.left = curleftpop-50;
     			obj1.style.top = curtoppop;
    			obj1.style.visibility = "visible";
    			return false;	
     		}
     		else if(id=="submitflow1")
     		{
     			
     			
     			var str="";
			str+='<table cellspacing=0 width=250 style="z-index:200;filter:Alpha(Opacity=70);opacity:.7">';
			str+='<tr>';
			str+='<td width="95%">';
			str+='&nbsp;';
			str+='</td>';
			str+='<td width="5%">&nbsp;';
			str+='</td>';
			str+='</tr>';
			str+='<tr>';
			str+='<td style="font-size: 8pt">';
			str+='please <a style="cursor:pointer;cursor:hand" onClick="openWindow()"'+'>login</a> first or <a style="cursor:pointer;cursor:hand" onClick="openWindow()"'+');"'+'>register with</a> GenScript!';
			str+='</td>';
			str+='<td>';
			str+='<a onClick="hide_it()"><img src="/images/close.gif" alt="Close" /></a>';
			str+='</td>';
			str+='</tr>';
			str+='</table>';
			
			var obj1 = document.getElementById("popupBoxf");
			obj1.innerHTML=str;
			
			obj1.style.left = curleftpop-50;
     			obj1.style.top = curtoppop;
    			obj1.style.visibility = "visible";
    			return false;	
     		}
     		else if(id=="submitflow2")
     		{
     			
     			
     			var str="";
			str+='<table cellspacing=0 width=400 style="z-index:200;filter:Alpha(Opacity=88);opacity:.9">';
			str+='<tr>';
			str+='<td width="90%">';
			str+='&nbsp;';
			str+='</td>';
			str+='<td width="10%">&nbsp;';
			str+='</td>';
			str+='</tr>';
			str+='<tr>';
			str+='<td style="font-size: 12pt">';
			str+='please&nbsp;&nbsp; <a style="cursor:pointer;cursor:hand" onClick="openWindow()">login</a>&nbsp;&nbsp; first&nbsp;&nbsp; or&nbsp;&nbsp; <a style="cursor:pointer;cursor:hand" onClick="openWindow()">register with </a> &nbsp;&nbsp;GenScript&nbsp;&nbsp;!';
			str+='</td>';
			str+='<td>';
			str+='<a onClick="hide_it()"><img src="/images/close.gif" alt="Close" /></a>';
			str+='</td>';
			str+='</tr>';
			str+='</table>';
			
			var obj1 = document.getElementById("popupBoxf");
			obj1.innerHTML=str;
			obj1.style.left = curleftpop;
     			obj1.style.top = curtoppop;
    			obj1.style.visibility = "visible";
    			return false;	
     		}
     		else if(id=="submitflow3")
     		{
     			
     			
     			var str="";
			str+='<table cellspacing=0 width=400 style="z-index:200;filter:Alpha(Opacity=88);opacity:.9">';
			str+='<tr>';
			str+='<td width="90%">';
			str+='&nbsp;';
			str+='</td>';
			str+='<td width="10%">&nbsp;';
			str+='</td>';
			str+='</tr>';
			str+='<tr>';
			str+='<td style="font-size: 12pt">';
			str+='please&nbsp;&nbsp; <a style="cursor:pointer;cursor:hand" onClick="openWindow()">login</a>&nbsp;&nbsp; first&nbsp;&nbsp; or&nbsp;&nbsp; <a style="cursor:pointer;cursor:hand" onClick="openWindow()">register with </a> &nbsp;&nbsp;GenScript&nbsp;&nbsp;!';
			str+='</td>';
			str+='<td>';
			str+='<a onClick="hide_it()"><img src="/images/close.gif" alt="Close" /></a>';
			str+='</td>';
			str+='</tr>';
			str+='</table>';
			
			var obj1 = document.getElementById("popupBoxf");
			obj1.innerHTML=str;
			obj1.style.left = curleftpop-50;
     			obj1.style.top = curtoppop;
    			obj1.style.visibility = "visible";
    			return false;	
     		}
     		else if(id=="submitflow4")
     		{
     			
     			
     			var str="";
			str+='<table cellspacing=0 width=400 style="z-index:200;filter:Alpha(Opacity=88);opacity:.9">';
			str+='<tr>';
			str+='<td width="90%">';
			str+='&nbsp;';
			str+='</td>';
			str+='<td width="10%">&nbsp;';
			str+='</td>';
			str+='</tr>';
			str+='<tr>';
			str+='<td style="font-size: 12pt">';
			str+='please&nbsp;&nbsp; <a style="cursor:pointer;cursor:hand" onClick="openWindow()">login</a>&nbsp;&nbsp; first&nbsp;&nbsp; or&nbsp;&nbsp; <a style="cursor:pointer;cursor:hand" onClick="openWindow()">register with </a> &nbsp;&nbsp;GenScript&nbsp;&nbsp;!';
			str+='</td>';
			str+='<td>';
			str+='<a onClick="hide_it()"><img src="/images/close.gif" alt="Close" /></a>';
			str+='</td>';
			str+='</tr>';
			str+='</table>';
			
			var obj1 = document.getElementById("popupBoxff");
			obj1.innerHTML=str;
			obj1.style.left = curleftpop;
     			obj1.style.top = curtoppop;
    			obj1.style.visibility = "visible";
    			return false;	
     		}
     		else if(id=="submitflow5")
     		{
     			var str="";
				str+='<table width="441" height="58" border="0" cellpadding="0" cellspacing="0" background="/images/table_bg.jpg">';
				str+='<tr>';
				str+='<td width="131" height="31">';
				str+='<div  class="note_class">Note:</div>';
				str+='</td>';
				str+='<td width="163">&nbsp;';
				str+='</td>';
				str+='<td width="147">';
				str+='<a onClick="hide_it()><img src="/images/close_li.gif" width="23" height="23" border="0" class="close"></a>';
				str+='</td>';
				str+='</tr>';
				str+='<tr>';
				str+='<td height="26" colspan="3" class="notice">';
				str+='please<a onClick="openWindow()" style="cursor:hand"> login</a> first or <a onClick="openWindow()" style="cursor:hand">register</a> with GenScript!';
				str+='</td>';
				str+='</tr>';
				str+='</table>';
				
				var obj1 = document.getElementById("popupBoxf");
				obj1.innerHTML=str;
				obj1.style.left = curleftpop;
     			obj1.style.top = curtoppop;
    			obj1.style.visibility = "visible";
    			return false;	
     		}
     		else if(id=="submitflow6")
     		{
     			
     			
     			var str="";
			str+='<table cellspacing=0 width=600 style="z-index:200;filter:Alpha(Opacity=88);opacity:.9">';
			str+='<tr>';
			str+='<td width="90%">';
			str+='&nbsp;';
			str+='</td>';
			str+='<td width="10%">&nbsp;';
			str+='</td>';
			str+='</tr>';
			str+='<tr>';
			str+='<td style="font-size: 12pt">';
			str+='please&nbsp;&nbsp; <a style="cursor:pointer;cursor:hand" onClick="openWindow()">login</a>&nbsp;&nbsp; first&nbsp;&nbsp; or&nbsp;&nbsp; <a style="cursor:pointer;cursor:hand" onClick="openWindow()">register with </a> &nbsp;&nbsp;GenScript&nbsp;&nbsp;!';
			str+='</td>';
			str+='<td>';
			str+='<a onClick="hide_it()"><img src="/images/close.gif" alt="Close" /></a>';
			str+='</td>';
			str+='</tr>';
			str+='</table>';
			
			var obj1 = document.getElementById("popupBoxff");
			obj1.innerHTML=str;
			obj1.style.left = curleftpop;
     			obj1.style.top = curtoppop;
    			obj1.style.visibility = "visible";
    			return false;	
     		}
     		else
     		{
     			
			var str="";
			str+='<table cellspacing=0 width=400 style="z-index:200;filter:Alpha(Opacity=88);opacity:.9">';
			str+='<tr>';
			str+='<td width="90%">';
			str+='&nbsp;';
			str+='</td>';
			str+='<td width="10%">&nbsp;';
			str+='</td>';
			str+='</tr>';
			str+='<tr>';
			str+='<td style="font-size: 12pt">';
			str+='please&nbsp;&nbsp; <a style="cursor:pointer;cursor:hand" onClick="openWindow()">login</a>&nbsp;&nbsp; first&nbsp;&nbsp; or&nbsp;&nbsp; <a style="cursor:pointer;cursor:hand" onClick="openWindow()">register with </a> &nbsp;&nbsp;GenScript&nbsp;&nbsp;!';
			str+='</td>';
			str+='<td>';
			str+='<a onClick="hide_it()"><img src="/images/close.gif" alt="Close" /></a>';
			str+='</td>';
			str+='</tr>';
			str+='</table>';
			
			var obj1 = document.getElementById("popupBox");
			obj1.innerHTML=str;
			obj1.style.left = curleftpop-100;
     			obj1.style.top = curtoppop;
    			obj1.style.visibility = "visible";
    			return false;	
    		}
    	}
}
//Add by CuiLichun 2008-11-26
 function show_it_1(id)
{
	if(getCookie("GSACCOUNTCookie")||getCookie("GSCookie")||getCookie("APPCookie"))
	{
	return true;
	}else{
		var curleftpop=document.getElementById(id).offsetLeft;
		var curtoppop=document.getElementById(id).offsetTop;
		if(id=="submitflow2"){
			if (window.navigator.userAgent.indexOf("MSIE")>=1)
			{
				curleftpop=curleftpop+350;
				curtoppop=curtoppop+110;
			}else
			if (window.navigator.userAgent.indexOf("Firefox")>=1)
			{
			
			}
		}
		var obj1 = document.getElementById("popupBoxf");
		
		obj1.style.left = curleftpop+"px";
		obj1.style.top = curtoppop+"px";
    	obj1.style.visibility = "visible";
    	return false;	
		}
}
function hide_it()
{
	if(document.getElementById("popupBoxf"))
		document.getElementById("popupBoxf").style.visibility = "hidden";
	
	if(document.getElementById("popupBox"))
     		document.getElementById("popupBox").style.visibility = "hidden";
     	if(document.getElementById("popupBoxff"))
     		document.getElementById("popupBoxff").style.visibility = "hidden";	
}

function psort(id)
{
	var obj = document.getElementById(id);
    var curleftpop = 0;
	var curtoppop = 0;
	if(obj)
	{	
		if (obj.offsetParent)
		{  
			while (obj.offsetParent)
			{

				curtoppop += obj.offsetTop;
				curleftpop += obj.offsetLeft;
			//	alert(curtoppop);
			//	alert(curleftpop);
				
				obj = obj.offsetParent;			
			}
			
		}
		else
		{
			if (obj.x)
			{
				curleftpop += obj.x;
			}
			if(obj.y)
			{
				curtoppop += obj.y;
			}			
		}
	}
	
	
	if(id=="p_sort")
    { 
    	var str="";
		str+='<div id="table_class">';
				str+='<div class="close_img">';
				str+='<a onClick="hide_psort()"><img src="/images/close_li.gif" width="23" height="23" alt="Close"></a>';
				str+='</div>';
				str+='<div class="note_class">Note</div>';
				str+='<div class="notice" id="noticeHidden">';
				str+='<div id="loginNotice"></div>';
				str+='<div id="login" class="loginBox"></div>';
				str+='</div>';
			//	str+='<div id="loginNotice"></div>';
				str+='</div>';
		
		var obj1 = document.getElementById("popupBoxf");
		obj1.innerHTML=str;
		document.getElementById("loginNotice").innerHTML = 'Please<a onClick="showLogin()" style="cursor:pointer;cursor:hand"> login</a> first or <a onClick="openWindow()" style="cursor:pointer;cursor:hand">register</a> in GenScript!';
		HM_UserAgent = navigator.userAgent;
		HM_FIREFOX = (navigator.userAgent.indexOf("Firefox") != -1);
		HM_IE = (navigator.userAgent.indexOf("MSIE") != -1)
		if(HM_IE)
		{
			curleftpop = curleftpop - 150;
			curtoppop = curtoppop - 20;
			obj1.style.left = curleftpop+'px';
			obj1.style.top = curtoppop+'px';
		}
		else if(HM_FIREFOX)
		{
			curleftpop = curleftpop - 150;
			curtoppop = curtoppop - 20;
			//alert(curtoppop);
			//alert(curleftpop);
			obj1.style.left = curleftpop+'px';
			obj1.style.top = curtoppop+'px';
		}
			
				
    	obj1.style.visibility = "visible";
    	
    	return false;	
    }
}

function hide_psort()
{
	var temp =  document.getElementById("popupBoxf");
	if(temp)
	{
		temp.style.visibility = "hidden";
	}
	var login =  document.getElementById("login");
	login.style.visibility = "hidden";
}
function showLogin()
{
	var str="";
		str+='<html><head><body><table>';
		str+='<tr><td class="login_bold">User Email :</td><td><input type=text name="mail" id="mail" class="login_input"></td>';
		str+='<td>&nbsp;</td><td rowspan="2"><input type="image" name="submit" value="submit" src="/images/login_image.gif" onClick="checkLogin()"></td></tr>';
		str+='<tr><td  class="login_bold">Password :</td><td><input type=password name="pass" id="pass" class="login_input"></td></tr>';
		
		str+='</table></body></html>';
	
	var obj1 = document.getElementById("login");
		obj1.innerHTML=str;
					
//		obj1.style.left = curleftpop;
//    	obj1.style.top = curtoppop;
		obj1.style.top = "43px";
		obj1.style.left = "80px";
//    	alert (obj1.style.top);
//		alert (obj1.style.left);
    	obj1.style.visibility = "visible";
    	return false;	
}

function checkLogin()
{

	//var noticeHidden = document.getElementById('noticeHidden');
	//noticeHidden.style.display = "none";
	
 	var notice = document.getElementById('loginNotice');
        notice.innerHTML = 'Please waiting...';

	var mail = document.getElementById('mail');
   	var pass = document.getElementById('pass');
	
	var mail_content = mail.value;
	var pass_content = pass.value;
	if(mail_content != "" || pass_content != "")
	{
		new Ajax.Request
		(
			'/cgi-bin/checkLogin.cgi',
        	{
        		method: 'post', 
        		parameters: 'mail='+mail_content+'&pass='+pass_content,
        		onFailure: showError,
        		onSuccess: function show(ajaxRequest) 
					{
						var result = ajaxRequest.responseText;
						
						if(result!=0)
						{   
							//var noticeHidden = document.getElementById('noticeHidden');
							//noticeHidden.style.visibility = "hidden";
							var login = document.getElementById('login');
							login.style.visibility = "hidden";
							var loginNotice = document.getElementById('loginNotice');
							loginNotice.innerHTML='Successful login! You can continue your operation.<br><Font color=black>This prompt will be closed in 5 seconds ...</Font>';

							clock();
							return true;
						}
						else
						{
							var notice = document.getElementById('loginNotice');
							notice.innerHTML='<span style="color:#FF0000;">Warning: User Email or Password is wrong!</span>';
							var login = document.getElementById('login');
							login.style.visibility = "hidden";
							showLogin();
							
							document.getElementById("mail").value=mail_content;
							return false;
						}
					}
				
			}
		);
     }
	return false;
	
}
function showError(xx)
{
	//alert(xx.responseText);	
}

function clock()
{
	setTimeout("b()",5000);	
}
function b()
{
	var divObj = document.getElementById('popupBoxf');
	divObj.style.visibility = "hidden";	
}

