
//var showExitSurvey=true;
var w=null;
var TimetoPopup=10000;

//window.onload=function(evt){
//   
//    var clockStart;
//    var EnterPcomCK=get_cookie("EnterPcom");
//   
//    if (EnterPcomCK==""){
//		//alert("Session cookie empty");
//        var enter_pcom=new Date();
//		clockStart=enter_pcom.getTime();
//        SetCookie('EnterPcom', clockStart);
//        //alert("Set Cookie with clockStart"+clockStart+" start timer");
//        setTimeout("show_survey()",TimetoPopup);
//		}
//    else{
//        var myTime = new Date(); 
//		var timeNow = myTime.getTime();  
//		var timeDiff = timeNow - EnterPcomCK;

//		if (timeDiff>TimetoPopup){
//			show_survey();
//		}else{
//		    //alert("start timer with bal" + ((TimetoPopup-timeDiff)/1000));
//			setTimeout("show_survey()",TimetoPopup-timeDiff);
//			
//		}
//		
//	    
//	}
//	
//}



function show_survey(){
	//reset timer when popclosed
	var enter_pcom=new Date();
	clockStart=enter_pcom.getTime();
	SetCookie('EnterPcom', clockStart);	
	
	 var loc=window.location.toString(); 
 	 var channelAry = new Array();
	channelAry=loc.split('/'); 
	//alert(channelAry[3]);
	channel=channelAry[3];
	
	var donesvy=get_cookie("DoneSurvey");
	if (donesvy!='Y')
	{
		
		var winl = (screen.width-369)/2;
		var wint = (screen.height-345)/2;
       
		//var w_prop='left='+winl+',top='+wint+',width=369,height=400,location=no, menubar=no, resizable=no, scrollbars=no, status=no, titlebar=no, toolbar=no';
		
		if (window.showModalDialog) {
			//alert("IE open");
			//window.showModalDialog('/includes/PopupSurvey/exit_survey.asp?channel='+channel,'popup survey','dialogWidth:300px;dialogHeight:250px;location:no;center:yes;help:no;status:no;scroll:no;');
			w=window.open('/includes/PopupSurvey/scholarship_popup.asp?channel='+channel,'_blank','left='+winl+',top='+wint+',height=250,width=300,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no ,modal=yes');
			if (w) {w.focus();}
			
		} else {
			w=window.open('/includes/PopupSurvey/scholarship_popup.asp?channel='+channel,'_blank','left='+winl+',top='+wint+',height=250,width=300,toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no ,modal=yes');
			if (w) {w.focus();}
		}
		
		
	}else{
				//no pop up exit
	}
}



function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
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;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function SetCookie (name, value) { 
var argv = SetCookie.arguments; 
var argc = SetCookie.arguments.length; 
var expires = (argc > 2) ? argv[2] : null; 
var path = "/"; 
//var path = (argc > 3) ? argv[3] : null; 
//var domain = "";//(argc > 4) ? argv[4] : null; 
//var secure = (argc > 5) ? argv[5] : false; 
//alert (path);
//alert (domain);
//alert (expires);
document.cookie = name + "=" + escape (value) + 
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path));// + 
//((domain == null) ? "" : ("; domain=" + domain)) ;
//((secure == true) ? "; secure" : "");
}
