
var expDays = 10; // number of days the cookie should last
var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));


var expDays2 = 2; // number of days the cookie should last
var exp2 = new Date(); 
exp2.setTime(exp2.getTime() + (expDays2*24*60*60*1000));


function CheckPopup() {	 	
		
	var displayPopup = GetCookie('PS');
	
	if(displayPopup !='Yes')
	{
		/*var page = "../popupsurvey/popupsurvey.asp";
		var windowprops = "width=650,height=500,location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes";
		window.open(page, "", windowprops);	*/	
		TakeSurvey();
	}
}	 

function TakeSurvey()
{
		var page = "../popupsurvey/popupsurvey.asp";
		var windowprops = "width=650,height=500,location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes";
		window.open(page, "", windowprops);
}

function GetCookie (name) {  
	var arg = name + "=";  
	var alen = arg.length;  
	var clen = document.cookie.length;  
	var i = 0; 	
	
	while (i < clen) {    
		var j = i + alen;    
		if (document.cookie.substring(i, j) == arg)      
		return getCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	if(document.cookie == "")		
		return null;
	return 'Yes';
 }
 
function SetCookie (name, value, exp) {  
	
	var argv = SetCookie.arguments;  
	var argc = SetCookie.arguments.length;  
	var expires = (argc > 2) ? argv[2] : null;  
	var path = (argc > 3) ? argv[3] : null;  
	var domain = (argc > 4) ? argv[4] : null;  
	var secure = (argc > 5) ? argv[5] : false;  
	
	var cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
	document.cookie = cookie;
alert(cookie);
}


function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	
	if (endstr == -1)
		endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}

function isChecked(objType){
	var objElement;
	var iChecked;	
	var iAllChecked;	
	var arrList = new Array(10);
	var j;
	
	iChecked = false;
	iAllChecked = false;
	
	var iPrevObj;
	iPrevObj = '';	 
	
	if(objType == 'MR')
	{
		for(j=0; j < arrList.length; j++)
		{
			arrList[j] = '';
		}
	j=0
	}
	
	for(var i=0; i< document.frmPopup.elements.length;i++)
	{
		objElement = document.frmPopup.elements[i];			
		if((objType == 'C' || objType == 'R') && objElement.checked)
		{
			iChecked = true;
			break;
		}		
		if(objType == 'MR' && objElement.type=='radio')
		{
			if(objElement.name != iPrevObj)
			{	
				arrList[j] = objElement.name;
				iPrevObj = objElement.name;	
				j++;					
			}
		}
	}
	if(objType == 'MR')
	{
		iChecked = false;
		for(var i=0; i < document.frmPopup.chk27.length; i++)
		{
			if(document.frmPopup.chk27[i].checked) 
				{
					iChecked = true;
					break;
				}
		}
		if(iChecked == true)
		{
			iChecked = false;
			for(var i=0; i < document.frmPopup.chk28.length; i++)
			{
				if(document.frmPopup.chk28[i].checked) 
					{
						iChecked = true;
						break;
					}
			}
		}
		if(iChecked == true)
		{
			iChecked = false;
			for(var i=0; i < document.frmPopup.chk29.length; i++)
			{
				if(document.frmPopup.chk29[i].checked) 
					{
						iChecked = true;
						break;
					}
			}
		}
		if(iChecked == true)
		{
			iChecked = false;
			for(var i=0; i < document.frmPopup.chk30.length; i++)
			{
				if(document.frmPopup.chk30[i].checked) 
					{
						iChecked = true;
						break;
					}
			}
		}
	}
	
	/*if(objType == 'MR')
	{
		for( var j=0; j < arrList.length; j++)
		{
			arrList[j] = '';
		}
		j=0;
		for(var i=0; i< document.frmPopup.elements.length;i++)
		{
			objElement = document.frmPopup.elements[i];
			
			if(objElement.type=='radio')
			{
				if(objElement.name != iPrevObj)
				{	
					arrList[j] = objElement.name;
					iPrevObj = objElement.name;					
					j++;					
				}
			}
		}
	}*/		
	/*for( var j=0; j < 3; j++)
	{
		var objList = arrList[j];
		objElement = document.getElementsByName(objList);
		if(objElement)
		{
			alert(objElement.Name);
		} 
	}*/
	 
	if(iChecked)
	{
		return true;
	}
	else
	{
		return false;
	}
}