// JavaScript Document
//alert("Loading wp cookie code");


function setCookiexx(name, value, expire) {
   document.cookie = name + "=" + escape(value)// + ";domain=./worldpac;path=/"
   + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}


function setCookie(name, value, expires, path, domain) {
  var curCookie = name + "=" + escape(value) +
      ((expires) ? "; expires=" + expires.toGMTString() : "") +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "");
//      ((secure) ? "; secure" : "");
  document.cookie = curCookie;
}
// The following function returns a cookie value, given the name of the cookie //
function getCookie(Name) {
   var search = Name + "=";
   if (document.cookie.length > 0) { // if there are any cookies
      offset = document.cookie.indexOf(search);
      if (offset != -1) { // if cookie exists          
	     offset += search.length          ;
		 // set index of beginning of value         
		 end = document.cookie.indexOf(";", offset)      ;    
		 // set index of end of cookie value         
		 if (end == -1)             
		    end = document.cookie.length         ;
		 return unescape(document.cookie.substring(offset, end))
      }    
   }
}
function register1(name) {
   var today = new Date()   
   var expires = new Date()   
   expires.setTime(today.getTime() + 1000*60*60*24*45)   
//   expires.setTime(today.getTime() + 1000*60)   
   setCookie("WPAC_PlasmaTV", name, expires)
}

function register(name) {
   var today = new Date()   
   var expires = new Date()   
   expires.setTime(today.getTime() + 1000*60*60*24*45)   
   var existname = getCookie("WPAC_PlasmaTV");
    if (existname)  { 
	  name = existname + name;
	  setCookie("WPAC_PlasmaTV", name, expires, "/", "worldpac.com")
    } else { 
     setCookie("WPAC_PlasmaTV", name, expires)
    }
}

function checkCookieExist(cid) {
var yourname = getCookie("WPAC_PlasmaTV");
var strYourname = new String(yourname);
offset = strYourname.indexOf(cid);
      if (offset != -1) { // if cookie exists    
		return true;
  } else { //alert("checkCookieExist function - Cookie DOES NOT Exist");
//    var formLink = "registration_test.html?cid="+cid;
    var formLink = "http://www.worldpac.com/imports/registration.php";
    window.open(formLink,'Register','width=640,height=900,scrollbars=yes,status=0,toolbar=0,directories=0,menubar=0,location=0,resizable=1,left=50,top=30');
    return false;
  }
}

function checkCookieExist1(cid) {
//alert("checkCookieExist");
var yourname = getCookie("WPAC_PlasmaTV");
//  if (yourname != null)  { 
  if (yourname == cid)  { 
//    alert("Cookie Exists");
	return true;
  } else { //alert("Cookie DOES NOT Exist");
//    window.open('/voip/wpform/','Register','width=640,height=850,scrollbars=yes,status=0,toolbar=0,directories=0,menubar=0,location=0,resizable=1,left=50,top=30');
    var formLink = "/network/wp_form.html?cid="+cid;
    window.open(formLink,'Register','width=630,height=460,scrollbars=yes,status=0,toolbar=0,directories=0,menubar=0,location=0,resizable=1,left=50,top=30');
    return false;
  }
}

