﻿var un;
var ut;
var fn;
var login=0;
var po=0;

function chkLogin()
{
   
    var ck=getCookie("userInfo");
    if(ck==null)
    {
        login=0;
          l1.innerHTML="<a href='login.htm' >Login</a>";
      //    hdLog.docu
    }
    else
    {
    
    var nv=ck.split('&'); 
    
    var i;
    var t1,t2,t3;
  //  for(i=0;i<nv.length;i++)
  //  {
        
        t1 = nv[0].split('=');
           t2 = nv[1].split('=');
                t3 = nv[2].split('=');  
        
  //  }
    //alert(t);
    
    un=t1[1];
    fn=t2[1];
    ut=t3[1];
    
    //alert(un+fn+ut);
    l1.innerHTML="<a href='index.html' onClick='logout();'>Logout</a>";
   //alert(ck);
   
   wnote();
   }
   
}

function getCookie(szName)
{
 	var szValue =	  null;
	if(document.cookie)	   //only if exists
	{
	//    alert(document.cookie);
       	var arr = 		  document.cookie.split((escape(szName) + '=')); 
       	if(2 <= arr.length)
       	{
           	var arr2 = 	   arr[1].split(';');
       		szValue  = 	   unescape(arr2[0]);
       	}
	}
	return szValue;
}


function wnote()
{
    note.innerHTML="<font color='#8C0209' size='3'> <b>Welcome, " +fn+ "!</b></font><br><br>";
}


function logout()
{

var date = new Date();
date.setTime(date.getTime()-1);
var expires = "; expires="+date.toGMTString();
document.cookie = "userInfo"+"="+"acd"+expires+"; path=/";
//window.location = 'index.html';


  //alert(getCookie("userInfo"));
}



function prodSel()
{
    document.cookie("prodInfo");
    
}



function chkPLog( v1, v2)
{
     var ck1=getCookie("userInfo");
   //  alert(ck1);
   
    if(ck1==null)
    {
        login=0;
       //l1.innerHTML="<a href='login.htm' >Login</a>";
       
   //    document.cookie="prod=page="+v2+"&nm=yatin";
 //      alert(v2);
       window.location = "../../log_in.aspx?page="+v2;
       
       
     
    }
   else
    {
        chkLogin();
    //    alert("in else");
       sendAjax(v2, getUName());
    }
    
}


function getUName() {
    return un;

}


function reqQuot(itemName, uname) {
    alert("item: " + itemName + "     userName: " + uname);


}
/*
function sendAjax(pageURL, UserName) {
//    alert("in sendAjax()");
    var xmlhttp;
 //   var str = document.forms[0].txtName.value;
 //   if (str.length == 0) {
 //       document.getElementById("txtHint").innerHTML = "";
 //       return;
 //   }
 //
    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else {// code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
 //   alert(xmlhttp.toString());
    xmlhttp.onreadystatechange = function () {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            //aj.innerHTML = xmlhttp.responseText;
            //   alert(xmlhttp.responseText);
           
        }
    }
    xmlhttp.open("GET", "VisitorLog.aspx?u=" + UserName, true); //+"&product="+pageURL
    xmlhttp.send(); 
 //   alert("hieeeee");
}
*/
