
var requestLogin;
var requesthere;
var requesthere2;
function getRequestOBJLOGIN() {
	if (window.ActiveXObject) {
		return(new ActiveXObject("Microsoft.XMLHTTP"));
			} else if (window.XMLHttpRequest) {
				return(new XMLHttpRequest());
			} else {
	return(null);
	}
}
function getRequestLoginB1() {
if (window.XMLHttpRequest){     // Object of the current windows
    requestLogin=new XMLHttpRequest();
   } 
   else if (window.ActiveXObject){   // ActiveX version
    requestLogin=   new ActiveXObject("Microsoft.XMLHTTP");//cj month//viewer choice//dedate (skype)
    }
    
		//requestLogin = getRequestOBJLOGIN();
		requestLogin.open("POST", "/mypage/publicview/components/loginBox1.jsp", true);
		requestLogin.onreadystatechange = showchecklog1;
		requestLogin.setRequestHeader("Connection", "close");
	    requestLogin.send(null);
}
function showchecklog1() {	    
	 if ((requestLogin.readyState == 4) && (requestLogin.status == 200)) {
	 responseText=requestLogin.responseText;
	 showdarklayer11();
	 var newdivMY=document.createElement("div");
    newdivMY.className="vclass";
    newdivMY.id="showPOPUPLAYER";
    newdivMY.innerHTML=responseText;
    document.getElementById("addPOPUPHERE").appendChild(newdivMY);
    //alert((screen.width ) / 2-100);
    //alert((screen.height ) / 2);
	var wleft1 = (screen.width ) / 2-300;
    var wtop1 = (screen.height ) / 2-250; 
    center_box1(document.getElementById("addPOPUPHERE"),100,100);
    //document.getElementById("addPOPUPHERE").style.top=wtop1+"px";
    //document.getElementById("addPOPUPHERE").style.left=wleft1+"px";
             }
             //return responseText;
     } 

///
var has_inner1 = typeof(window.innerWidth) == 'number';  
var has_element1 = document.documentElement  
     && document.documentElement.clientWidth;  
 function center_box1(box, width, height)  
 {  
     cleft = has_inner1  
         ? pageXOffset +   
           (window.innerWidth - width)/2  
         : has_element1  
           ? document.documentElement.scrollLeft +   
             (document.documentElement.clientWidth - width)/2  
           : document.body.scrollLeft +   
             (document.body.clientWidth - width)/2;  
   
     ctop = has_inner1  
         ? pageYOffset + (window.innerHeight - height)/2  
         : has_element1  
           ? document.documentElement.scrollTop +   
             (document.documentElement.clientHeight - height)/2  
           : document.body.scrollTop +   
             (document.body.clientHeight - height)/2;  
   
     cleft=cleft-150;
     ctop=ctop-170;
     box.style.left = cleft > 0 ? cleft + 'px' : '0px';  
     box.style.top = ctop > 0 ? ctop + 'px' : '0px';  
 }
	



function validate1()
{
 if(removeAllSpaces(document.getElementById("userID1").value)=="")
 {
  alert("Please enter your User Name");
  document.getElementById("userID1").focus();
  return false;
 }
 if(removeAllSpaces(document.getElementById("password1").value)=="")
 {
  alert("Please enter your password");
  document.getElementById("password1").focus();
  return false;
 }
checkLoginData1();
return false; 
}

function checkLoginData1(){
if (window.XMLHttpRequest){     // Object of the current windows
    requesthere=new XMLHttpRequest();
   } 
   else if (window.ActiveXObject){   // ActiveX version
    requesthere=   new ActiveXObject("Microsoft.XMLHTTP");//cj month//viewer choice//dedate (skype)
    }
    
//requesthere = getRequestOBJLOGIN();

 var formdata22="userID="+encodeURI( document.getElementById("userID1").value );
      formdata22=formdata22+"&password="+encodeURI( document.getElementById("password1").value );
      formdata22=formdata22+"&profileID="+encodeURI( document.getElementById("profileID").value );
       //alert(formdata22+":");
		requesthere.open("POST", "/newLogin.do?Method=LoginExistingUserMypage&"+formdata22, true);
 		requesthere.onreadystatechange = isDetailvalid1;
 		requesthere.setRequestHeader("Connection", "close");
	    requesthere.send(null);
	    //return false;
	    //isDetailvalid();

}

function isDetailvalid1() {
	if ((requesthere.readyState == 4) && (requesthere.status == 200)) {

             var responseText = requesthere.responseText;
             //alert(responseText);
             if(responseText=='false'){
              alert('Invalid username/ password');
              
              return false;
              }
              else{
              //window.location=responseText;
              //alert('j');
              
             var  location1=location+"";
             var pen1=location1.split("?");
             if (pen1.length>1){
             window.location=location.pathname+"?"+pen1[1];
             //alert(location.pathname+"?"+pen1[1]);
             }else {
             window.location=location.pathname;
             //alert(location.pathname);
             }
             //alert(window.location);
            //  window.location.reload(true);
              //hidePOPUPLAYER();
              //document.getElementById("signinsignout").innerHTML="<div class='top-right-icon2' ><a href='#' onclick='showLogout()' class='horos1' >Sign out</a></div>";
             
              }
              
           }
             
    
}
	
function showLogout(){ 
window.location="/mypageFriends.do?method=logOut";
/*
//requesthere2=null;
if (window.XMLHttpRequest){     // Object of the current windows
    requesthere2=new XMLHttpRequest();
   } 
   else if (window.ActiveXObject){   // ActiveX version
    requesthere2=   new ActiveXObject("Microsoft.XMLHTTP");//cj month//viewer choice//dedate (skype)
    }
    	//	requesthere2 = getRequestOBJLOGIN();
    	
		requesthere2.open("POST", "/mypageFriends.do?method=logOut", true);
		requesthere2.onreadystatechange = showchecklog2;
		//alert(requesthere2+'/mypageFriends.do?method=logOut');
		requesthere2.setRequestHeader("Connection", "close");
	    requesthere2.send(null);
        // alert(requesthere2);
                
*/
} 
function showchecklog2() {
	if ((requesthere2.readyState == 4) && (requesthere2.status == 200)) {

             var requesttext = requesthere2.responseText;
             window.location="/index.jsp";
             /*
             //alert(requesttext);
              //document.getElementById("signinsignout").innerHTML="<div class='top-right-icon2' ><a href='#' onclick='getRequestLoginB1()' class='horos1' >Sign in</a></div>";
              // alert(location.pathname+"d");
             var  location1=location+"";
             var pen1=location1.split("?");
             if (pen1.length>1){
             window.location=location.pathname+"?"+pen1[1];
             }else window.location=location.pathname;
             // window.location.reload();
            // alert(requesttext);
            */
           }
             
    
}