//var path='http://localhost/gadgets';
var path='http://adboox.com';
var css = document.createElement('link');css.rel = 'stylesheet';css.type = 'text/css';css.href = path+"/style_chart.css";
if (typeof css!="undefined") document.getElementsByTagName("head")[0].appendChild(css);
var html='<div style="width:90px;"><img src="'+path+'/images/gap.jpg" border="0" width="90" height="33" id="vb" alt="google analytics"></div>';
document.write(html);
var vish={
	ie:document.all?true:false,
	display:false,
	timer:20,
	alpha:0,
	endalpha:100,
	speed:10,
	id:'vc',
	init:function(){
		$vid('vb').onclick = vish.show.bind(vish);
		//domain='http://vishwavish.com'; 
		domain=domain.replace(/www./,'');   
		domain2=domain.replace('http://','');
		var _d=document.domain;
		chartTracker=chartTracker; //2042_Apr.png
		var heading=(charttype==1)?"Previous Month Visits Of ":"Last 30 Days Visit Of ";
		var html='<div id="vc" style="width:393px; padding:5px; background-color:#F6F6EE; border:1px solid #ccc;" class="normal">';
		html+='<div style="position:relative; top:2px" align="center"><span>'+heading+'<span class="mahroon">'+domain+'</span></span></div>';
		html+='<div style="display:block; background:#F6F6EE;padding:12px;"><div style="display:block; background:#F6F6EE;"><img src="'+path+'/charts/'+chartTracker+'.png" border="0" width="370" height="250" alt="previous month visitors chart"></div></div>';
		html+='<div style="position:static;top:2px; padding-bottom:5px;" align="center"><a href="mailto:info@'+domain2+'?subject=Regarding Advertisements"><img src="'+path+'/images/contact.jpg" border="0" width="185" height="20"></a></div>';
		//html+='<div class="power"><a href="http://www.adboox.com/"><img src="'+path+'/images/adboox.gif" width="313" height="87" border="0" /></a></div>';
		html+='<div class="power"><a href="http://www.adboox.com/">Gadget Created By Adboox.com</a></div>';
		html+='<div id="banner"><script type="text/javascript" src="'+path+'/adboox_i.php?ct='+chartTracker+'&do='+_d+'"></script></div>';
		html+='</div>';
		var divTag = document.createElement("div");
		divTag.innerHTML=html;
		document.body.appendChild(divTag);
		return false;
	},
	browser:function(){
			var bodyWidth = document.documentElement.clientWidth;
			var bodyHeight = document.documentElement.clientHeight;
			if(self.innerHeight){
				bodyWidth = self.innerWidth; 
				bodyHeight = self.innerHeight; 	
			}else if(document.documentElement && document.documentElement.clientHeight){
				bodyWidth = document.documentElement.clientWidth; 
				bodyHeight = document.documentElement.clientHeight;
			}else if(document.body){
				bodyWidth = document.body.clientWidth; 
				bodyHeight = document.body.clientHeight; 
			}
			return [bodyWidth,bodyHeight];
		 },	
		show:function(evt){
			elem=document.getElementById(vish.id);
			//if(vish.display==false){
				var arrSize=vish.browser();
				elem.style.display='block';
				//document.getElementById('vb').src=path+'/images/gam.jpg';
				var x=(arrSize[0]/2)-(585/2);
				var y=(arrSize[1]/2)-(470/2)+Math.max(document.body.scrollTop,document.documentElement.scrollTop);
				elem.style.left=(x+10)+'px';
				elem.style.top=(y-10)+'px';
				clearInterval(elem.timer);
				elem.timer=setInterval(function(){vish.fadepic(1)},vish.timer);
			//}else{
				//vish.hide();	
			//}
			//vish.display=!vish.display;
			return false;
		},
		hide:function(){
			var elem = document.getElementById(vish.id);
			if(elem.style.display!='none'){
			 clearInterval(elem.timer);
			 elem.timer=setInterval(function(){vish.fadepic(-1)},vish.timer);	
			 //document.getElementById('vb').src=path+'/images/gap.jpg';
			}
			return false;
		},
		fadepic:function(d){
			var elem = document.getElementById(vish.id);
			 var a=vish.alpha; 
			 if((a !=  vish.endalpha && d == 1) || (a != 0 && d == -1)){
				 var i=vish.speed;
				 if(vish.endalpha - a < vish.speed && d == 1){
					i= vish.endalpha-a;
				 }else if(vish.alpha < vish.speed && d == -1){
					 i  = a;
				 }
				 vish.alpha = a + (i * d);
				 elem.style.opacity  = vish.alpha * .01;
				 elem.style.filter = 'alpha(opacity=' + vish.alpha + ')';
			 }else{
					clearInterval(elem.timer);
					if(d == -1){elem.style.display = 'none'}
				}
		},
		doit:function(e){
			if (!e) var e = window.event;
			if (e.target) targ = e.target;
			else if (e.srcElement) targ = e.srcElement;
			if (targ.nodeType == 3) targ = targ.parentNode;
			var parent=targ;
			while(1){
				if(!parent.offsetParent){ vish.hide(); break; }
				parent = parent.offsetParent; 
				if((parent.id==vish.id)||targ.id==vish.id) break; else vish.hide();	
			}		
			//if(e.button!=2) vish.hide();
			return;
		}
}//vish
function $vid(id){
	return document.getElementById(id);
}
Function.prototype.bind = function(o, args){
	var fn = this;
	return function(){
		fn.apply(o, args || arguments);
	}
}
window.onload=vish.init;
document.onmousedown=vish.doit;