function px(w, h){document.write('<img src="img/px.gif" width="' + w  + '" height="' + h + '"/>')}

function openWindow(url, width, height){
	var style = 'top=200,left=300,screenX=0,screenY=800,width=' + width + ',height='+ height +',resizable=no,scrollbars=no,dependent=yes,titlebar=no,toolbar=no'
	window.open(url, 'Popup',style);
}

function DownloadFile(filename, fileurl) 
{
	var ifr_src = 'Download.aspx?filename=' + escape(filename) + '&fileurl=' + escape(fileurl);
	var ifr = document.getElementById('ifrDownload');
	
	if (!ifr) return
	ifr.src = ifr_src;
}

function ShowUrl(url, popup, style) 
{
	if (popup=1)
	{
		if (style == null || style=='default')
			style = 'menubar=yes, titlebar=no, toolbar=no';
		window.open(url, 'Popup', style);
	}
	else
	{
		window.location = url;
	}
	
}

function Vote(frm, Id, op) 
{
	var site = document.getElementById('SqlSite').value;	
	var i, vote;
	var v = 0;

	var cookiename = "poll" + Id;
	
	if (op == 1 && frm != null)
	{		
		vote=-1;
		for (i = 0; i <= frm.Vote.length - 1; i++) {
			if (frm.Vote[i].checked) 
			{
				v = 1; 
				vote = frm.Vote[i].value
			}
		}
		if (vote==-1) return;
	}
		
	if (op > 0 && readCookie(cookiename) == 1) {
		var url = 'default.aspx?SqlSite=' + site + '&SqlPage=poll&CpPollId=' + Id + '&CpPollResultId=' + vote + '&Checked=1';
		window.open(url, "windowpoll", "screenX=50,screenY=50,width=415,height=265,resizable=0,scrollbars=1,dependent=0")
		return
	}
	
	if (op > 0 && frm == null) {
		v = 1;
		vote = op;
	}

	if (v == 1) 
	{
		writeCookie(cookiename, 1, 100000);
		var url = 'default.aspx?SqlSite=' + site + '&SqlPage=poll&CpPollId=' + Id + '&CpPollResultId=' + vote  + '&Checked=0';
		window.open(url, "windowpoll", "screenX=50,screenY=50,width=415,height=265,resizable=0,scrollbars=1,dependent=0")
	}
	else 
	{
		var url = 'default.aspx?SqlSite=' + site + '&SqlPage=poll&CpPollId=' + Id;
		window.open(url, "windowpoll", "screenX=50,screenY=50,width=415,height=265,resizable=0,scrollbars=1,dependent=0")
	}
}

function readCookie(name) 
{

	var namearg = name + "=";
	var nlen = namearg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + nlen;
		if (document.cookie.substring(i, j) == namearg) {
			var endpos = document.cookie.indexOf (";", j);
			if (endpos == -1) endpos = document.cookie.length;
			return unescape(document.cookie.substring(j, endpos));
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return null;
}

function writeCookie(name, value, expiry) {
	var expdate = new Date();
	if(expiry) { //horas
		expdate.setTime(expdate.getTime() + 1000 * 60 * 60 * expiry);
		document.cookie = name + "=" + escape(value) + "; expires=" + expdate.toGMTString();
	}
	else {
		document.cookie = name + "=" + escape(value);
	}
}

function deleteCookie(name) {
   if (readCookie(name)) {
     document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT";
   }
}

function ChangeCSSClass(id, cssClass) {
	var elem = document.getElementById(id);
	elem.className = cssClass;
}


function PopDestaque( x,y )
{			
	document.getElementById("popup").style.top=y;
	document.getElementById("popup").style.left=x;							
	document.getElementById("popup").style.visibility="visible";	
	go();				
}


function Hide ( divId )
{
	if (!divId) divId ='popup';
	
	eval("document.getElementById('" + divId + "').style.visibility='hidden'");					
}


function go()
{
	valDelay = document.getElementById("delay").value;
	valDelay = valDelay * 1000;
	setTimeout("Hide()",valDelay);	
}


function PopSubscription()
{		
	objWidth = 230;
	objHeight = 100;
	x=  window.screen.width;
	y = window.screen.height;		
	x = (x - objWidth)/2;			
	y = (y - objHeight )/2 ;
	document.getElementById("popupNewsletter").style.top=y;
	document.getElementById("popupNewsletter").style.left=x;							
	document.getElementById("popupNewsletter").style.visibility="visible";
}