﻿function setcookie(name,value,duration){
cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration);
document.cookie=cookiestring;
}

function getcookie(cookiename) {
 var cookiestring=""+document.cookie;
 var index1=cookiestring.indexOf(cookiename);
 if (index1==-1 || cookiename=="") return ""; 
 var index2=cookiestring.indexOf(';',index1);
 if (index2==-1) index2=cookiestring.length; 
 return unescape(cookiestring.substring(index1+cookiename.length+1,index2));
}

function getexpirydate( nodays){
var UTCstring;
Today = new Date();
nomilli=Date.parse(Today);
Today.setTime(nomilli+nodays*24*60*60*1000);
UTCstring = Today.toUTCString();
return UTCstring;
}

function setPartner(form)
 {                     
    var RefID = getcookie('RefPageID');

    if(RefID != '')
	 {
	   form.PartnerRefsrc.value = RefID;
	 }

 }    

var directory = "";
var RefPageID = directory;

if(RefPageID == "")
 {
   var ref = getcookie("RefPageID");
   if(ref == "" || ref == "NONE")
    {
      var r = document.location.toString();
      var index = r.indexOf("=");
      if(index !=-1)
      RefPageID = r.substr(index+1,r.length-index);
      else
      RefPageID = "NONE";
    }
    
    else
    RefPageID = ref;    
 }
    
setcookie("RefPageID",RefPageID,60);