var minusImg = new Image();
minusImg.src = "../admin/img/minus.gif";  
var plusImg = new Image();
plusImg.src = "../admin/img/plus.gif";

var newwin;

function launchwin(winurl,winname,winfeatures,w,h)
{
	//This launches a new window and then
	//focuses it if window.focus() is supported.
	if (screen)
	{
		leftpos = screen.width - w;
		leftpos = leftpos / 2;
		toppos = screen.height -h;
		toppos = toppos / 2;
		leftpos = Math.round(leftpos);
		toppos = Math.round(toppos);
	}

	winfeatures=winfeatures+',left='+leftpos+',top='+toppos;

	newwin = window.open(winurl,winname,winfeatures);
	newwin.focus();
}

function launchwin2(winurl,winname,winfeatures,w,h)
{
	//This launches a new window and then
	//focuses it if window.focus() is supported.
	if (screen)
	{
		leftpos = screen.width - w;
		leftpos = leftpos / 2;
		toppos = screen.height -h;
		toppos = toppos / 2;
		leftpos = Math.round(leftpos);
		toppos = Math.round(toppos);
	}

	winfeatures=winfeatures+'status=no,menubar=no,scrollbars=no,resizable=no,left='+leftpos+',top='+toppos;

	newwin = window.open(winurl,winname,winfeatures);
	newwin.focus();
}

function new_window() 
{ 
	Index = 
window.open('','index','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=600');
} 

function new_window2(url) 
{ 
	Index2 = window.open(url,'index2','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=675,height=500');
}

function new_window3() 
{ 
	Index3 = window.open('','index3','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=600');
}

function CollapsableDiv(imgID, divID)
{
        this.imageID = imgID;
        this.image = null;
        this.divID = divID;
        this.div = null;
        this.init();
}        
CollapsableDiv.prototype.toggle = toggle;
CollapsableDiv.prototype.init = initDiv;
CollapsableDiv.prototype.setup = setupDiv;
        
var isIE = (navigator.userAgent.toLowerCase().indexOf("msie") != -1);

function initDiv()
{
	var thisObj = this;
	if(isIE)
		window.attachEvent("onload", function() { thisObj.setup(); });
	else
		window.addEventListener("load", function() { thisObj.setup(); }, true);
}
        
function setupDiv()
{
        this.div = document.getElementById(this.divID);
		if(this.imageID)
	        this.image = document.getElementById(this.imageID);
}
                
function toggle()
{
	if(!this.div)
	{
		var thisObj = this;
		window.setTimeout(function() { thisObj.toggle(); }, 10);
		return;
	}
        if(this.div.style.display != "")
        {
			if(this.image)
	            this.image.src = minusImg.src;
            this.div.style.display = "";

            document.cookie = this.divID + "=true";
        }
        else
        {
			if(this.image)
	            this.image.src = plusImg.src;
            this.div.style.display = "none";
    
            document.cookie = this.divID + "=false";
        }
}


/** AD ROTATOR **/
function adRotator(zoneID)
{
	this.xmlhttp = null;
	this.zoneID = zoneID;
	
	this.imgID = null;
	this.img = null;
	this.link = null;
	
	var thisObj = this;
	this.cleanup = function () { adRotator_cleanup.call(thisObj); };
	
	this.getAd = function() { adRotator_getAd.call(thisObj); };
	
	this.setup();
}
adRotator.prototype.setup = adRotator_setup;
adRotator.prototype.init = adRotator_init;
adRotator.prototype.handleAd = adRotator_handleAd;

function adRotator_cleanup()
{
	this.xmlhttp = null;
	this.img = null;
	this.link = null;
}

var isIE = (navigator.userAgent.toLowerCase().indexOf("msie") != -1);

function adRotator_setup()
{
	var thisObj = this;
	var init = function() { thisObj.init(); };
	
	if(isIE)
	{
		window.attachEvent("onload", init);
		window.attachEvent("onunload", this.cleanup);
	}
	else
	{
		window.addEventListener("load", init, false);
		window.addEventListener("unload", this.cleanup, false);
	}
}

function adRotator_init()
{
	this.img = document.getElementById(this.imgID);
	this.link = this.img.parentNode;
	
	this.getAd();	
}

function adRotator_getAd()
{
	try
	{
		var thisObj = this;
		try
		{
			if(isIE)
			{
				this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
				this.xmlhttp.onreadystatechange= function () { thisObj.handleAd(); };
			}
			else
			{
				this.xmlhttp = new XMLHttpRequest();
				this.xmlhttp.onload = function () { thisObj.handleAd(); };
			}
		}
		catch (e)
		{
		}
		this.xmlhttp.open("GET", "banner.php?z=" + this.zoneID, true);
		this.xmlhttp.send(null);
	}
	catch (e)
	{
	}
}

function adRotator_handleAd()
{
	if(this.xmlhttp.readyState == 4)
	{
		try
		{
		var xml = this.xmlhttp.responseXML;
		var ad = xml.getElementsByTagName("bannerAd")[0];
		
		var adName = ad.getElementsByTagName("name")[0].firstChild.data;
		var imgUrl = ad.getElementsByTagName("img")[0].firstChild.data;
		var linkUrl = ad.getElementsByTagName("url")[0].firstChild.data;
		var adId = ad.getElementsByTagName("id")[0].firstChild.data;

		//alert("adName: " + adName + "\n\nimgUrl: " + imgUrl + "\n\nlinkUrl: " + linkUrl + "\n\nadId: " + adId);
		
		this.img.src = imgUrl;
		this.img.alt = adName;
		this.img.style.display = "";
		this.link.title = adName;
		this.link.href = "adredir.php?url=" + linkUrl + "&id=" + adId
		
		var thisObj = this;
		
		window.setTimeout(this.getAd, 60000);
		}
		catch (ex)
		{
		}
	}
}

function doVote(frm)
{
        var form = document.getElementById(frm);
        form.submit();
}

