 // name - name of the cookie 
 // value - value of the cookie 
 // [expires] - expiration date of the cookie 
 // (defaults to end of current session) 
 // [path] - path for which the cookie is valid 
 // (defaults to path of calling document) 
 // [domain] - domain for which the cookie is valid 
 // (defaults to domain of calling document) 
 // [secure] - Boolean value indicating if 
 // the cookie transmission requires a secure transmission 
 // * an argument defaults when it is assigned null as a placeholder 
 // * a null placeholder is not required for trailing omitted arguments 
 function setCookie(name, value, expires, path, domain, secure) { 
 var curCookie = name + "=" + escape(value) + 
 ((expires) ? "; expires=" + expires.toGMTString() : "") + 
 ((path) ? "; path=" + path : "") + 
 ((domain) ? "; domain=" + domain : "") + 
 ((secure) ? "; secure" : "") 
 //      if (!caution || (name + "=" + escape(value)).length <= 4000) 
 if ((name + "=" + escape(value)).length <= 4000) 
 document.cookie = curCookie 
 else 
 if (confirm("Cookie exceeds 4KB and will be cut!")) 
 document.cookie = curCookie 
 } 
  
 // name - name of the cookie 
 // * return string containing value 
 // of specified cookie or null if cookie 
 // does not exist 
 function getCookie(name) { 
 var prefix = name + "=" 
 var cookieStartIndex = document.cookie.indexOf(prefix) 
 if (cookieStartIndex == -1) 
 return null 
 var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + 
 prefix.length) 
 if (cookieEndIndex == -1) 
 cookieEndIndex = document.cookie.length 
 return unescape(document.cookie.substring(cookieStartIndex + 
 prefix.length, 
 cookieEndIndex)) 
 } 
  
 function getLanguage() { 
 var curPath = location.href; 
 var langList = new Array ("en","big5","gb"); 
 var langName = new Array ("ENGLISH","TRAD_CHINESE","SIMP_CHIESE"); 
  
 for(var i=0; i<langList.length; i++) { 
 var index = location.href.indexOf("/"+ langList[i]+"/"); 
 if(index!=-1) { 
 return langName[i]; 
 } 
 } 
 return langName[0]; // default to english 
 } 
  
 function openCertDetails() 
 { 
 var referer = ""; 
 var siteSealImage; 
  
 if (self.sampleReferer) 
 referer = self.sampleReferer; 
 else 
 referer = window.location; 
  
 if (document.images) { 
 siteSealImage = document.images["thawteSiteSeal"] 
 siteSealImage.src="https://www.thawte.com/cgi/server/seal_generator.exe?referer=" + referer 
 } 
  
 certDetailsUrlWithReferer = "https://www.thawte.com/cgi/server/certdetails.exe?referer=" + referer; 
 thewindow = window.open(certDetailsUrlWithReferer, 
 "newWindow", config="height=500,width=516,toolbar=no,menubar=no," + 
 "scrollbars=yes,resizable=no,location=no,directories=no,status=yes"); 
 } 
  
 function validateEmail(email) { 
 var str = email; // email string 
 var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid 
 var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid 
 // Check if email is in correct format 
 if (reg1.test(str) || !reg2.test(str)) { // if syntax is valid 
 return false; 
 } 
 return true; 
 } 
  
 function isIE() { 
 if (navigator.appName != "Microsoft Internet Explorer") { 
 return false; 
 } 
 return true; 
 } 
  
 function switch2(lang) { 
 var curPath = location.href; 
 var langList = new Array ("en","big5","gb"); 
 var currentDate = new Date(); 
  
 // Set language cookies to be good for a year 
 setCookie('LANG', lang, new Date(currentDate.getMilliseconds()+365*24*60*60*1000) 
 , '/', '.datahaven.ie', false); // for IE 
 setCookie('LANG', lang, new Date(currentDate.getMilliseconds()+365*24*60*60*1000) 
 , '/', 'datahaven.ie', false); // for netscape 
  
 for(var i=0; i<langList.length; i++) { 
 var index = location.href.indexOf("/"+ langList[i]+"/"); 
 if(index!=-1) { 
 var newURL = location.href.substring(0,index) + "/" + lang 
 + location.href.substring(index+langList[i].length+1 
 , location.href.length); 
 window.location.replace(newURL); 
 } 
 } 
 } 
  
 function adminWindow(html) 
 { 
 var wwwhtml = 'https://haven9.datahavenltd.com' + html; 
 adminWin = window.open(wwwhtml,"admin", 
 "toolbar=no,status=yes,scrollbars=yes,resizable=no,location=no,screenX=0,screenY=0,width=650,height=450"); 
 } 
  
 function logon(form) 
 { 
 adminWin = window.open("","admin", 
 "toolbar=no,status=yes,scrollbars=yes,resizable=no,location=no,screenX=0,screenY=0,width=650,height=450"); 
 //  form.action='https://' + window.location.host + "/obs/user/logon.do?u=" + form.loginName.value; 
 form.action='https://haven9.datahavenltd.com/obs/user/logon.do?u=' + form.loginName.value; 
 form.target='admin'; 
 return true; 
 } 
///obs/system/logon.do?locale=en'
function logonAdmin(form) 
 { 
 adminWin = window.open("","admin", 
 "toolbar=no,status=yes,scrollbars=yes,resizable=no,location=no,screenX=0,screenY=0,width=650,height=450"); 
 //  form.action='https://' + window.location.host + "/obs/user/logon.do?u=" + form.loginName.value; 
 form.action='https://www.datahaven.ie:8443/obs/system/logon.do?u=' + form.loginName.value; 
 form.target='admin'; 
 return true; 
 } 
  
 function register(html) 
 { 
 var wwwhtml = 'https://www.datahaven.ie:8443' + html; 
 var regWin = window.open(wwwhtml,"register", 
 "toolbar=no,status=no,scrollbars=yes,resizable=no,location=no,screenX=0,screenY=0,width=450,height=320"); 
  
 } 
  
  

