var showPop=1;
var isIE4 = document.all? true : false;
var isIE6 = document.getElementById && document.all ? true : false;
var isNS4 = document.layers? true : false;
var isNS6 = document.getElementById && !document.all ? true : false;

function getDOMObject (documentID)
{
	if (isIE4)
	{
		return document.all[documentID];
	}
	else if(isIE6)
	{
		return document.getElementById(documentID);
	}
	else if (isNS4)
	{
		return document.layers[documentID];
	}
	else if (isNS6)
	{
		return document.getElementById(documentID);
	}
}
function clearSearchText(SrchObj)
{
	SrchObj.value = "";
	SrchObj.select();
}

function replaceString(string,text,by)
{
	var strLength = string.length, txtLength = text.length;
	if ((strLength == 0) || (txtLength == 0)){return string;};
	var i = string.indexOf(text);
	if ((!i) && (text != string.substring(0,txtLength))){return string;};
	if (i == -1){return string;};
	var newstr = string.substring(0,i)+by;
	if (i+txtLength < strLength){newstr += replaceString(string.substring(i+txtLength,strLength),text,by);};
	return newstr;
}

function submitSearch(formname, type, strAppend)
{
	strAppend = strAppend + generateBrowLogURL('srcqry');
	d = document.forms[formname];
	if ((d.elements['q'].value.length == 0) || (d.elements['q'].value == "Enter Keyword"))
	{
		alert("Please enter a search keyword !");
		d.elements['q'].focus();
		return false;
	}
	else if(checkValidURLChars(d.elements['q'].value))
	{
		newstr = d.elements['q'].value;
		newstr = getEscapedString(newstr);
		d.action = "/display.cfm?s=" + newstr + "&" + strAppend+ "&kt=" + type;
	}
	else
	{
		newstr = d.elements['q'].value;
		newstr = getEscapedString(newstr);
		d.action = '/' + newstr +".cfm?" +strAppend+ "&kt=" + type;
	};
	if (typeof(d)!='undefined'){d.target = "_top";};
	return true;
}

function is_ie6()
{
	return ((window.XMLHttpRequest == undefined) && (ActiveXObject != undefined) && /msie|MSIE 6/.test(navigator.userAgent));
}

function sendRequest(strFormName, strElement)
{
	showPop=0;
	thisform = document.getElementById(strFormName);
	var strforms = strElement;
	var arrElement = new Array();
	arrElement = strforms.split("@@@@");
	for(var i=0; i< arrElement.length; i++)
	{
		var arrTemp = new Array();
		var strTemp = new String(arrElement[i]);
		arrTemp = strTemp.split("####");
		switch(arrTemp[0])
		{
			case "action":
				thisform.action = arrTemp[1] + generateBrowLogURL('adclk');
				break;
			case "data":
				thisform.params.value = arrTemp[1];
				break;
		}
	}
	thisform.method = "POST";
	if(is_ie6()){thisform.target = "";};
	thisform.submit();
	return(false);
}

function changeStatus(strKeyword)
{
	window.status = strKeyword;
	return true;
}

function addbookmark(strDomainName)
{
	bookmarkurl="http://www."+strDomainName;
	bookmarktitle="Welcome To "+strDomainName;

	if (window.sidebar)
	{ /* Mozilla Firefox Bookmark */
		window.sidebar.addPanel(bookmarktitle, bookmarkurl,"");
	}
	else if( window.external )
	{ /* IE Favorite */
		window.external.AddFavorite( bookmarkurl, bookmarktitle);
	}
	else if(window.opera && window.print)
	{ /* Opera Hotlist */
		return(true);
	};
	return(false);
}

function setAsHomePage(ctl, strDomainName)
{
	bookmarkurl="http://www."+strDomainName;

	if( window.external )
	{
		ctl.style.behavior='url(#default#homepage)';
		ctl.setHomePage(bookmarkurl);
	};
	return(false);
}

function getDate()
{
	var arrDay=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	var arrMonth=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	var objDate=new Date();
	var intYear=objDate.getYear();
	if (intYear < 1000){intYear+=1900;};
	var intDay=objDate.getDay();
	var intMonth=objDate.getMonth();
	var intDayMonth=objDate.getDate();
	if (intDayMonth<10){intDayMonth="0"+intDayMonth;};
	var strCurrerntDate=arrDay[intDay]+", "+arrMonth[intMonth]+" "+intDayMonth+", "+intYear;
	document.write(strCurrerntDate);
}

function myPop(strPopupUrl, intShowToolbar)
{
		var d = new Date();
		pundername = 'newpop'+d.getTime();
		if( intShowToolbar == 0)
		{
			newpop = window.open(strPopupUrl, pundername, 'directories=0,menubar=0,width='+screen.width+',height='+screen.height);
		}
		else if ( intShowToolbar == 1 )
		{
			newpop = window.open(strPopupUrl, pundername, "status=1, location=1, toolbar=1,directories=1, top=0, left=0, resizable=1, scrollbars=1, width="+screen.width+",height="+screen.height+",menubar=1");

		}
		else if( intShowToolbar == -1)
		{
			newpop = window.open(strPopupUrl, pundername, "status=1, location=1, toolbar=1,directories=1, top=0, left=0, resizable=1, scrollbars=1, width="+screen.width+",height="+screen.height+",menubar=1");
		}
		else if( intShowToolbar == 2)
		{
			newpop = window.open(strPopupUrl, "fac"+pundername, "status=1, location=1, toolbar=1,directories=1, top=0, left=0, resizable=1, scrollbars=1, width="+screen.width+",height="+screen.height+", menubar=1");
		}		

		if (newpop!=null && typeof(newpop)!="undefined")
		{
			newpop.blur();
		}
		return newpop;
}

function renderFAC()
{
	if(showPop==1 && setFAC == 0)
	{ 
		try{
			if (typeof facl != "undefined" && facl.length>0)
			{
				facl = facl + generateBrowLogURL('adclk');
				myPop(facl, 2);
			}
		}catch(e){ }
	}
}
function showPopunder (strPopupUrl, intShowTool)
{
     if(showPop==1)
     {
		var wopen = myPop(strPopupUrl, intShowTool);
		if (!window.opera && (wopen==null || typeof(wopen)=="undefined"))
		{
			x=document.getElementById('popupbutton');
			if(x){x.onchange();};
		};
   	};
}
function checkUTFString (strValue)
{
	var blnUTF,intStringLength;
	if(strValue == ''){	return (false);};
	intStringLength = strValue.length;
	for(intCur = 0; intCur < intStringLength; intCur++)
	{
		blnUTF = true;
		chrValue = strValue.charAt (intCur);
		var intAscii;
		for (intAscii = 0; intAscii < 128; ++ intAscii)
		{
			var strAscii = intAscii.toString (16);
			if (strAscii.length == 1){strAscii = "0" + strAscii;};
			strAscii = "%" + strAscii;
			strAscii = unescape (strAscii);
			if (strAscii == chrValue){blnUTF=false;break;};
		}
		if(blnUTF == true){break;};
	}
	return blnUTF;
}
function checkValidURLChars (strValue)
{
	var blnReturn,intStringLength;
	if(strValue == ''){return (false);};
	if( strValue.match(/[#&]/) ){return ( true );};
	intStringLength = strValue.length;
	for(intCur = 0; intCur < intStringLength; intCur++)
	{
		blnReturn = true;
		chrValue = strValue.charAt (intCur);
		var intAscii;
		for (intAscii = 0; intAscii < 128; ++ intAscii)
		{
			var strAscii = intAscii.toString (16);
			if (strAscii.length == 1){strAscii = "0" + strAscii;};
			strAscii = "%" + strAscii;
			strAscii = unescape (strAscii);
			if (strAscii == chrValue){blnReturn=false;break;};
		}
		if(blnReturn == true){break;};
	}
	return blnReturn;
}
function getEscapedString (strValue)
{
	var blnUTF;
	var intStringLength;
	var strReturnValue;
	strReturnValue = '';
	if(strValue == ''){return (strValue);};
	intStringLength = strValue.length;
	for(intCur = 0; intCur < intStringLength; intCur++)
	{
		blnUTF = true;
		chrValue = strValue.charAt (intCur);
		var intAscii;
		for (intAscii = 0; intAscii < 128; ++ intAscii)
		{
			var strAscii = intAscii.toString (16);
			if (strAscii.length == 1){strAscii = "0" + strAscii;};
			strAscii = "%" + strAscii;
			strAscii = unescape (strAscii);
			if (strAscii == chrValue){blnUTF=false;break;};
		}
		if(blnUTF == true)
		{
			strReturnValue = strReturnValue+chrValue;
		}
		else
		{
			if(chrValue == " "){chrValue = "_";};
			strReturnValue = strReturnValue+escape(chrValue);
		};
	}
	return strReturnValue;
}
function relplaceAllALinks(tag_regex)
{
	try
	{
		links = window.document.getElementsByTagName('A');
		links_len = links.length;
		for(i = 0; i < links_len; i++)
		{
			if( links[i].href.match(tag_regex ))
			{
				tempData = links[i].innerHTML;
				modifyKeywordClickURL(links[i], 'olod' );				
				links[i].innerHTML = tempData;
			};
		};
	}catch(e){};
}
function modifyKeywordClickURL(anchor_tag, call_type)
{
	anchor_tag.href = anchor_tag.href  + generateBrowLogURL(call_type);
	if (typeof prctu != "undefined" && prctu.length>0)
	{
		anchor_tag.href = prctu + getEscapedString( anchor_tag.href );
	};
	return true;
}
function generateBrowLogURL(call_type)
{
	var append_data='';
	try
	{
		if( typeof br_data == 'undefined' || !br_data ){
			br_data = new brdata();
		};
		if( call_type == 'kwclk' )
		{
			append_data = escape(br_data.getMousePositionData());
		}
		else if( call_type == 'adclk' || call_type == 'srcqry' )
		{
			append_data = '&bd=' + escape(br_data.getSearchBoxRelatedData());
		}
		else
		{
			append_data = '&bd=' + escape(br_data.getURLBrowserData());
		};
	}
	catch(e){};
	return append_data;
}
var brdata = function(){
	this.fd = '#',
	this.cookieSupport = -1,
	this.isinframe = -1,
	this.browserdata='',
	this.getLocalTimeZone = function(){
		return	(new Date()).getTimezoneOffset()/60*(-1);
	},
	this.getScreenHeight = function(){
		return screen.height;
	},
	this.getScreenWidth = function(){
		return screen.width;
	},
	this.calledInExternalFrame = function(){
		return 'n';
	},
	this.isCookieSupported = function(){
		if(this.cookieSupport == -1)
		{
			var ce = navigator.cookieEnabled || false;
			if (typeof navigator.cookieEnabled == 'undefined' && !ce)
			{
				document.cookie="skck";
				ce=(document.cookie.indexOf("skck")!=-1)? true : false;
			};
		};
		return this.cookieSupport;
	},
	this.getURLBrowserData = function(){
		if(this.browserdata == '')
		{
			this.browserdata = this.getLocalTimeZone().toString() +  this.fd + this.getScreenHeight() + this.fd + this.getScreenWidth() + this.fd +  (( this.isCookieSupported() )?1:0).toString() + this.fd + (this.calledInExternalFrame()).toString();
		};
		return this.browserdata;
	},
	this.getMousePositionData = function(){
		return this.fd + mX + this.fd + mY;
	},
	this.getSearchBoxRelatedData = function(){
		return this.getURLBrowserData()+this.getMousePositionData();
	};
};
var _skPU = {
		_Top: null,
		_wh: function(){
			var _mh=0;
			try{
				if (typeof (this._Top.window.innerHeight) == 'number') {			
					_mh = this._Top.window.innerHeight;
				} else if (this._Top.document.documentElement
						&& this._Top.document.documentElement.clientHeight) {			
					_mh = this._Top.document.documentElement.clientHeight;
				} else if (this._Top.document.body && this._Top.document.body.clientHeight){			
					_mh = this._Top.document.body.clientHeight;
				};
			}catch(e){
				_mh=0;
			};
			return _mh;
		},
		_ww: function(){
			var _mw=0;
			try{
				if (typeof (this._Top.window.innerWidth) == 'number') {			
					_mw = this._Top.window.innerWidth;
				} else if (this._Top.document.documentElement
						&& this._Top.document.documentElement.clientWidth) {			
					_mw = this._Top.document.documentElement.clientWidth;
				} else if (this._Top.document.body && this._Top.document.body.clientWidth){			
					_mw = this._Top.document.body.clientWidth;
				};
			}catch(e){
				_mw=0;
			};		
			return _mw;
		},
		_wt: function(){
			return ((this._Top)?((this._Top.window.screenTop != undefined) ? this._Top.window.screenTop: this._Top.window.screenY):0);
		},
		_wl: function(){				
			return ((this._Top)?((this._Top.window.screenLeft != undefined) ? this._Top.window.screenLeft: this._Top.window.screenX):0);
		},
		doPU: function (url,pw,ph,npf,dr) {
			if(!this._Top){
				this._Top = self;
				if (top!=self) {
					try{
						if (top.document.location.toString()){this._Top = top;};
					}catch (e){};
				};
			};
			var _npSU = ((dr)?url:"about:blank");
			var _npID = "pu_" + Math.floor(89999999 * Math.random() + 10000000);
			var pxLeft = 0;
			var pxTop = 0;
			if(pw==-1)
				{
				pw=screen.width;
				}
			if(ph==-1){
				ph=screen.height;
			}
			pxLeft = (this._wl()+(this._ww()/2)-(pw/2));
			pxTop = (this._wt()+(this._wh()/2)-(ph/2));
			if(!npf){
				npf='toolbar=0,scrollbars=1,location=1,statusbar=0,menubar=0,resizable=1';
			};
			var _npW = this._Top.window.open(_npSU, _npID,npf+',top='+ pxTop+',left='+pxLeft+',width='+pw+',height='+ph);
			if(_npW){					
				_npW.blur();
				if (navigator.userAgent.toLowerCase().indexOf("applewebkit") > -1)
				{
					this._Top.window.blur();
					this._Top.window.focus();
				};

					_npW.Init = function(e) {
						with (e) {
							Params = e.Params;							
							Main = function() {								
								if (typeof window.mozPaintCount != "undefined") {
									var x = window.open("about:blank");
									if(x){
										x.close();
									};
								};
								var dUrl = Params.dUrl;							
								try {
									if(navigator.userAgent.toLowerCase().indexOf("msie")<1){
										opener.window.focus();
									};
								}catch(err){
								};
								if(!dr){
								window.location = dUrl;
								}
							};
							Main();
						};
					};
					_npW.Params = {
						dUrl : url
					};
					_npW.Init(_npW);
			};
			return _npW;				
		}		
};

function renderFACP(e)
{
	if(e=="ex")
	{
		return false;
	}
	
	if(showPop==1 && typeof(__pp)!='undefined' && typeof(__pp.FACP)!='undefined' && __pp.FACP.pd==false)
	{ 
		try{
			if (!e) { 
				var e = window.event || window.Event; 
				e.cancelBubble = true;
			}
			if(e.button && e.button == 2) return false;
			if (typeof(__pp.FACP.u) != "undefined" && __pp.FACP.u.length>0)
			{
				__pp.FACP.u = __pp.FACP.u + generateBrowLogURL('adclk');
				_skPU.doPU(__pp.FACP.u,__pp.FACP.w,__pp.FACP.h,__pp.FACP.p,(e=="ex"));
				showPop=0;
				__pp.FACP.pd=true; 
				return true;
			}
		}catch(e){
			__pp.FACP.pd=true;
			return false; 
		}
	}
	else
	{
		return false;
	}
}
function confirmToOptOut()
{
  optOut=confirm('You will not be able to see any ads or websearches.');
  if(optOut)
  {
    var date = new Date();
	date.setTime(date.getTime()+(365*24*60*60*1000));
	var expires = "; expires="+date.toGMTString();
    document.cookie = "ootk=1"+expires+"; path=/";    
  	window.location.reload();
  };
}
if (!isIE4){ document.captureEvents(Event.MOUSEMOVE);};
var mX=0,mY=0,br_data=false;
document.onmousemove = mPos;
function mPos(e) {
	if (isIE4){
		mX = event.clientX + document.body.scrollLeft;
		mY = event.clientY + document.body.scrollTop;
	}
	else{
		mX = e.pageX;
		mY = e.pageY;
	}
	return true;
}

function atevt() {
    if (document.addEventListener) {
        document.addEventListener('click', ppctrl, false);
    } else if (document.attachEvent) {
        document.attachEvent('onclick', ppctrl);
    } else {
        document.onclick = ppctrl;
    }
}

function ppctrl(e)
{ 
	if(showPop==1 && !renderFACP(e) )
	{
		shpp(e);
	}
}

function shpp(e)
{
	if(typeof(__pp)!='undefined' && showPop==1)
	{ 
		try{
			if (!e) { 
				var e = window.event || window.Event; 
				e.cancelBubble = true;
			}
			if(e.button && e.button == 2) return ;
			try{
					if (typeof(__pp.kp)!="undefined" && typeof(__pp.kp.u)!="undefined" && __pp.kp.u && __pp.kp.u.length>0 && __pp.kp.pd==false)
					{
						_skPU.doPU(__pp.kp.u,__pp.kp.w,__pp.kp.h,__pp.kp.p,(e=="ex")); 
						__pp.kp.pd = true; 
					}
				}catch(exc){}
			if(e=="ex")
			{
				shmsc(e);
			}
			else
			{
				if (typeof(__pp.dp) != "undefined" && typeof(__pp.dp.u) != "undefined" && __pp.dp.u && __pp.dp.u.length>0 && __pp.dp.pd==false)
				{
					_skPU.doPU(__pp.dp.u,__pp.dp.w,__pp.dp.h,__pp.dp.p,(e=="ex")); 
					__pp.dp.pd = true;
				}
			}
			
		}catch(exc){ }
	}
}

function shmsc(e)
{
	if(typeof(__pp)!='undefined')
	{ 
		try{
			if (typeof(__pp.ms) != "undefined" && typeof(__pp.ms.u) != "undefined" && __pp.ms.u)
			{
				var cnt = __pp.ms.u.length;
				for(var i=0;i<cnt;i++)
				{
					if(__pp.ms.u[i])
					{
						_skPU.doPU(__pp.ms.u[i],-1,-1,__pp.ms.p,true);
					}
				}
			}
		}catch(e){ }
	}
}
