
function scrollListener(){
	stFlashAd.moveTo(document.body.scrollLeft,document.body.scrollTop);
	setTimeout('scrollListener()',100);
	
}


function readyStateListener(){
	if(document.readyState == "complete"){
		if(isNextView()){
			stFlashAd.getDiv().innerHTML = stFlashAd.getObjectCode();
			//setNextView(window[objName].interval);
			if(stFlashAd.position == "relative"){
				scrollListener();
			}
		}
	}else{
		setTimeout('readyStateListener(\'stFlashAd\')',1000);
	}
}

function hidePulldowns(){
	for(var i=0;i<document.forms.length;i++){
		for(var j=0;j<document.forms[i].length;j++){
			if(document.forms[i][j].type.substr(0,6) == "select"){
				document.forms[i][j].style.visibility = "hidden";
			}
		}
	}
}

function showPulldowns(){
	for(var i=0;i<document.forms.length;i++){
		for(var j=0;j<document.forms[i].length;j++){
			if(document.forms[i][j].type.substr(0,6) == "select"){
				document.forms[i][j].style.visibility = "visible";
			}
		}
	}
}
/******************************************

 COOKIES

******************************************/

function isNextView(){
	var cookies, retVal, stPageView, nextViewExists, timeSwitch, pageViewSwitch;
	
	cookies = new stCookies();
	
	//Check time based switch "timeSwitch"
	nextViewExists = cookies.getValue("nextView");
	(nextViewExists == -1)? (timeSwitch = true) : (timeSwitch = false);

	//Check and increment page based switch "pageViewSwitch"
	stPageView = Number(cookies.getValue('pageView'));
	(isNaN(stPageView))? stPageView = 1 : stPageView++;
	cookies.setCookie('pageView',stPageView);
	(stPageView >= stFlashAd.pageViewInterval)? pageViewSwitch = true : pageViewSwitch = false;
	
	//It is time to show an ad, re-init the cookies
	if(timeSwitch && pageViewSwitch){
		//alert("satisfied test");
		cookies.setCookie('nextView','false',stFlashAd.interval);
		cookies.setCookie('pageView',0);
		return true;
	}
	
	// time and page view switches are not yet satisfied
	// If this is the first page view we will show the ad anyway
	if(stFlashAd.showOnFirstLoad && stPageView == 0){
		//alert("showing firestime");
		return true;
	}
	//alert("not showing");
	return false;


}

/******************************************

 FlashAd

******************************************/

FlashAd = function(){
	//this._name = "";
	
	this.flashSrc = "Movie.swf"
	this.flashWidth = "100%";
	this.flashHeight = "100%";
	this.flashID = "flashAdObject";
	this.quality = "autohigh";
	this.position = "relative";
	
	//this.hasGifVersion = false;
	//this.gifSrc = "";
	//this.gifHeight = 0;
	//this.gifWidth = 0;
	
	this.divID = "flashAdDiv";
	this.divLeft = 0;
	this.divTop = 0;
	this.divWidth = "100%";
	this.divHeight = "100%";
	
	//default interval is 1 sec
	this.interval = 1000;
	this.pageViewInterval = 1;
	this.showOnFirstLoad = false;
	
	this.targetURL = "http://karasxxx.com";
	this.targetWindow = "_self";
	this.wmode = "transparent";
	

	
}

function deAmpersand(str){
	return str.split("&").join("þ");
}

FlashAd.prototype.getDivCode = function(){
	var str;
	str = "<div id=\"" + this.divID + "\" style=\"position:absolute; left:" + this.divLeft + "; top:" + this.divTop + "; width:" + this.divWidth + "; height:" + this.divHeight + "; z-index:100000;\"> ";
	str += "</div>";
	return str;
}

FlashAd.prototype.getObjectCode = function(){
	var str;
	str = "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\"" + this.flashWidth + "\" height=\"" + this.flashHeight + "\" codebase=\"http://active.macromedia.com/flash/cabs/swflash.cab\" ID=\"" + this.flashID + "\" >";
	str += "<param name=movie value=\"" + this.flashSrc + "?targetURL=" + deAmpersand(this.targetURL) + "&targetWindow=" + escape(this.targetWindow) + "\">";
	str += "<param name=quality value=" + this.quality + ">";
	str += "<param name=wmode value=" + this.wmode + ">";
	str += "</object>";
	//alert(deAmpersand(this.targetURL));
	return str;
}



FlashAd.prototype.getDiv = function(){
	return document.all[this.divID];
}

FlashAd.prototype.updateLocation = function(){
	var myDiv = this.getDiv();
	//alert(this.divLeft);
	myDiv.style.left = this.divLeft;
	myDiv.style.top = this.divTop;
}

FlashAd.prototype.move = function(xMod,yMod){
	this.divTop += yMod;
	this.divLeft += xMod;
}

FlashAd.prototype.moveTo = function(x,y){
	//alert(x + " " + y);
	this.divTop = y;
	this.divLeft = x;
	this.updateLocation();
}

FlashAd.prototype.init = function(){
	//this._name = instanceName;
	document.write(this.getDivCode());
	readyStateListener(this._name);
	
}



stFlashAd = new FlashAd();