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 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 setcookie(name,value,duration){
cookiestring=name+"="+escape(value)+";EXPIRES="+getexpirydate(duration)+"; path=/; domain=.fedex.com;";
document.cookie=cookiestring;
    if(!getcookie(name)){
        return false;
    }else{
        return true;
    }
}

function setsessioncookie(name,value){
cookiestring=name+"="+escape(value)+"; EXPIRES=; path=/; domain=.fedex.com;";
document.cookie=cookiestring;
    if(!getcookie(name)){
        return false;
    }else{
        return true;
    }
}

function deletecookie(name){
cookiestring=name+"=; EXPIRES=Thu, 01-Jan-70 00:00:01 GMT; path=/; domain=.fedex.com;";
document.cookie=cookiestring;
    if(!getcookie(name)){
        return false;
    }else{
        return true;
    }
}

function mot_survey() {
    var motStatus = getcookie('support_mot');
    if (motStatus != "No") {       
    		var randomNumber=Math.floor(Math.random()*21);
    		//alert("randomNumber -> "+randomNumber);
    		//if (randomNumber == 0){
				if (randomNumber <= 10) {
            behind = window.open('/us/officeprint/main/mot_invite.html','quickhelp','width=600,height=400,scrollbars=yes');
            behind.blur();
        }
    }
}

function resetSurvey() {
	deletecookie('support_mot');
	history.go(0);
}

function noToSurvey() {
    _hbLink('No_Survey');
    setcookie('support_mot',"No",9125);
    window.close();
    return true;
}

function yesToSurvey() {
    _hbLink('Yes_Survey');
    setcookie('support_mot',"No",9125);
    window.location.href='http://www.shippinginsights.com/se.ashx?s=6B80A80C44E3860A';
    return true;
}
//mot_survey()

