// JavaScript Document
	var giveCookies = function(webtrends, country, voted, poll_id) {
	//alert("give cookies called");
		var webtrendsCookie = "";
		var countryCookie = "";
		var votedCookie = false; 
		
		if (webtrends) {
                     webtrendsCookie = getCookie("dcs"); 
                     //alert ("webtredends? "+webtrendsCookie );
                } else {webtrendsCookie="";}
		
		if (country) {
                     countryCookie = getCookie("ingGeoLocation");
                     //alert ("country? "+countryCookie);
                } else {countryCookie="";}


		if (voted && String(poll_id).length > 0) { 
			var tempVoted = getCookie("voted_"+poll_id);
			(tempVoted)? votedCookie = true : votedCookie = false;
                         //alert ("voted? "+votedCookie);
		} else {votedCookie="true";}
		//thisMovie("poll").giveJSCookies(webtrendsCookie,countryCookie,votedCookie);
                  thisMovie("poll").giveJSCookies(votedCookie);
	}

	var thisMovie = function (movieName) {
		if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName];
		} else {
		return document[movieName];

		}
	}
	
	var setVoted = function (poll_id) {
		//alert ("asking to set Cookie for poll: "+poll_id);
		date=new Date;
		date.setMonth(date.getMonth()+1);
		setCookie("voted_"+poll_id,"true",date);
		//alert ("get cookie: "+getCookie("voted_"+poll_id));
	}

	var setCookie = function (name, value) {
		//format: setCookie(name:mandatory, value:mandatory, expires:optional string date, domain:optional cookie avaibility domain, secure:optional https or not (boolean)) 
		var argv = setCookie.arguments;
		var argc = argv.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 tempCookie = name +"="+ escape(value) + ((expires==null) ? "" : ("; expires="+expires.toGMTString()))+((path==null) ? "" : ("; path="+path))+((domain==null) ? "" : ("; domain="+domain))+((secure==true) ? "; secure" : "");
		//alert (tempCookie);
		document.cookie = tempCookie;
	}
	
	var getCookieVal = function (offset) {
		var endstr = document.cookie.indexOf (";", offset);
		if (endstr==-1) endstr = document.cookie.length;
		return unescape(document.cookie.substring(offset, endstr));
	}
		
	var getCookie = function (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;
		}
		return null;
	}
