// JavaScript Document
//alert("Loading wp cookie code");
var formLink = "wp_form.html";
//register("voip_whitepaper");

function setCookie(name, value, expire) {
   document.cookie = name + "=" + escape(value)
   + ((expire == null) ? "" : ("; expires=" + expire.toGMTString()))
}

// 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 register(name) {
// alert("Writing Cookie to client PC");   
   var today = new Date()   
   var expires = new Date()   
   expires.setTime(today.getTime() + 1000*60*60*24*45)   
//   expires.setTime(today.getTime() + 1000*60)   
   setCookie("3Com_VoIP_WhitePapers", name, expires)
}

function checkCookieExist() {
var yourname = getCookie("3Com_VoIP_WhitePapers");
  if (yourname != null)  { 
//    alert("Cookie Exists");
	return true;
  } else {
//    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');
    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;
  }
}
