aww = parseInt((navigator.userAgent.indexOf("MSIE")!= -1) ? document.body.clientWidth : window.innerWidth);
awh = parseInt((navigator.userAgent.indexOf("MSIE")!= -1) ? document.body.clientHeight : window.innerHeight);

function getad(adid, m, w, h)
{
	//url = 'http://localhost/adserver/ads/getad.php?adid='+adid;
	url = 'http://www.homesharetest.com/adserver/ads/getad.php?adid='+adid;
	switch(m)
	{
		case 'embed' :
		{
			document.write('<iframe style="border:1px solid #cccccc;" frameborder="0" width="'+w+'" height="'+h+'" scrolling="no" marginwidth="0" marginheight="0" src="'+url+'"></iframe>');	
		} break;
		case 'inpage_popup' :
		{
			t=(awh / 2)-(h/2);
			l=(aww / 2)-(w/2);
			document.write('<div name="ad'+adid+'" id="ad'+adid+'" style="font-family:verdana,arial;font-size:11px;font-weight:regular;color:#666666;background:#ffffff;border:1px solid #cccccc;position:absolute;z-index:999;top:'+t+'px;left:'+l+'px;width:'+w+'px;height:'+(h+20)+'px"><div style="float:left;padding-left:6px;">Advertisement</div><div style="margin-bottom:4px;width:40px;float:right"><a href="javascript:;" onclick="document.getElementById(\'ad'+adid+'\').style.display=\'none\'"><span style="font-family:verdana,arial;font-size:11px;font-weight:regular;color:navy;">Close</span></a></div><iframe frameborder="0" width="'+w+'" height="'+h+'" scrolling="no" marginwidth="0" marginheight="0" src="'+url+'"></iframe></div>');	
		} break;
		case 'popup' :
		{
			t=(parseInt(screen.availHeight) / 2) - (parseInt(h) / 2);
			l=(parseInt(screen.availWidth) / 2) - (parseInt(w) / 2);
			var popup = window.open(url,adid,'"left='+l+',top='+t+',width='+w+',height='+h+'"');
		} break;
		case 'popunder' :
		{
			t=(parseInt(screen.availHeight) / 2) - (parseInt(h) / 2);
			l=(parseInt(screen.availWidth) / 2) - (parseInt(w) / 2);
			var popup = window.open(url,adid,'"left='+l+',top='+t+',width='+w+',height='+h+'"');
			popup.blur();
		} break;
	}
}

function getadbycode(adid, m, w, h)
{
	//url = 'http://localhost/adserver/ads/getadbycode.php?adid='+adid;
	url = 'http://www.homesharetest.com/adserver/ads/getadbycode.php?adid='+adid;
	switch(m)
	{
		case 'embed' :
		{
			document.write('<iframe style="border:1px solid #cccccc;" frameborder="0" width="'+w+'" height="'+h+'" scrolling="no" marginwidth="0" marginheight="0" src="'+url+'"></iframe>');	
		} break;
		case 'inpage_popup' :
		{
			t=(awh / 2)-(h/2);
			l=(aww / 2)-(w/2);
			document.write('<div name="ad'+adid+'" id="ad'+adid+'" style="font-family:verdana,arial;font-size:11px;font-weight:regular;color:#666666;background:#ffffff;border:1px solid #cccccc;position:absolute;z-index:999;top:'+t+'px;left:'+l+'px;width:'+w+'px;height:'+(h+20)+'px"><div style="float:left;padding-left:6px;">Advertisement</div><div style="margin-bottom:4px;width:40px;float:right"><a href="javascript:;" onclick="document.getElementById(\'ad'+adid+'\').style.display=\'none\'"><span style="font-family:verdana,arial;font-size:11px;font-weight:regular;color:navy;">Close</span></a></div><iframe frameborder="0" width="'+w+'" height="'+h+'" scrolling="no" marginwidth="0" marginheight="0" src="'+url+'"></iframe></div>');	
		} break;
		case 'popup' :
		{
			t=(parseInt(screen.availHeight) / 2) - (parseInt(h) / 2);
			l=(parseInt(screen.availWidth) / 2) - (parseInt(w) / 2);
			var popup = window.open(url,adid,'"left='+l+',top='+t+',width='+w+',height='+h+'"');
		} break;
		case 'popunder' :
		{
			t=(parseInt(screen.availHeight) / 2) - (parseInt(h) / 2);
			l=(parseInt(screen.availWidth) / 2) - (parseInt(w) / 2);
			var popup = window.open(url,adid,'"left='+l+',top='+t+',width='+w+',height='+h+'"');
			popup.blur();
		} break;
	}
}

function createPopup(title, url, width, height) 
{
	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  winW = window.innerWidth;
	  winH = window.innerHeight;
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winW = document.body.offsetWidth;
	  winH = document.body.offsetHeight;
	 }
	}
	l=(winW/2)-(width/2);
	t=(winH/2)-(height/2);
	var popup = window.open(url,"window",'"resizeable,left='+l+',top='+t+',width='+width+',height='+height+'"');
	//popup.document.write(content); //Write content into it.
}

