var pf204652IntervalId = 0;

var pf204652maxHeight = 0;//iframe_height+15+14;

var pf204652minHeight = 15;

var pf204652curHeight = 0;

var ad_pos=0;//position;

var originalTop=0;//iframe_height*-1 -14;

var tempTop=0;//iframe_height*-1 -14;

var Url = {

 

	// public method for url encoding

	encode : function (string) {

		return escape(this._utf8_encode(string));

	},

 

	// public method for url decoding

	decode : function (string) {

		return this._utf8_decode(unescape(string));

	},

 

	// private method for UTF-8 encoding

	_utf8_encode : function (string) {

		string = string.replace(/\r\n/g,"\n");

		var utftext = "";

 

		for (var n = 0; n < string.length; n++) {

 

			var c = string.charCodeAt(n);

 

			if (c < 128) {

				utftext += String.fromCharCode(c);

			}

			else if((c > 127) && (c < 2048)) {

				utftext += String.fromCharCode((c >> 6) | 192);

				utftext += String.fromCharCode((c & 63) | 128);

			}

			else {

				utftext += String.fromCharCode((c >> 12) | 224);

				utftext += String.fromCharCode(((c >> 6) & 63) | 128);

				utftext += String.fromCharCode((c & 63) | 128);

			}

 

		}

 

		return utftext;

	},

 

	// private method for UTF-8 decoding

	_utf8_decode : function (utftext) {

		var string = "";

		var i = 0;

		var c = c1 = c2 = 0;

 

		while ( i < utftext.length ) {

 

			c = utftext.charCodeAt(i);

 

			if (c < 128) {

				string += String.fromCharCode(c);

				i++;

			}

			else if((c > 191) && (c < 224)) {

				c2 = utftext.charCodeAt(i+1);

				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));

				i += 2;

			}

			else {

				c2 = utftext.charCodeAt(i+1);

				c3 = utftext.charCodeAt(i+2);

				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));

				i += 3;

			}

 

		}

 

		return string;

	}

 

}



String.prototype.equalsIgnoreCase=myEqualsIgnoreCase;

String.prototype.equals=myEquals;



function myEquals(arg)

{

        return (this.toString()==arg.toString());

}



function myEqualsIgnoreCase(arg)

{               

        return (new String(this.toLowerCase())==(new String(arg)).toLowerCase());

}



function getstyle_str(iframe_width,str_cwp)

{

	style= "<style type=\"text/css\">* html div#fl813691 {position: absolute; overflow:hidden;top:expression(eval(document.compatMode &&document.compatMode=='CSS1Compat') ?documentElement.scrollTop+(documentElement.clientHeight-this.clientHeight): document.body.scrollTop+(document.body.clientHeight-this.clientHeight));}#coh963846{display:block; height:15px; line-height:15px; width:"+iframe_width+"px;}#coc67178{float:right; padding:0; margin:0; list-style:none; overflow:hidden; height:15px;}			#coc67178 li{display:inline;}			#coc67178 li a{background-image:url("+str_cwp+"images/button.gif); background-repeat:no-repeat; width:30px; height:0; padding-top:15px; overflow:hidden; float:left;}				#coc67178 li a.close{background-position: 0 0;}				#coc67178 li a.close:hover{background-position: 0 -15px;}				#coc67178 li a.min{background-position: -30px 0;}				#coc67178 li a.min:hover{background-position: -30px -15px;}				#coc67178 li a.max{background-position: -60px 0;}				#coc67178 li a.max:hover{background-position: -60px -15px;}#co453569{display:block; margin:0; padding:0; height:123px;  border-style:solid; border-width:1px; border-color:#111 #999 #999 #111; line-height:1.6em; overflow:hidden;}</style>";



return style;



}







function showContentAds(metainfo)

{

	var cont='';

	desc = ""; 

	keyword = ""; 

	for(i=0; i<metainfo.length;i++)

	{

		if(metainfo[i].httpEquiv.equalsIgnoreCase ('Content-Type'))

		{

			 var tmp=metainfo[i].content;

			 var arr1=tmp.split(";");

			 for(var j=0; j<arr1.length;j++)

			 {

					if(arr1[j].substr(1,7).equalsIgnoreCase ("charset"))

					{

						//alert(arr1[j]);

						var arr2=arr1[j].split("=");

						if(arr2.length>=2)

							cont=arr2[1];

					}

			 }

		}

		

		

		if(metainfo[i].name.equalsIgnoreCase ('keywords'))

		{

			keyword=metainfo[i].content;

		}

		if((title=="" ||title.equalsIgnoreCase ("Untitled Document"))&& metainfo[i].name.equalsIgnoreCase ('title'))

		{

			title=metainfo[i].content;

		}

		if(metainfo[i].name.equalsIgnoreCase ('description'))

		{

			desc=metainfo[i].content;

		}

	}

	

	var url=show_ads_url;

	url=url+"?id="+show_ads_id;	

	url=url+"&ht="+iframe_height;	

	url=url+"&blockcount="+block_count;

	url=url+"&content_type="+cont;

	url=url+"&search="+Url.encode(keyword);

	url=url+"&title="+Url.encode(title);

	url=url+"&desc="+Url.encode(desc);

	url=url+"&ref="+Url.encode(ref);

	//alert(url); 

	frame="<iframe frameborder=\"0\" src=\""+url+"\" height=\""+iframe_height+"\" width=\""+iframe_width+"\" scrolling=\"no\" ></iframe>";

	

	document.getElementById("show_ads_"+show_ads_id).innerHTML=frame;

		

}







function showKeywordAds()

{

	var cont='';

	for(i=0; i<metainfo.length;i++)

	{

		if(metainfo[i].httpEquiv.equalsIgnoreCase('Content-Type'))

		{

			 var tmp=metainfo[i].content;

			 var arr1=tmp.split(";");

			 for(var j=0; j<arr1.length;j++)

			 {

					if(arr1[j].substr(1,7).equalsIgnoreCase ("charset"))

					{

						//alert(arr1[j]);

						var arr2=arr1[j].split("=");

						if(arr2.length>=2)

							cont=arr2[1];

					}

			 }

		}

	}



	var url=show_ads_url;

	url=url+"?id="+show_ads_id;	

	url=url+"&ht="+iframe_height;	

	url=url+"&blockcount="+block_count;

	url=url+"&content_type="+cont;

	url=url+"&search="+Url.encode(keyword);

	url=url+"&ref="+Url.encode(ref);

	//alert(url);

	frame="<iframe frameborder=\"0\" src=\""+url+"\" height=\""+iframe_height+"\" width=\""+iframe_width+"\" scrolling=\"no\" ></iframe>";

	document.getElementById("show_ads_"+show_ads_id).innerHTML=frame;

	

}





function showCategoryAds()

{

	var cont='';

	for(i=0; i<metainfo.length;i++)

	{

		if(metainfo[i].httpEquiv.equalsIgnoreCase('Content-Type'))

		{

			 var tmp=metainfo[i].content;

			 var arr1=tmp.split(";");

			 for(var j=0; j<arr1.length;j++)

			 {

					if(arr1[j].substr(1,7).equalsIgnoreCase ("charset"))

					{

						//alert(arr1[j]);

						var arr2=arr1[j].split("=");

						if(arr2.length>=2)

							cont=arr2[1];

					}

			 }

		}

	}



	var url=show_ads_url;

	url=url+"?id="+show_ads_id;	

	url=url+"&ht="+iframe_height;	

	url=url+"&blockcount="+block_count;

	url=url+"&content_type="+cont;

	url=url+"&ref="+Url.encode(ref);

	url=url+"&hostname="+Url.encode(window.location.hostname);

	

			frame="";	

			//alert();

	if(window.position)

	{



		//alert(window.innerHeight);

		var ie=document.all && !window.opera;

		//var dom=document.getElementById

		var iebody=(document.compatMode=="CSS1Compat")? document.documentElement : document.body ;

		ht=(ie)? iebody.clientHeight: window.innerHeight ;//screen.height

		//alert(ht);

		wt=(ie)? iebody.clientWidth : window.innerWidth ;//screen.width

		horiz_center=((wt/2 )- (iframe_width/2))+"px";

		ver_center=((ht/2 )- (iframe_height/2))+"px";

		var sticky=false;

		switch(position)

		{

			case 1:

			frame="<div  id=\"fl813691\"  style=\"z-index:900;position:fixed;_position: absolute;left:0;top:0\" >";

			sticky=true;

			break;

			case 2:

			frame="<div  id=\"fl813691\" style=\"z-index:900;position:fixed;_position: absolute;left:"+horiz_center+";top:0\" >";

			sticky=true;

			break;

			case 3:

			frame="<div  id=\"fl813691\" style=\"z-index:900;position:fixed;_position: absolute;top:0;right:0; \" >";

			sticky=true;

			break;

			

			case 7:

			frame="<div  id=\"fl813691\" style=\"z-index:900;position:fixed;_position: absolute;left:0;bottom:0\" >";

			sticky=true;

			break;

			case 8:

		//	echo "inside switch";

			frame="<div  id=\"fl813691\" style=\"z-index:900;position:fixed;_position: absolute;left:"+horiz_center+";bottom:0\" >";

		//	echo frame;			

			sticky=true;

			break;

			case 9:

			frame="<div  id=\"fl813691\" style=\"z-index:900;position:fixed;_position: absolute;right:0;bottom:0\" >";

			sticky=true;

			break;

			default:

			break;

		}

		if(sticky==true)

			{

			 pf204652maxHeight = iframe_height+15;

			 ad_pos=position;

			 originalTop=iframe_height*-1 ;

			 tempTop=iframe_height*-1 ;			

							

			if(block_count==1)

				{

					var get_str_cwp=get_current_working_path(show_ads_url);

					frame=getstyle_str(iframe_width,get_str_cwp)+frame;

					var expdate = new Date ();

					expdate.setTime(expdate.getTime() + 1000 * 60 * 60 * 5);

					setCookie("inout_adserver_2050_position","inout_adserver_2050_position",expdate);

					//alert("set value");

				}

			

			if(block_count>1)

				{

				var test=getCookie("inout_adserver_2050_position");

						if(test=="inout_adserver_2050_position")

						{

						//alert(test);

						//alert("already set");

						return;

						}

				}

			}

		

	}

	

		if(frame!="")	

			{

				if(position>4)

				{

						 frame+='<div id="coh963846"><ul id="coc67178"><li style="display: inline;" id="pf204652hide"><a class="min" href="javascript:pf204652clickhide();" title="Hide this window"></a></li><li id="pf204652show" style="display: none;"><a class="max" href="javascript:pf204652clickshow();" title="Show this window"></a></li>	<li id="pf204652close"><a class="close" href="javascript:pf204652clickclose();" title="Close this window"></a></li> </ul></div>';

				}

				frame+="<iframe frameborder=\"0\" src=\""+url+"\" height=\""+iframe_height+"\" width=\""+iframe_width+"\" scrolling=\"no\" ></iframe>";

				if(position<4)

				{

					 frame+='<div id="coh963846"><ul id="coc67178"><li style="display: inline;" id="pf204652hide"><a class="min" href="javascript:pf204652clickhide();" title="Hide this window"></a></li><li id="pf204652show" style="display: none;"><a class="max" href="javascript:pf204652clickshow();" title="Show this window"></a></li>	<li id="pf204652close"><a class="close" href="javascript:pf204652clickclose();" title="Close this window"></a></li> </ul></div>';

				}

				frame+="</div>"

			}

		else

	frame="<iframe frameborder=\"0\" src=\""+url+"\" height=\""+iframe_height+"\" width=\""+iframe_width+"\" scrolling=\"no\" ></iframe>";

	



	document.getElementById("show_ads_"+show_ads_id).innerHTML=frame;

	

	if(sticky==true)

			{

				pf204652bottomLayer = document.getElementById('fl813691');

				pf204652IntervalId = setInterval ( 'pf204652show()', 5 );

			}

	

}













function URLEncode (clearString) 

{

  var output = '';

  var x = 0;

  clearString = clearString.toString();

  var regex = /(^[a-zA-Z0-9_.]*)/;

  while (x < clearString.length) {

    var match = regex.exec(clearString.substr(x));

    if (match != null && match.length > 1 && match[1] != '') {

    	output += match[1];

      x += match[1].length;

    } else {

      if (clearString[x] == ' ')

        output += '+';

      else {

        var charCode = clearString.charCodeAt(x);

        var hexVal = charCode.toString(16);

        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();

      }

      x++;

    }

  }

  return output;

}



function getCookie(name)



{



	var cookies = document.cookie;



	if (cookies.indexOf(name) != -1)



	{



		var startpos = cookies.indexOf(name)+name.length+1;



		var endpos = cookies.indexOf(";",startpos)-1;



		if (endpos == -2) endpos = cookies.length;



		return unescape(cookies.substring(startpos,endpos));



	}



	else



	{



		return false;



	}



}



function setCookie(name, value, expires)



{



	// no expiration date specified? use this date and it will just be deleted soon.



        if (!expires) expires = new Date(); 



	document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() + "; path=/";



}



function delete_cookie ( cookie_name )

{

  var cookie_date = new Date ( );  // current date & time

  cookie_date.setTime ( cookie_date.getTime() - 1 );

  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();

}

function closeAd(){

document.getElementById('adDiv').style.display="none";

} 





















	function pf204652show(){

	if(position>4)

			{

				  pf204652curHeight += 2;

				  if (pf204652curHeight >= pf204652maxHeight){

				  pf204652curHeight= pf204652maxHeight;

					clearInterval ( pf204652IntervalId );

				  }

				  pf204652bottomLayer.style.height = pf204652curHeight+'px';

			  }

	else		

			{

				 tempTop +=2;

				  if (tempTop >= 0){

				  tempTop=0;

					clearInterval ( pf204652IntervalId );

				  }

				  pf204652bottomLayer.style.top = tempTop+'px';

			}

	}

function pf204652hide( ){

	if(position>4)

			{

	  pf204652curHeight -= 2;

	  if (pf204652curHeight < pf204652minHeight){

		clearInterval ( pf204652IntervalId );

	  }

	  pf204652bottomLayer.style.height = pf204652curHeight+'px';

	  }

	 else

	 	{

	  tempTop -= 2;

	  if (tempTop < originalTop){

		clearInterval ( pf204652IntervalId );

	  }

	  pf204652bottomLayer.style.top = tempTop+'px';

		}

}







	function pf204652clickhide(){

		document.getElementById('pf204652hide').style.display='none';

		document.getElementById('pf204652show').style.display='inline';

		pf204652IntervalId = setInterval ( 'pf204652hide()', 5 );

	}

function pf204652clickshow(){

	document.getElementById('pf204652hide').style.display='inline';

	document.getElementById('pf204652show').style.display='none';

	pf204652IntervalId = setInterval ( 'pf204652show(0)', 5);

}

	function pf204652clickclose(){

		document.body.style.marginBottom = '0px';

		pf204652bottomLayer.style.display = 'none';

	}

function get_current_working_path(str)

	{

		var end_pos=(str.search(/publisher-show-ads.php/));

		var url_str_var;

		if(end_pos!=-1)

		  {

		  url_str_var=(str.substring(0,end_pos));

		  }

		else

		  {

		  var end_pos=(str.search(/show-ads.php/));

		  if(end_pos!=-1)

		  url_str_var=(str.substring(0,end_pos));

		  }

		return(url_str_var);

	}

