/******************************************
* DHTML Ad Box (By Matt Gabbert at http://www.nolag.com)
* Visit http://www.dynamicdrive.com/ for full script
* This notice must stay intact for use
******************************************/

var ns=(document.layers);
var ie=(document.all);
var w3=(document.getElementById && !ie);
var calunit=ns? "" : "px"
var msg;
var timeouts = new Array();
var num_timeouts = 0;
var LinksArray = null;

function initAd(table_width, table_height, new_width, new_height, divid, scrolla){
	if(!ns && !ie && !w3) return;
	if(ie)		adDiv=eval('document.all.sponsorAdDiv_id_' + divid + '.style');
	else if(ns)	adDiv=eval('document.layers["sponsorAdDiv_id_' + divid + '"]');
	else if(w3)	adDiv=eval('document.getElementById("sponsorAdDiv_id_' + divid + '").style');
	
	var adDiv = document.getElementById("sponsorAdDiv_id_" + divid).style;
	
	if (ie||w3)
	adDiv.visibility="visible";
	else
	adDiv.visibility ="show";
	var obj 			= 	document.getElementById("imgtable_id_" + divid);
	msg = "";
	var img = document.getElementById("img_id_" + divid);
			img.style.width = "0px";
			img.style.height = "0px";
			img.style.visibility = "hidden";
		
	showAd(table_width, table_height, new_width, new_height, divid, scrolla);
}
function showAd(table_width, table_height, new_width, new_height, divid, scrolla){

	var adDiv = document.getElementById("sponsorAdDiv_id_" + divid).style;
	var browserHeight = 0;
	
	if (ie){documentWidth  =truebody().offsetWidth/2+truebody().scrollLeft-20;
	documentHeight =truebody().offsetHeight/2+truebody().scrollTop-20;
	browserHeight = truebody().offsetHeight;}	
	else if (ns){documentWidth=window.innerWidth/2+window.pageXOffset-20;
	documentHeight=window.innerHeight/2+window.pageYOffset-20;
	browserHeight = window.innerHeight;} 
	else if (w3){documentWidth=self.innerWidth/2+window.pageXOffset-20;
	documentHeight=self.innerHeight/2+window.pageYOffset-20;
	browserHeight = self.innerHeight;} 
	
	adDiv.left=documentWidth-(table_width/2)+calunit;
	if(scrolla == 0)
		adDiv.top =documentHeight-(table_height/2)+calunit;
	else
		adDiv.top =documentHeight-((browserHeight) - table_height/2 - 120)+calunit;
	
			
	var obj 			= 	document.getElementById("imgtable_id_" + divid);
	if (ie||w3)
	adDiv.visibility="visible";
	else
	adDiv.visibility ="show";
	
	/*
	var background1 	= 	document.getElementById("background1");
	var background2 	= 	document.getElementById("background2");
	var background3 	= 	document.getElementById("background3");
	var background4 	= 	document.getElementById("background4");
	var background5 	= 	document.getElementById("background5");
	*/
	
	
	/*
	setOpacity(background1, 80);
	setOpacity(background2, 80);
	setOpacity(background3, 80);
	setOpacity(background4, 80);
	setOpacity(background5, 80);
	*/
	
	setOpacity(obj, 80);
	
	
	if(new_height < (table_height + 15)) {
		obj.style.height 	= 	new_height + "px";
		
		++num_timeouts;
		timeouts[num_timeouts-1] = setTimeout("showAd(" + table_width + "," + table_height + "," + (new_width) + "," + (new_height + 35) + "," + divid + "," + scrolla + ")",40);
	} else {
		if(new_width < (table_width + 15)) {
			obj.style.width 	= 	new_width + "px";
			
			++num_timeouts;
			timeouts[num_timeouts-1] = setTimeout("showAd(" + table_width + "," + table_height + "," + (new_width + 35) + "," + (new_height) + "," + divid + "," + scrolla + ")", 40);
		} else {
			
			var img = document.getElementById("img_id_" + divid);
			img.style.width = table_width + "px";
			img.style.height = table_height + "px";
			img.style.visibility = "visible";
			
			++num_timeouts;
			
			//alert(scrolla);
			if(scrolla == 0)
			timeouts[num_timeouts-1] = setTimeout("showAd(" + table_width + "," + table_height + "," + (new_width) + "," + (new_height) + "," + divid + "," + scrolla + ")",1);
		}
	}
	
}
function closeAd(divid){
	
	var adDiv = document.getElementById("sponsorAdDiv_id_" + divid).style;
	
	if (ie||w3)
		adDiv.visibility="hidden";
	else
		adDiv.visibility ="hidden";
		
	var fullscreendiv_id 			= 	document.getElementById("fullscreendiv_id");
	fullscreendiv_id.style.visibility 	= "hidden";
	var obj 			= 	document.getElementById("imgtable_id_" + divid);
	obj.style.height 	= 	"10px";
	obj.style.width 	= 	"10px";
	obj.style.visibility = "hidden";
	
	var img = document.getElementById("img_id_" + divid);
			img.style.width = "0px";
			img.style.height = "0px";
			img.style.visibility = "hidden";
			
	//set the array and the variable back to the default
	//delete all the open timeouts!
	var i;
	for(i=0; i<timeouts.length; i++) {
		clearTimeout(timeouts[i]);
	}
	
	num_timeouts = 0;

}

function truebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function enlarge(table_width, table_height, new_width, new_height, divid, scrolla) {
	
	if(LinksArray != null) {
		for(i=0; i<LinksArray.length; i++) {
			closeAllMenus(i);
		}
	}
	var body = document.getElementById("body");
	var content = "<div class=\"div_wrapper\" id=\"fullscreendiv_id\"></div>";
	content += body.innerHTML;
	body.innerHTML = content;
	
	var docHeight	= 	getDocHeight();
	var fullscreendiv_id	= 	document.getElementById("fullscreendiv_id");
	fullscreendiv_id.style.visibility 	= "visible";
	if(docHeight > 768)
		fullscreendiv_id.style.height		= docHeight + "px";
	else
		fullscreendiv_id.style.height		= 1024 + "px";
	setOpacity(fullscreendiv_id, 80);
	
	var img = document.getElementById("img_id_" + divid);
	img.style.width = "0px";
	img.style.height = "0px";
	img.style.visibility = "hidden";
	
	var obj 			= 	document.getElementById("imgtable_id_" + divid);
	obj.style.visibility = "visible";
	
	initAd(table_width, table_height, new_width, new_height, divid, scrolla);
	
}

function setOpacity(obj, opacity) {
	opacity = (opacity == 100)?99.999:opacity;

	// IE/Win
	obj.style.filter = "alpha(opacity:"+opacity+")";

	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = opacity/100;

	// Older Mozilla and Firefox
	obj.style.MozOpacity = opacity/100;

	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = opacity/100;
}

function getDocHeight() {
	var docHeight;
	if (typeof document.height != 'undefined') {
	docHeight = document.height;
	}
	else if (document.compatMode && document.compatMode != 'BackCompat') {
	docHeight = document.documentElement.scrollHeight;
	}
	else if (document.body && typeof document.body.scrollHeight !=
	'undefined') {
	docHeight = document.body.scrollHeight;
	}
	return docHeight;
}


//onload=initAd;
//End-->
