var base_url = 'http://www.thatsmyscript.com/';//added by waqas
document.write("<script type='text/javascript' src=\'"+base_url+"jscript/menu.js\'></script>");
var serverPath="http://10.0.0.1:81/tmsversion3/";
var opacity=0;
var opacVar;
var countryList="";
var countryListIds="";
countryListName="";
var suggestBlockId=0;
var searchBlockID=0;
var maxscrollOutValue=270;
var scrollVarOut;
var scrollVar;
var prevDiv="";
var scHeight=0;
var scrollFun;
var delayCounter=10;
var delayObj="";
var checkHeight=0;
var togHeight;
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{
			string: navigator.userAgent,
			subString: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
function GetXmlHttpObject()
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
function Left(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function Top(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
	curtop += obj.y;
	return curtop;
}
function emailcheck(emailID) 
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (!filter.test(emailID))
	{		
		return false;					
	}
	else
	{
		return true;
	}	
}
function onlyDigits(e,obj)
{
	var keynum;
	var keychar;
	var numcheck;
	if(window.event) 
	{
		keynum = e.keyCode;
	}else if(e.which) 
	{
		keynum = e.which;
	}		
	if(keynum==8 || e.charCode==0)
	{
		return true;
	}
	keychar = String.fromCharCode(keynum);
	numcheck = /\d/;	
	return numcheck.test(keychar);
}
function onlyDecimals(e,obj)
{
	var keynum;
	var keychar;
	var numcheck;
	if(window.event) 
	{
		keynum = e.keyCode;
	}else if(e.which) 
	{
		keynum = e.which;
	}		
	if(keynum==8 || e.charCode==0 || keynum==46)
	{
		if(keynum==46)
		{
			txtVal=obj.value;
			var arr=txtVal.split(".");//checking for number of dots
			if(arr.length!=1)
			{
				return false;//if dots is more return false
			}
		}
		return true;
	}
	keychar = String.fromCharCode(keynum);
	numcheck = /\d/;	
	return numcheck.test(keychar);
}
function getFileName(url)
{
  var lastSlash = url.lastIndexOf("/");
  var firstQuestionMark = url.indexOf("?");
  var firstHashMark = url.indexOf("#");
  if(firstQuestionMark == -1)
  {
  	firstQuestionMark = url.length;
  }
   if(firstHashMark == -1)
  {
  	firstHashMark = url.length;
  }
  var fileName = url.substring(0, firstHashMark);
  fileName = fileName.substring(lastSlash + 1, firstQuestionMark);
  return fileName ;
}
function focusIn(objname,text)
{	
	obj = document.getElementById(objname);		
	if(obj.value == text)
	{
		obj.value="";		
		obj.className = "awardyeartext";
	}	
}
function focusme(obj)
{
	obj.select();
}
function focusOut(objname,text)
{
	obj = document.getElementById(objname);
	if(obj.value == "")
	{
		obj.value = text;
		obj.className = "watermrkyeartext";		
	}
}
function txtFocusIn(objname,text,className)
{	
	obj = document.getElementById(objname);		
	if(obj.value == text)
	{
		obj.value="";	
		obj.className = className;
	}	
}
function txtFocusOut(objname,text,className)
{
	obj = document.getElementById(objname);
	if(obj.value == "")
	{
		obj.value = text;
		obj.className = className;		
	}
}
function globalSearchActive()
{
	obj = document.getElementById("TxtSearch");
	if(obj.value=="Search")
	{
		obj.value="";
	}
	obj.style.color="#666666";
	obj.style.background="#ffffff";
	//document.getElementById("divGlobalSearch").style.background="url('images/main_search_box.png') no-repeat 2px 0px";
}
function globalSearchInactive()
{
	obj = document.getElementById("TxtSearch");
	if(obj.value.replace(/ /g,"")=="")
	{
		obj.value="Search";
		obj.style.color="#ffffff";
		obj.style.background="#35A4B5";
	//document.getElementById("divGlobalSearch").style.background="url('images/main_search_box.png') no-repeat 2px -19px";
	}	
}
function search(obj)
{
	if(obj.value.replace(/ /g,"")!="")
	{
		var xmlHttp;		
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request");
			return;
		}
		url="ajax_search.php?param="+escape(obj.value);
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=function()
		{
			if (xmlHttp.readyState==4)
			{
				var respText=xmlHttp.responseText;
				//respText=respText.replace(regex,'>$1<b>$2</span>$3<');
				findWord = new RegExp(obj.value, "g" );
				//respText=respText.replace( findWord, "<span style=\u0022color:red;font-weight:bold;\u0022>" + obj.value + "</span>" );
				document.getElementById("searchcontainer").innerHTML=respText;
				if(xmlHttp.responseText.replace(/ /g,"")=="")
				{
					document.getElementById("searchresultbox").style.display="none";
				}
				else
				{
					document.getElementById("searchresultbox").style.display="block";
				}
			}
		}			
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);	
	}
	else
	{
		document.getElementById("searchresultbox").style.display="none";
	}
}
/*testing function will be removed soon*/
function search_checking(obj)
{
	if(obj.value.replace(/ /g,"")!="")
	{
		var xmlHttp;		
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request");
			return;
		}
		url="oldajax_search.php?param="+escape(obj.value);
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=function()
		{
			if (xmlHttp.readyState==4)
			{
				var respText=xmlHttp.responseText;
				//respText=respText.replace(regex,'>$1<b>$2</span>$3<');
				findWord = new RegExp(obj.value, "g" );
				//respText=respText.replace( findWord, "<span style=\u0022color:red;font-weight:bold;\u0022>" + obj.value + "</span>" );
				document.getElementById("searchcontainer").innerHTML=respText;
				if(xmlHttp.responseText.replace(/ /g,"")=="")
				{
					document.getElementById("searchresultbox").style.display="none";
				}
				else
				{
					document.getElementById("searchresultbox").style.display="block";
				}
			}
		}			
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);	
	}
	else
	{
		document.getElementById("searchresultbox").style.display="none";
	}
}
/******************************************/
function searchSite()
{
	document.forms[0].action="/searchresult";
	document.forms[0].submit();
}
function searchSiteType(type)
{
	document.forms[0].action="/searchresult/"+type;
	document.forms[0].submit();
}
function clearSearchText(obj)
{
	if(obj.value=="Search")
	{
		obj.value="";
	}
	obj.style.color="#666666";
}
function putDefault(obj)
{
	if(obj.value.replace(/ /g,"")=="")
	{
		obj.value="Search";
		obj.style.color="#cccccc";
	}	
}
function clearSearchBox(obj)
{
	if(obj.value=="Search")
	{
		obj.value="";
	}
	obj.style.color="#666666";
}
function resetInnerBox(obj)
{
	if(obj.value.replace(/ /g,"")=="")
	{
		obj.value="Search";
		obj.style.color="#CCCCCC";
		document.getElementById("link_clearsearch").style.visibility="hidden";
	}	
	else
	{
		document.getElementById("link_clearsearch").style.visibility="visible";
	}
}
function searchAll()
{
	var searchValue=document.forms[0].TxtInnerSearch.value;
	var xmlHttp;		
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;	
	}
	url="ajax_searchall.php?param="+escape(searchValue);
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{
			document.getElementById("searchAllul").innerHTML=xmlHttp.responseText;
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function nextSearch(typeSearch,pageNum)
{
	var searchValue=document.forms[0].TxtInnerSearch.value;
	var xmlHttp;		
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;	
	}
	if(typeSearch==1)
	{
		url="ajax_videosearch.php";
	}
	else if(typeSearch==2)
	{
		url="ajax_pagessearch.php";
	}
	else if(typeSearch==3)
	{
		url="ajax_brandssearch.php";
	}
	else if(typeSearch==4)
	{
		url="ajax_agencysearch.php";
	}
	else if(typeSearch==5)
	{
		url="ajax_printsearch.php";
	}
	else if(typeSearch==6)
	{
		url="ajax_radiosearch.php";
	}
	else if(typeSearch==7)
	{
		url="ajax_countrysearch.php";		
	}
	else if(typeSearch==8)
	{
		url="ajax_entertainsearch.php";
	}
	else if(typeSearch==9)
	{
		url="ajax_categorysearch.php";
	}
	else if(typeSearch==10)
	{
		url="ajax_blogsearch.php";
	}
	else if(typeSearch==11)
	{
		url="ajax_latestadssearch.php";
	}
	url=url+"?param="+pageNum+"&param1="+escape(searchValue);
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{
			if(typeSearch==1)
			{
				document.getElementById("searchvideoul").innerHTML=xmlHttp.responseText;
				if(document.forms[0].HFtotalVideoRec.value>100)				
				{
					startVal=parseInt((pageNum-1)*100)+1;
					endVal=parseInt(startVal)+99;
					if(endVal>document.forms[0].HFtotalVideoRec.value)
					{
						endVal=document.forms[0].HFtotalVideoRec.value;
					}
					document.getElementById("resultshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalVideoRec.value+"&nbsp;results found for '"+searchValue+"'.";
				}
				else
				{		
					document.getElementById("resultshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalVideoRec.value+"&nbsp;results found for '"+searchValue+"'.";
				}
				if(document.forms[0].HFtotalVideoRec.value==0)
				{
					document.getElementById("resultshow").innerHTML="No Video found.";
				}
				else
				{
					document.getElementById("link_result_1").innerHTML="("+document.forms[0].HFtotalVideoRec.value+")";
				}
			}
			else if(typeSearch==2)
			{
				document.getElementById("searchpageul").innerHTML=xmlHttp.responseText;	
				if(document.forms[0].HFtotalPageRec.value>5)				
				{
					startVal=parseInt((pageNum-1)*5)+1;
					endVal=parseInt(startVal)+4;
					if(endVal>document.forms[0].HFtotalPageRec.value)
					{
						endVal=document.forms[0].HFtotalPageRec.value;
					}	
						
					document.getElementById("resultPageshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalPageRec.value+"&nbsp;results found for '"+searchValue+"'.";
				}
				else
				{
					document.getElementById("resultPageshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalPageRec.value+"&nbsp;results found for '"+searchValue+"'.";
				}	
				if(document.forms[0].HFtotalPageRec.value==0)
				{
					document.getElementById("resultPageshow").innerHTML="My zone is not found.";
				}
				else
				{
					document.getElementById("link_result_6").innerHTML="("+document.forms[0].HFtotalPageRec.value+")";
				}
			}
			else if(typeSearch==3)
			{				
				document.getElementById("searchbrandsul").innerHTML=xmlHttp.responseText;	
				if(document.forms[0].HFtotalBrandsRec.value>5)				
				{
					startVal=parseInt((pageNum-1)*5)+1;
					endVal=parseInt(startVal)+4;
					if(endVal>document.forms[0].HFtotalBrandsRec.value)
					{
						endVal=document.forms[0].HFtotalBrandsRec.value;
					}	
					document.getElementById("resultBrandshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalBrandsRec.value+"&nbsp;results found for '"+searchValue+"'.";
				}
				else
				{
					document.getElementById("resultBrandshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalBrandsRec.value+"&nbsp;results found for '"+searchValue+"'.";
				}		
				if(document.forms[0].HFtotalBrandsRec.value==0)
				{
					document.getElementById("resultBrandsshow").innerHTML="No Brand found.";
				}
				else
				{
					document.getElementById("link_result_5").innerHTML="("+document.forms[0].HFtotalBrandsRec.value+")";
				}
			}
			else if(typeSearch==4)
			{				
				document.getElementById("searchagencyul").innerHTML=xmlHttp.responseText;	
				if(document.forms[0].HFtotalAgencyRec.value>5)				
				{
					startVal=parseInt((pageNum-1)*5)+1;
					endVal=parseInt(startVal)+4;
					if(endVal>document.forms[0].HFtotalAgencyRec.value)
					{
						endVal=document.forms[0].HFtotalAgencyRec.value;
					}
					document.getElementById("resultAgencyshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalAgencyRec.value+"&nbsp;results found for '"+searchValue+"'.";
				}
				else
				{
					document.getElementById("resultAgencyshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalAgencyRec.value+"&nbsp;results found for '"+searchValue+"'.";
				}		
				if(document.forms[0].HFtotalAgencyRec.value==0)
				{
					document.getElementById("resultAgencyshow").innerHTML="No Agency found.";
				}	
				else
				{
					document.getElementById("link_result_9").innerHTML="("+document.forms[0].HFtotalAgencyRec.value+")";
				}
			}
			else if(typeSearch==5)
			{				
				document.getElementById("searchprintsul").innerHTML=xmlHttp.responseText;	
				if(document.forms[0].HFtotalPrintsRec.value>5)				
				{
					startVal=parseInt((pageNum-1)*5)+1;
					endVal=parseInt(startVal)+4;
					if(endVal>document.forms[0].HFtotalPrintsRec.value)
					{
						endVal=document.forms[0].HFtotalPrintsRec.value;
					}			
					document.getElementById("resultPrintsshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalPrintsRec.value+"&nbsp;results found for '"+searchValue+"'.";
				}
				else
				{
					document.getElementById("resultPrintsshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalPrintsRec.value+"&nbsp;results found for '"+searchValue+"'.";
				}		
				if(document.forms[0].HFtotalPrintsRec.value==0)
				{
					document.getElementById("resultPrintsshow").innerHTML="No Print found.";
				}	
				else
				{
					document.getElementById("link_result_2").innerHTML="("+document.forms[0].HFtotalPrintsRec.value+")";
				}
			}
			else if(typeSearch==6)
			{				
				document.getElementById("searchradiosul").innerHTML=xmlHttp.responseText;	
				if(document.forms[0].HFtotalRadiosRec.value>5)				
				{
					startVal=parseInt((pageNum-1)*5)+1;
					endVal=parseInt(startVal)+4;
					if(endVal>document.forms[0].HFtotalRadiosRec.value)
					{
						endVal=document.forms[0].HFtotalRadiosRec.value;
					}					
					document.getElementById("resultRadiosshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalRadiosRec.value+"&nbsp;results found for '"+searchValue+"'.";
				}
				else
				{
					document.getElementById("resultRadiosshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalRadiosRec.value+"&nbsp;results found for '"+searchValue+"'.";
				}			
				if(document.forms[0].HFtotalRadiosRec.value==0)
				{
					document.getElementById("resultRadiosshow").innerHTML="No Radio found.";
				}	
				else
				{
					document.getElementById("link_result_3").innerHTML="("+document.forms[0].HFtotalRadiosRec.value+")";
				}
			}
			else if(typeSearch==7)
			{				
				document.getElementById("searchcountryul").innerHTML=xmlHttp.responseText;	
				if(document.forms[0].HFtotalCountryRec.value>5)				
				{
					startVal=parseInt((pageNum-1)*5)+1;
					endVal=parseInt(startVal)+4;
					if(endVal>document.forms[0].HFtotalCountryRec.value)
					{
						endVal=document.forms[0].HFtotalCountryRec.value;
					}					
					document.getElementById("resultCountryshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalCountryRec.value+"&nbsp;results found for '"+searchValue+"'.";
				}
				else
				{
					document.getElementById("resultCountryshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalCountryRec.value+"&nbsp;results found for '"+searchValue+"'.";
				}
				if(document.forms[0].HFtotalCountryRec.value==0)
				{
					document.getElementById("resultCountryshow").innerHTML="No Country found.";
				}
				else
				{
					document.getElementById("link_result_8").innerHTML="("+document.forms[0].HFtotalCountryRec.value+")";
				}
			}
			else if(typeSearch==8)
			{				
				document.getElementById("searchentertainul").innerHTML=xmlHttp.responseText;	
				if(document.forms[0].HFtotalEntertainRec.value>5)				
				{
					startVal=parseInt((pageNum-1)*5)+1;
					endVal=parseInt(startVal)+4;
					if(endVal>document.forms[0].HFtotalEntertainRec.value)
					{
						endVal=document.forms[0].HFtotalEntertainRec.value;
					}		
					document.getElementById("resultEntertainshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalEntertainRec.value+"&nbsp;results found for '"+searchValue+"'.";
				}
				else
				{
					document.getElementById("resultEntertainshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalEntertainRec.value+"&nbsp;results found for '"+searchValue+"'.";
				}		
				if(document.forms[0].HFtotalEntertainRec.value==0)
				{
					document.getElementById("resultEntertainshow").innerHTML="No Entertainment found.";
				}
				else
				{
					document.getElementById("link_result_10").innerHTML="("+document.forms[0].HFtotalEntertainRec.value+")";
				}
			}
			else if(typeSearch==9)
			{				
				document.getElementById("searchcategoryul").innerHTML=xmlHttp.responseText;	
				if(document.forms[0].HFtotalCategoryRec.value>5)				
				{
					startVal=parseInt((pageNum-1)*5)+1;
					endVal=parseInt(startVal)+4;
					if(endVal>document.forms[0].HFtotalCategoryRec.value)
					{
						endVal=document.forms[0].HFtotalCategoryRec.value;
					}		
					document.getElementById("resultCategoryshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalCategoryRec.value+"&nbsp;results found for '"+searchValue+"'.";
				}
				else
				{
					document.getElementById("resultCategoryshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalCategoryRec.value+"&nbsp;results found for '"+searchValue+"'.";
				}			
				if(document.forms[0].HFtotalCategoryRec.value==0)
				{
					document.getElementById("resultCategoryshow").innerHTML="No Category found.";
				}	
				else
				{
					document.getElementById("link_result_7").innerHTML="("+document.forms[0].HFtotalCategoryRec.value+")";
				}
			}
			else if(typeSearch==10)
			{				
				document.getElementById("searchblogul").innerHTML=xmlHttp.responseText;	
				document.forms[0].HFtotalBlogRec.value;
				if(document.forms[0].HFtotalBlogRec.value>5)				
				{
					startVal=parseInt((pageNum-1)*5)+1;
					endVal=parseInt(startVal)+4;
					if(endVal>document.forms[0].HFtotalBlogRec.value)
					{
						endVal=document.forms[0].HFtotalBlogRec.value;
					}					
					document.getElementById("resultBlogshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalBlogRec.value+"&nbsp;results found for '"+searchValue+"'.";
					//document.getElementById("resultBlogshow").innerHTML="Results &nbsp;&nbsp;" + startVal + "&nbsp;to&nbsp;" + endVal + "&nbsp;&nbsp;of&nbsp;&nbsp;" + document.forms[0].HFtotalBlogRec.value;
				}
				else
				{
					document.getElementById("resultBlogshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalBlogRec.value+"&nbsp;results found for '"+searchValue+"'.";
					//document.getElementById("resultBlogshow").innerHTML="Results  &nbsp;1&nbsp;to&nbsp;" + document.forms[0].HFtotalBlogRec.value + "&nbsp;&nbsp;of&nbsp;&nbsp;" + document.forms[0].HFtotalBlogRec.value;
				}			
				if(document.forms[0].HFtotalBlogRec.value==0)
				{
					document.getElementById("resultBlogshow").innerHTML="No Blog found.";
				}			
				else
				{
					document.getElementById("link_result_11").innerHTML="("+document.forms[0].HFtotalBlogRec.value+")";
				}
			}
			else if(typeSearch==11)
			{				
				document.getElementById("searchlatestul").innerHTML=xmlHttp.responseText;	
				document.forms[0].HFtotalLatestRec.value;
				if(document.forms[0].HFtotalLatestRec.value>5)				
				{
					startVal=parseInt((pageNum-1)*5)+1;
					endVal=parseInt(startVal)+4;
					if(endVal>document.forms[0].HFtotalLatestRec.value)
					{
						endVal=document.forms[0].HFtotalLatestRec.value;
					}					
					document.getElementById("resultLatestshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalLatestRec.value+"&nbsp;results found for '"+searchValue+"'.";
				}
				else
				{
					document.getElementById("resultLatestshow").innerHTML="About&nbsp;"+document.forms[0].HFtotalLatestRec.value+"&nbsp;results found for '"+searchValue+"'.";
				}			
				if(document.forms[0].HFtotalLatestRec.value==0)
				{
					document.getElementById("resultLatestshow").innerHTML="Latest Ads not found.";
				}			
				else
				{
					document.getElementById("link_result_4").innerHTML="("+document.forms[0].HFtotalLatestRec.value+")";
				}
			}
			//
			$(".itemblock50").css("display","none");
			$(".itemblock100").css("display","none");
			//
		}
	}			
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}
function nextNavSearch(typeSearch)
{
	if(typeSearch==1)
	{
		var pageNum=document.forms[0].HFVideoPresentPage.value;
	}
	else if(typeSearch==2)
	{
		var pageNum=document.forms[0].HFPagePresentPage.value;	
	}
	else if(typeSearch==3)
	{
		var pageNum=document.forms[0].HFBrandsPresentPage.value;	
	}	
	else if(typeSearch==4)
	{
		var pageNum=document.forms[0].HFAgencyPresentPage.value;	
	}
	else if(typeSearch==5)
	{
		var pageNum=document.forms[0].HFPrintPresentPage.value;	
	}
	else if(typeSearch==6)
	{
		var pageNum=document.forms[0].HFRadioPresentPage.value;	
	}
	else if(typeSearch==7)
	{
		var pageNum=document.forms[0].HFCountryPresentPage.value;	
	}
	else if(typeSearch==8)
	{
		var pageNum=document.forms[0].HFEntertainPresentPage.value;	
	}
	else if(typeSearch==9)
	{
		var pageNum=document.forms[0].HFCategoryPresentPage.value;	
	}	
	else if(typeSearch==10)
	{
		var pageNum=document.forms[0].HFBlogPresentPage.value;	
	}
	else if(typeSearch==11)
	{
		var pageNum=document.forms[0].HFLatestPresentPage.value;	
	}	
	pageNum=parseInt(pageNum)+1;
	nextSearch(typeSearch,pageNum);
}
function prevNavSearch(typeSearch)
{
	if(typeSearch==1)
	{
		var pageNum=document.forms[0].HFVideoPresentPage.value;
	}
	else if(typeSearch==2)
	{
		var pageNum=document.forms[0].HFPagePresentPage.value;	
	}
	else if(typeSearch==3)
	{
		var pageNum=document.forms[0].HFBrandsPresentPage.value;	
	}	
	else if(typeSearch==4)
	{
		var pageNum=document.forms[0].HFAgencyPresentPage.value;	
	}
	else if(typeSearch==5)
	{
		var pageNum=document.forms[0].HFPrintsPresentPage.value;	
	}
	else if(typeSearch==6)
	{
		var pageNum=document.forms[0].HFRadiosPresentPage.value;	
	}
	else if(typeSearch==7)
	{
		var pageNum=document.forms[0].HFCountryPresentPage.value;	
	}
	else if(typeSearch==8)
	{
		var pageNum=document.forms[0].HFEntertainPresentPage.value;	
	}
	else if(typeSearch==9)
	{
		var pageNum=document.forms[0].HFCategoryPresentPage.value;	
	}
	else if(typeSearch==10)
	{
		var pageNum=document.forms[0].HFBlogPresentPage.value;	
	}
	else if(typeSearch==11)
	{
		var pageNum=document.forms[0].HFLatestPresentPage.value;	
	}
	pageNum=parseInt(pageNum)-1;
	nextSearch(typeSearch,pageNum);
}
function closeResult()
{	
	if(document.getElementById("searchresultbox"))
	{
		document.getElementById("searchresultbox").style.display="none";	
	}
	if(document.getElementById("divAdSuggestions"))
	{	
		document.getElementById("divAdSuggestions").style.display="none";		
	}
	if(document.getElementById("divSuggestions"))
	{	
		document.getElementById("divSuggestions").style.display="none";
	}	
}


function openComingSoon(obj)
{	
	document.getElementById("divComingSoon").style.visibility = "visible";
	document.getElementById("divComingSoon").style.left=Left(obj)+5+"px";
	document.getElementById("divComingSoon").style.top=Top(obj)-35+"px";
	clearTimeout(opacVar);	
	decreaseOpacity(0);
}
function closeComingSoon(obj)
{	
	clearTimeout(opacVar);	
	increaseOpaciti(100);
}
function decreaseOpacity(opacity)
{	
	imageobject=document.getElementById("divComingSoon");	
	if (navigator.appName.indexOf("Netscape")!=-1&&parseInt(navigator.appVersion)>=5)
	{
		if(BrowserDetect.browser=="Chrome")
		{
			 imageobject.style.opacity=opacity;
		}
		else
		{			
			imageobject.style.MozOpacity=opacity/100;
			imageobject.style.opacity=opacity/100;
			imageobject.style.KhtmlOpacity = opacity / 100; 
		}		
		
	}
	else if (navigator.appName.indexOf("Microsoft")!= -1  &&parseInt(navigator.appVersion)>=4)
	{
		imageobject.filters.alpha.opacity=opacity;			
	}
	if(opacity<100)
	{
		opacity=opacity+10;
		opacVar=setTimeout("decreaseOpacity("+opacity+")",100);
	}
	else
	{
		clearTimeout(opacVar);
	}
}
function increaseOpaciti(opacity)
{
	imageobject=document.getElementById("divComingSoon");
	if (navigator.appName.indexOf("Netscape")!=-1&&parseInt(navigator.appVersion)>=5)
	{
		if(BrowserDetect.browser=="Chrome")
		{
			 imageobject.style.opacity=opacity;
		}
		else
		{
			
			imageobject.style.MozOpacity=opacity/100;
			imageobject.style.opacity=opacity/100;
			imageobject.style.KhtmlOpacity = opacity / 100; 
		}		
	}
	else if (navigator.appName.indexOf("Microsoft")!= -1  &&parseInt(navigator.appVersion)>=4)
	{
		imageobject.filters.alpha.opacity=opacity;			
	}
	if(opacity>0)
	{
		opacity=opacity-10;
		opacVar=setTimeout("increaseOpaciti("+opacity+")",50);
	}
	else
	{
		document.getElementById("divComingSoon").style.visibility = "hidden";
		clearTimeout(opacVar);
	}
}
function checkLoginAd()
{
	var xmlHttp;		
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	url="ajax_checklogin.php";
	url=url+"?sid="+Math.random();
	xmlHttp.onreadystatechange=function()
	{		
		if (xmlHttp.readyState==4)
		{				
			if(xmlHttp.responseText==1)
			{					
				document.forms[0].action="createad.php";
				document.forms[0].submit();
			}
			else
			{
				document.getElementById("loginRedirectURL").value="createad.php";
				openSignin();
			}			
		}					
	}		
	xmlHttp.open("GET",url,true) ;
	xmlHttp.send(null);		
}
function checkLoggedRegIN()
{
	var xmlHttp;		
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	url="ajax_checklogin.php";
	url=url+"?sid="+Math.random();
	xmlHttp.onreadystatechange=function()
	{		
		if (xmlHttp.readyState==4)
		{				
			if(xmlHttp.responseText==1)
			{					
				return true;
			}
			else
			{
				registerUser();
			}			
		}					
	}		
	xmlHttp.open("GET",url,true) ;
	xmlHttp.send(null);		
}
function checkLoggedIN()
{
	var xmlHttp;		
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	url="ajax_checklogin.php";
	url=url+"?sid="+Math.random();
	xmlHttp.onreadystatechange=function()
	{		
		if (xmlHttp.readyState==4)
		{				
			if(xmlHttp.responseText==1)
			{					
				return true;
			}
			else
			{
				registerUser();
			}			
		}					
	}		
	xmlHttp.open("GET",url,true) ;
	xmlHttp.send(null);		
}
function openSignin(proccedType)
{
	if(proccedType)
	{
		document.getElementById("loginProceed").value=proccedType;
	}
	if(document.forms[0])
	{
		document.forms[0].action="http://www.thatsmyscript.com/login";
		/*document.forms[0].action="register#signin";*/
		document.forms[0].submit();
	}
	else
	{
		/*window.location.href="register#signin"*/
		window.location.href="http://www.thatsmyscript.com/login"
	}
}
function openDownloadSignin(url)
{
	if(document.getElementById("regcontainer"))
	{
		document.getElementById("regcontainer").style.display="none";
	}	
	if(document.getElementById("tab1"))
	{
		document.getElementById("tab1").style.display="none";
	}
	if(document.getElementById("tab2"))
	{
		document.getElementById("tab2").style.display="none";
	}
	if(document.getElementById("tab3"))
	{
		document.getElementById("tab3").style.display="none";
	}
	document.getElementById("pageshader").style.display="block";
	document.getElementById("loginbox").style.display="block";	
	document.getElementById("forgetbox").style.display="none";
	document.getElementById("signinbox").style.display="block";	
	document.getElementById("TxtLoginID").value="";
	document.getElementById("TxtPWD").value="";	
	document.getElementById("loginmessage").style.visibility="visible";
	document.getElementById("loginmessage").innerHTML = "You will need to sign in and have download subscription to proceed.";
	document.getElementById("TxtLoginID").focus();
	document.getElementById("loginRedirectURL").value=url;
}
function searchPortFolioPage(type,secure)
{
	/*alert(type+"---"+secure);*/
	var ancName="";
	switch (type)
	{
		case 1:
		   ancName="Users";
		break;
		case 2:
		   ancName="Brands";
		break;
		case 3:
		  ancName="Countries";
		break;
		case 4:
		  ancName="Agencies";
		 break;
		case 5:
		  ancName="Categories";
		  break;
		case 6:
		  ancName="Entertainments";
		break;
	}
	if(secure==1)
	{
		document.forms[0].action="http://www.thatsmyscript.com/portfolio#"+ancName
	}
	else
	{
		document.forms[0].action="http://www.thatsmyscript.com/portfolio#"+ancName
	}	
	document.forms[0].target="";
	document.forms[0].submit();
}
function signout()
{
	var xmlHttp;		
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	url="ajax_logout.php";
	url=url+"?sid="+Math.random();
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{							
			document.forms[0].action=window.location;
			document.forms[0].target="";
			document.forms[0].submit();
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function gotolocation(locationpath)
{
	document.forms[0].action=locationpath;
	document.forms[0].target="";
	document.forms[0].submit();	
}
function secure_signout()
{
	var xmlHttp;		
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	//url="https://www.thatsmyscript.com/ajax_logout.php";
	url="http://www.thatsmyscript.com/ajax_logout.php";
	url=url+"?sid="+Math.random();
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{							
			document.forms[0].action=window.location;
			document.forms[0].target="";
			document.forms[0].submit();
		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function openUpload(obj)
{
	var xmlHttp;		
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	url="ajax_checklogin.php";
	url=url+"?sid="+Math.random();
	xmlHttp.onreadystatechange=function()
	{		
		if (xmlHttp.readyState==4)
		{				
			if(xmlHttp.responseText==1)
			{					
				document.forms[0].action="upload";
				document.forms[0].submit();
			}
			else
			{
				document.getElementById("loginRedirectURL").value="http://www.thatsmyscript.com/upload";
				openSignin();				
				//return hs.htmlExpand(obj,{ objectType: 'ajax' });
			}			
		}					
	}		
	xmlHttp.open("GET",url,true) ;
	xmlHttp.send(null);		
}

function nl2br (str, is_xhtml) {   
    var breakTag = ''; 
    breakTag = '<br />';
    if (typeof is_xhtml != 'undefined' && !is_xhtml) {
        breakTag = '<br>';
    }
 
    return (str + '').replace(/([^>]?)\n/g, '$1'+ breakTag +'\n');
}
function findCharCount(txtB,displayCont,max) 
{		
	var max_length = max;
	var textBox = eval("document.FrmEditAboutMe."+txtB).value; 
	var charleft = document.getElementById(displayCont).innerHTML; 
	
	if(textBox.length > max_length) 
	{
		var text = textBox.substring(0, max_length);
		charleft = 0;
		eval("document.FrmEditAboutMe."+txtB).value = text;
		setTimeout("findCharCount('"+txtB+"','"+displayCont+"',"+max_length+")",100);
	} 
	else 
	{ 
		document.getElementById(displayCont).innerHTML = textBox.length;
		setTimeout("findCharCount('"+txtB+"','"+displayCont+"',"+max_length+")",100);
	}  
}
function setCharCount(txtB,max) 
{		
	var max_length = max;
	var textBox = eval("document.forms[0]."+txtB).value; 	
	if(textBox.length > max_length) 
	{
		var text = textBox.substring(0, max_length);
		charleft = 0;
		eval("document.forms[0]."+txtB).value = text;
		setTimeout("setCharCount('"+txtB+"',"+max_length+")",100);
	} 
	else 
	{ 
		setTimeout("setCharCount('"+txtB+"',"+max_length+")",100);
	}  
}
function keyDownEvent(e)
{
	var e=window.event?event:e;			
	var srcElement=window.event?e.srcElement.id:e.target.id;
	var srcID=window.event?e.srcElement:e.target;	
	if(e.keyCode == 13 && (srcElement == 'TxtSearch'|| srcElement=="TxtInnerSearch"))
	{
		searchSite();
	}
	else if(e.keyCode == 13)
	{		
		if(document.getElementById("loginbox").style.display=="none")
		{			
			if(document.getElementById("divAdSuggestions"))
			{
				if(document.getElementById("divAdSuggestions").style.display=="block")
				{
					if(document.getElementById("ancsug"+suggestBlockId))
					{
						var clickFun = document.getElementById("ancsug"+suggestBlockId).onclick;				
						document.getElementById("ancsug"+suggestBlockId).onclick();
						suggestBlockId=0;
					}
				}				
				else if(document.getElementById("profBox") && document.getElementById("profBox").style.display=="block")
				{
					if(document.getElementById("ancProfsug"+suggestBlockId))
					{
						var clickFun = document.getElementById("ancProfsug"+suggestBlockId).onclick;				
						document.getElementById("ancProfsug"+suggestBlockId).onclick();
						document.getElementById("profBox").style.display="none"
						suggestBlockId=0;
					}
				}
				else if(srcElement=="TxtCountry" && document.forms[0].HFCountryId.value>0)
				{
					addCountries();
				}
				else if(srcElement=="TxtRegion" && document.forms[0].HFRegionId.value>0)
				{
					loadCountryToRegion();
				}
				else if(srcElement.substring(0,12).toLowerCase()=="searchresult")
				{
					window.location=document.getElementById(srcElement).href;
					searchBlockID=0;
				}
				else if(document.forms[0].name=="FrmUploadFilm")
				{
					uid=document.FrmUploadFilm.APC_UPLOAD_PROGRESS.value
					//startProgress(uid);
					uploadVideoStart();
				}
				else if(document.forms[0].name=="FrmRegister")
				{
					//checkBeforeRegister();
				}
			}
			else if(document.getElementById("divSuggestions"))
			{
				if(document.getElementById("divSuggestions").style.display=="block")
				{
					if(document.getElementById("ancsug"+suggestBlockId))
					{
						var clickFun = document.getElementById("ancsug"+suggestBlockId).onclick;				
						document.getElementById("ancsug"+suggestBlockId).onclick();
						suggestBlockId=0;
					}
				}								
			}				
			else if(srcElement=="TxtCountry" && document.forms[0].HFCountryId.value>0)
			{
				addCountries();
			}
			else if(srcElement=="TxtRegion" && document.forms[0].HFRegionId.value>0)
			{
				loadCountryToRegion();
			}
			else if(srcElement.substring(0,12).toLowerCase()=="searchresult")
			{
				window.location=document.getElementById(srcElement).href;
				searchBlockID=0;
			}
			else if(document.forms[0].name=="FrmUploadFilm")
			{
				uid=document.FrmUploadFilm.APC_UPLOAD_PROGRESS.value
				//startProgress(uid);
				uploadVideoStart();
			}
			else if(document.forms[0].name=="FrmRegister")
			{
				//checkBeforeRegister();
			}
		}
	}
	else if(e.keyCode==40 || e.keyCode==98)
	{	
		if(document.getElementById("divAdSuggestions"))
		{			
			if(document.getElementById("divAdSuggestions").style.display=="block")
			{
				searchBlockID=0;
				suggestBlockId=parseInt(suggestBlockId)+1;
				if(document.getElementById("ancsug"+suggestBlockId))
				{					
					document.getElementById("ancsug"+suggestBlockId).className="suggestActive";	
					document.getElementById("ancsug"+suggestBlockId).focus();				
				}
				else
				{							
					prevSuggestBlockId=parseInt(suggestBlockId)-1;	
					if(document.getElementById("ancsug"+prevSuggestBlockId))
					{
						document.getElementById("ancsug"+prevSuggestBlockId).className="suggestInactive";
					}
					suggestBlockId=1;	
					document.getElementById("ancsug1").className="suggestActive";						
					document.getElementById("ancsug1").focus();				
				}				
				if(suggestBlockId>1)
				{
					prevSuggestBlockId=parseInt(suggestBlockId)-1;					
					if(document.getElementById("ancsug"+prevSuggestBlockId))
					{
						document.getElementById("ancsug"+prevSuggestBlockId).className="suggestInactive";
					}					
				}
			}
			else if((document.getElementById("profBox")) && (document.getElementById("profBox").style.display=="block"))
			{
				searchBlockID=0;
				suggestBlockId=parseInt(suggestBlockId)+1;
				if(document.getElementById("ancProfsug"+suggestBlockId))
				{					
					document.getElementById("ancProfsug"+suggestBlockId).className="profBox_active";	
					document.getElementById("ancProfsug"+suggestBlockId).focus();				
				}
				else
				{							
					prevSuggestBlockId=parseInt(suggestBlockId)-1;	
					if(document.getElementById("ancProfsug"+prevSuggestBlockId))
					{
						document.getElementById("ancProfsug"+prevSuggestBlockId).className="profBox_inactive";
					}
					suggestBlockId=1;	
					document.getElementById("ancProfsug1").className="profBox_active";						
					document.getElementById("ancProfsug1").focus();				
				}				
				if(suggestBlockId>1)
				{
					prevSuggestBlockId=parseInt(suggestBlockId)-1;					
					if(document.getElementById("ancProfsug"+prevSuggestBlockId))
					{
						document.getElementById("ancProfsug"+prevSuggestBlockId).className="profBox_inactive";
					}					
				}
			}			
			else
			{
				suggestBlockId=0;			
				if(document.getElementById("searchresultbox").style.display=="block")
				{					
					searchBlockID=parseInt(searchBlockID)+1;				
					if(document.getElementById("searchresult_"+searchBlockID))
					{					
						document.getElementById("searchresult_"+searchBlockID).className="searchActive";	
						document.getElementById("searchresult_"+searchBlockID).focus();				
					}
					else
					{							
						prevSearchBlockId=parseInt(searchBlockID)-1;	
						if(document.getElementById("searchresult_"+prevSearchBlockId))
						{
							document.getElementById("searchresult_"+prevSearchBlockId).className="searchnormal";
						}
						searchBlockID=1;	
						document.getElementById("searchresult_1").className="searchActive";						
						document.getElementById("searchresult_1").focus();				
					}				
					if(searchBlockID>1)
					{
						prevSearchBlockId=parseInt(searchBlockID)-1;					
						if(document.getElementById("searchresult_"+prevSearchBlockId))
						{
							document.getElementById("searchresult_"+prevSearchBlockId).className="searchnormal";
						}					
					}				
				}
			}
		}
		else if(document.getElementById("divSuggestions"))
		{			
			if(document.getElementById("divSuggestions").style.display=="block")
			{
				searchBlockID=0;
				suggestBlockId=parseInt(suggestBlockId)+1;
				if(document.getElementById("ancsug"+suggestBlockId))
				{					
					document.getElementById("ancsug"+suggestBlockId).className="suggestActive";	
					document.getElementById("ancsug"+suggestBlockId).focus();				
				}
				else
				{							
					prevSuggestBlockId=parseInt(suggestBlockId)-1;	
					if(document.getElementById("ancsug"+prevSuggestBlockId))
					{
						document.getElementById("ancsug"+prevSuggestBlockId).className="suggestInactive";
					}
					suggestBlockId=1;	
					document.getElementById("ancsug1").className="suggestActive";						
					document.getElementById("ancsug1").focus();				
				}				
				if(suggestBlockId>1)
				{
					prevSuggestBlockId=parseInt(suggestBlockId)-1;					
					if(document.getElementById("ancsug"+prevSuggestBlockId))
					{
						document.getElementById("ancsug"+prevSuggestBlockId).className="suggestInactive";
					}					
				}
			}
			else
			{
				suggestBlockId=0;			
				if(document.getElementById("searchresultbox").style.display=="block")
				{
					searchBlockID=parseInt(searchBlockID)+1;				
					if(document.getElementById("searchresult_"+searchBlockID))
					{					
						document.getElementById("searchresult_"+searchBlockID).className="searchActive";	
						document.getElementById("searchresult_"+searchBlockID).focus();				
					}
					else
					{							
						prevSearchBlockId=parseInt(searchBlockID)-1;	
						if(document.getElementById("searchresult_"+prevSearchBlockId))
						{
							document.getElementById("searchresult_"+prevSearchBlockId).className="searchnormal";
						}
						searchBlockID=1;	
						document.getElementById("searchresult_1").className="searchActive";						
						document.getElementById("searchresult_1").focus();				
					}				
					if(searchBlockID>1)
					{
						prevSearchBlockId=parseInt(searchBlockID)-1;					
						if(document.getElementById("searchresult_"+prevSearchBlockId))
						{
							document.getElementById("searchresult_"+prevSearchBlockId).className="searchnormal";
						}					
					}				
				}
			}
		}
		else
		{
			suggestBlockId=0;			
			if(document.getElementById("searchresultbox").style.display=="block")
			{				
				searchBlockID=parseInt(searchBlockID)+1;
				if(document.getElementById("searchresult_"+searchBlockID))
				{					
					document.getElementById("searchresult_"+searchBlockID).className="searchActive";	
					document.getElementById("searchresult_"+searchBlockID).focus();				
				}
				else
				{							
					prevSearchBlockId=parseInt(searchBlockID)-1;	
					if(document.getElementById("searchresult_"+prevSearchBlockId))
					{
						document.getElementById("searchresult_"+prevSearchBlockId).className="searchnormal";
					}
					searchBlockID=1;	
					document.getElementById("searchresult_1").className="searchActive";						
					document.getElementById("searchresult_1").focus();				
				}				
				if(searchBlockID>1)
				{
					prevSearchBlockId=parseInt(searchBlockID)-1;					
					if(document.getElementById("searchresult_"+prevSearchBlockId))
					{
						document.getElementById("searchresult_"+prevSearchBlockId).className="searchnormal";
					}					
				}				
			}
		}		
	}
	else if(e.keyCode==38 || e.keyCode==104) 
	{
		if(document.getElementById("divAdSuggestions"))
		{
			if(document.getElementById("divAdSuggestions").style.display=="block")
			{
				suggestBlockId=parseInt(suggestBlockId)-1;
				if(document.getElementById("ancsug"+suggestBlockId))
				{					
					document.getElementById("ancsug"+suggestBlockId).className="suggestActive";	
					document.getElementById("ancsug"+suggestBlockId).focus();
				}
				else
				{
					suggestBlockId=1;					
					document.getElementById("ancsug1").className="suggestActive";
					document.getElementById("ancsug1").focus();
				}
				nextSuggestBlockId=parseInt(suggestBlockId)+1;
				if(document.getElementById("ancsug"+nextSuggestBlockId))
				{
					document.getElementById("ancsug"+nextSuggestBlockId).className="suggestInactive";		
				}
			}
			else if((document.getElementById("profBox")) && (document.getElementById("profBox").style.display=="block"))
			{
				suggestBlockId=parseInt(suggestBlockId)-1;
				if(document.getElementById("ancProfsug"+suggestBlockId))
				{					
					document.getElementById("ancProfsug"+suggestBlockId).className="profBox_active";	
					document.getElementById("ancProfsug"+suggestBlockId).focus();
				}
				else
				{
					suggestBlockId=1;					
					document.getElementById("ancProfsug1").className="profBox_active";
					document.getElementById("ancProfsug1").focus();
				}
				nextSuggestBlockId=parseInt(suggestBlockId)+1;
				if(document.getElementById("ancProfsug"+nextSuggestBlockId))
				{
					document.getElementById("ancProfsug"+nextSuggestBlockId).className="profBox_inactive";		
				}
			}
			else if(document.getElementById("searchresultbox").style.display=="block")
			{
				searchBlockID=parseInt(searchBlockID)-1;
				if(document.getElementById("searchresult_"+searchBlockID))
				{					
					document.getElementById("searchresult_"+searchBlockID).className="searchActive";	
					document.getElementById("searchresult_"+searchBlockID).focus();
				}
				else
				{
					searchBlockID=1;					
					document.getElementById("searchresult_1").className="searchActive";
					document.getElementById("searchresult_1").focus();
				}
				nextSearchBlockId=parseInt(searchBlockID)+1;
				if(document.getElementById("searchresult_"+nextSearchBlockId))
				{
					document.getElementById("searchresult_"+nextSearchBlockId).className="searchnormal";		
				}											
			}
		}
		else if(document.getElementById("divSuggestions"))
		{
			if(document.getElementById("divSuggestions").style.display=="block")
			{
				suggestBlockId=parseInt(suggestBlockId)-1;
				if(document.getElementById("ancsug"+suggestBlockId))
				{					
					document.getElementById("ancsug"+suggestBlockId).className="suggestActive";	
					document.getElementById("ancsug"+suggestBlockId).focus();
				}
				else
				{
					suggestBlockId=1;					
					document.getElementById("ancsug1").className="suggestActive";
					document.getElementById("ancsug1").focus();
				}
				nextSuggestBlockId=parseInt(suggestBlockId)+1;
				if(document.getElementById("ancsug"+nextSuggestBlockId))
				{
					document.getElementById("ancsug"+nextSuggestBlockId).className="suggestInactive";		
				}
			}
			else if(document.getElementById("searchresultbox").style.display=="block")
			{
				searchBlockID=parseInt(searchBlockID)-1;
				if(document.getElementById("searchresult_"+searchBlockID))
				{					
					document.getElementById("searchresult_"+searchBlockID).className="searchActive";	
					document.getElementById("searchresult_"+searchBlockID).focus();
				}
				else
				{
					searchBlockID=1;					
					document.getElementById("searchresult_1").className="searchActive";
					document.getElementById("searchresult_1").focus();
				}
				nextSearchBlockId=parseInt(searchBlockID)+1;
				if(document.getElementById("searchresult_"+nextSearchBlockId))
				{
					document.getElementById("searchresult_"+nextSearchBlockId).className="searchnormal";		
				}											
			}
		}
		else if(document.getElementById("searchresultbox").style.display=="block")
		{
			searchBlockID=parseInt(searchBlockID)-1;
			if(document.getElementById("searchresult_"+searchBlockID))
			{					
				document.getElementById("searchresult_"+searchBlockID).className="searchActive";	
				document.getElementById("searchresult_"+searchBlockID).focus();
			}
			else
			{
				searchBlockID=1;					
				document.getElementById("searchresult_1").className="searchActive";
				document.getElementById("searchresult_1").focus();
			}
			nextSearchBlockId=parseInt(searchBlockID)+1;
			if(document.getElementById("searchresult_"+nextSearchBlockId))
			{
				document.getElementById("searchresult_"+nextSearchBlockId).className="searchnormal";		
			}											
		}
	}
	else
	{
		suggestBlockId=0;
		searchBlockID=0;
	}	
}
function closeAutoSuggest()
{
	if(document.getElementById("divAdSuggestions"))
	{
		document.getElementById("divAdSuggestions").style.display="none";
	}
	if(document.getElementById("divAdSuggestions"))
	{
		document.getElementById("divAdSuggestions").style.display="none";		
	}
	suggestBlockId = 0;
}
function checkIfNull(txtB,errImg) 
{
	if(txtB.value.replace(/ /g,"")=="")
	{
		 document.getElementById(errImg).style.visibility="visible";
		 //document.getElementById(errImg+"Text").style.visibility="visible";
		 return false;
	}
	else
	{
		document.getElementById(errImg).style.visibility="hidden";
		return true;
	}
}

//Function to scroll a div
function scrollUp(divcontent,divcontainer)
{
	divcontentObj=document.getElementById(divcontent);
	divcontainerObj=document.getElementById(divcontainer);	
	contantH=divcontentObj.offsetHeight;
	containerH=divcontainerObj.offsetHeight;	
	if(contantH>containerH)
	{
	
			diffH=contantH-containerH;			
			if(diffH > scHeight *-1)
			{
				scHeight=scHeight+3*-2;
				divcontentObj.style.top=scHeight+"px";	
				scrollFun=setTimeout("scrollUp('"+divcontent+"','"+divcontainer+"')",100);		
			}
			else
			{
				document.getElementById("scrollup").style.visibility="hidden";
				clearTimeout(scrollFun);
			}
	}	
	if(scHeight<0)
	{
		document.getElementById("scrolldown").style.visibility="visible";
	}
}

function clearScroll()
{
	clearTimeout(scrollFun);
}

//Function to scroll a div
function scrollDown(divcontent,divcontainer)
{
	divcontentObj=document.getElementById(divcontent);
	divcontainerObj=document.getElementById(divcontainer);	
	contantH=divcontentObj.offsetHeight;
	containerH=divcontainerObj.offsetHeight;				
	if(scHeight<0)
	{
		scHeight=scHeight+3*2;
		divcontentObj.style.top=scHeight+"px";	
		scrollFun=setTimeout("scrollDown('"+divcontent+"','"+divcontainer+"')",100);		
	}
	else
	{
		document.getElementById("scrolldown").style.visibility="hidden";
		clearTimeout(scrollFun);
	}
	diffH=contantH-containerH;				
	if(contantH>containerH && scHeight*-1 < diffH)
	{
		document.getElementById("scrollup").style.visibility="visible";
	}
		
}
//Ads error messages
function openAdshelp(obj)
{
	if(document.getElementById("divAdsErrorMsgbox"))
	{ 
		var helpdiv = document.getElementById('divAdsErrorMsgbox');
		helpdiv.style.display="none";
		helpdiv.style.top=Top(obj)+10+"px";
		helpdiv.style.left=Left(obj)+20+"px";
		var msg="";
		msg=obj.getAttribute('adsMsg');
		if(msg!="")
		{
			helpdiv.style.display="block";
			helpdiv.innerHTML=msg;
		}
	}
}
function hideAdshelp(obj)
{
	if(document.getElementById("divAdsErrorMsgbox"))
	{
		document.getElementById("divAdsErrorMsgbox").style.display="none";
	}
}
function adsErrorMsgSet(objName,attr,msg)
{	
	if(document.getElementById(objName))
	{
		var obj=document.getElementById(objName);
		obj.onmouseover=function() 
		{			
			openAdshelp(obj)
		}
		obj.onmouseout=function() 
		{
			hideAdshelp(obj)
		}
		obj.setAttribute(attr,msg);
	}
}
//Ads error messages ends here

/* badges page functions starts here*/
function selectBadge(image)
{
	var username = document.getElementById("HFBadgeUserName").value;
	document.getElementById("divBadgeEmbed").style.display="block";
	document.getElementById("txtBadge").value="<a href='http://www.thatsmyscript.com/"+username+"'><img src='http://www.thatsmyscript.com/images/badges/"+image+".png' border='0' alt='thatsmyscript' /></a>";
	//document.getElementById("txtBadge").value="<a href='http://www.thatsmyscript.com/"+username+"'><img src='http://192.168.0.10:81/tmsnew/images/badges/"+image+".png' border='0' alt='thatsmyscript' /></a>";
	document.getElementById("divBadgePrev").innerHTML="<a href='http://www.thatsmyscript.com/"+username+"'><img src='images/badges/"+image+".png' border='0' alt='thatsmyscript' /></a>";
}
/* badges page functions ends here*/
function pageSubmitter(page)
{
	if( document.forms[0])
	{
		document.forms[0].action=page;
		document.forms[0].submit()
	}
	else
	{
		window.location=page;
	}
}



function removeNonAplha(e,obj)
{
	var keynum;
	var keychar;
	var numcheck;	
	var illegalChars= /[\(\)\<\>\,\;\:\\\/\"\[\]&\!\#\@\$\%\^\&\*\_\{\'\`\~\}\+\|\-\=\?]/;
	if(window.event) 
	{
		keynum = e.keyCode;
	}
	else if(e.which) 
	{
		keynum = e.which;
	}		
	if(keynum==8 || e.charCode==0)
	{
		return true;
	}	
	keychar = String.fromCharCode(keynum);
	if(illegalChars.test(keychar))
	{
		return false;
	}
	else if(obj.value.indexOf(".")>=0 && keychar==".")
	{	
		return false;
	}
	else if(keynum==32)
	{
		return false;
	}
	else
	{
		return true;
	}
}
function alphanumeric(alphane)
{
	var numeric = alphane;
	var dotCount = 0;
	for(var j=0; j<numeric.length; j++)
	{
		var alphaa = numeric.charAt(j);
		var hh = alphaa.charCodeAt(0);		
		if((hh > 47 && hh<58) || (hh > 64 && hh<91) || (hh > 96 && hh<123) || (hh ==46))
		{
			/* if((hh ==46))
			{				
				return false;
			} */	
			//return true;
		}
		else	
		{			
			return false;
		}
	} 
	return true;
}
function loginErrSet(objName,msg)
{	
	if(document.getElementById(objName))
	{
		var obj=document.getElementById(objName);
		obj.onmouseover=function() 
		{			
			openloginErrMsg(obj);
		}
		obj.onmouseout=function() 
		{
			hideloginErrMsg(obj)
		}
		obj.setAttribute("err",msg);
	}
}
function hideloginErrMsg(obj)
{
	if(document.getElementById("divErrorMsgbox"))
	{
		document.getElementById("divErrorMsgbox").style.display="none";
	}
}
function openloginErrMsg(obj)
{
	if(document.getElementById("divErrorMsgbox"))
	{ 
		var helpdiv = document.getElementById('divErrorMsgbox');
		helpdiv.style.display="none";
		helpdiv.style.top=Top(obj)+10+"px";
		helpdiv.style.left=Left(obj)+20+"px";
		var msg="";
		msg=obj.getAttribute('err');
		if(msg!="")
		{
			helpdiv.style.display="block";
			helpdiv.innerHTML=msg;
		}
	}
}
//share links
function shareVideo(url)
{
 newwindow=window.open(url,'Share','menubar=0,scrollbars=1,resizable=1,height=500,width=800');
if (window.focus) {newwindow.focus()}

}
///
//right sside bar ads
function getNextAdv(index,videoCatgID)
{
	var premCount=0;
	premCount=document.getElementById("HFPremCount").value;
	var xmlHttp;		
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	var advIDS=new Array(3);	
	advIDS[0]=document.getElementById("HFRightAdv1").value;
	if(document.getElementById("HFRightAdv2"))
	{
		advIDS[1]=document.getElementById("HFRightAdv2").value;
	}
	else
	{
		advIDS[1]=0;
	}
	if(document.getElementById("HFRightAdv3"))
	{
		advIDS[2]=document.getElementById("HFRightAdv3").value;
	}
	else
	{
		advIDS[2]=0;
	}
	if(document.getElementById("HFRightAdv4"))
	{
		advIDS[3]=document.getElementById("HFRightAdv4").value;
	}
	else
	{
		advIDS[3]=0;
	}	
	totalADS=document.getElementById("HFTotalADS").value;
	url="ajax_rightads.php?param="+advIDS+"&param1="+index+"&param2="+videoCatgID+"&param3="+totalADS+"&param4="+premCount;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=function()
	{
		if (xmlHttp.readyState==4)
		{
			if(xmlHttp.responseText.replace(/ /g,"")!="")
			{
				document.getElementById("ULRightAdv"+index).innerHTML=xmlHttp.responseText;				
			}
			document.getElementById("loader"+index).style.visibility="hidden";
		}
		else
		{			
			document.getElementById("loader"+index).style.visibility="visible";
		}
	}		
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);		
}


// upgrade account starts here
function upgradeSummary(type)
{
	if(document.getElementById("HFUserId").value!=0)
	{
		document.forms[0].action="upgrade_summary.php?type="+type;
		document.forms[0].submit();		
	}	
}


function upgrade(id,name,type)
{	
	document.getElementById("HFSubscribeId").value=id;
	document.getElementById("HFSubscribeName").value=name;
	if(type==0)
	{
		if(document.getElementById("ChkDwnBackup").checked)
		{
			type = 2;
		}
		else
		{
			type = 1;
		}
	}
	
	if(document.getElementById("HFUserId").value!=0)
	{
	    if(type!=3)
		{			
			document.forms[0].action="upgrade_payment.php?type="+type;
			//document.forms[0].action="upgrade_paymentDB.php?id="+id+"&type="+type;
			document.forms[0].submit();			
		}
		else
		{
			if(document.getElementById("HFBackup").value==0)
			{
				document.forms[0].action="upgrade_payment.php?type="+type;
				//document.forms[0].action="upgrade_paymentDB.php?id="+id+"&type="+type;
				document.forms[0].submit();
			}
			else
			{
				alert("You Are Already Subscribed"); 
			}
		}
	}	
}

// upgrade account Ends here
function extractQuerystring( url,name )
{
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( url);
  if( results == null )
    return "";
  else
    return results[1];
}
//right block ads
function openRightTile(index)
{
	for(i=1;i<=4;i++)
	{
		tileObj=$("#spanRightTileContent_"+i);
		if(tileObj.css("display")=="block")
		{
			if(i!=index)
			tileObj.slideUp(100);
			if(i==1)
			{
				$("#LbRightTile_1").css("background-image","url('images/blogs/righttilescurved_bg.jpg')");
			}
			else
			{
				$("#LbRightTile_"+i).css("background-image","url('images/blogs/righttiles_bg.jpg')");
			}
			$("#LbRightTile_"+i).css("color","#000");
		}
	}
	if($("#spanRightTileContent_"+index).css("display")=="none")
		$("#spanRightTileContent_"+index).slideDown(100);
	if(index==1)
	{
		$("#LbRightTile_1").css("background-image","url('images/blogs/righttilescurved_activebg.jpg')");
	}
	else
	{
		$("#LbRightTile_"+index).css("background-image","url('images/blogs/righttiles_activebg.jpg')");
	}
	$("#LbRightTile_"+index).css("color","#fff");
}
///////
function getCheckedValue(radioObj) 
{
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return 0;
}
function initTmsAds()
{
	setInterval(function(){showTmsAds(3)},11000);
	setInterval(function(){showTmsAds(1)},8000);
	setInterval(function(){showTmsAds(4)},5000);
	setInterval(function(){showTmsAds(2)},14000);
}
function showTmsAds(blockIndex) 
{
	cont="divBlogAds_"+blockIndex;
    var $active = $('#'+cont+' DIV.active');
    if ( $active.length == 0 ) $active = $('#'+cont+' DIV:last');
    var $next =  $active.next().length ? $active.next()
        : $('#'+cont+' DIV:first');
    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}
function initSlideShow()
{
	var currentPosition = 0;
	var slideWidth = 854;
	var slides = $('.slide');
	var numberOfSlides = slides.length;
	// Remove scrollbar in JS
	$('#slidesContainer').css('overflow', 'hidden');
	// Wrap all .slides with #slideInner div
	slides
    .wrapAll('<div id="slideInner"></div>')
    // Float left to display horizontally, readjust .slides width
	.css({
      'float' : 'left',
      'width' : slideWidth
    });
	// Set #slideInner width equal to total width of all slides
	$('#slideInner').css('width', slideWidth * numberOfSlides);
	// Insert controls in the DOM
	$('#divScroller')
	.prepend('<a id="link_left"  class="control" style="cursor:pointer;" ></a>')
    .append('<a id="link_right"  class="control" style="cursor:pointer;" ></a>');

	$('.slidelink').bind('click', function(){	
		currentPosition = parseInt($(this).attr('id'));
	});
	// Create event listeners for .controls clicks
	$('.control').bind('click', function(){
		// Determine new position
		currentPosition = ($(this).attr('id')=='link_right') ? currentPosition+1 : currentPosition-1;
		if(currentPosition==-1)
		{
			currentPosition = 4;
		}
		else if(currentPosition==5)
		{
			currentPosition = 0;
		}
		// Determine next position
		nextPosition = currentPosition+1;
		//clearTimeout(slidecontinue);	
		// Move slideInner using margin-left
		$('#slideInner').animate({
		  'marginLeft' : slideWidth*(-currentPosition)
		});
	});
}

function subscribeTabs(type)
{
	if(document.getElementById("divBookshelf") && document.getElementById("divDownloads"))
	{
		scroll(0,0);
		$("#divBookshelf").hide();
		$("#divDownloads").hide();
		$(".LbDownloads").css('background-image', 'url(images/subscribe/downloads_inactive_btn.png)');
		$(".LbBookshelf").css('background-image', 'url(images/subscribe/bookshelf_inactive_btn.png)');
		if(type==1)
		{
			window.location="#downloads";
			
			$("#divDownloads").show();
			$(".LbDownloads").css('background-image', 'url(images/subscribe/downloads_active_btn.png)');
		}
		else if(type==2)
		{
			window.location="#bookshelf";
			$("#divBookshelf").show();
			$(".LbBookshelf").css('background-image', 'url(images/subscribe/bookshelf_active_btn.png)');
		}
	}
}
function downloadPref(k,t)
{
	if(t==1 || t==3)
	{
		xmlHttp=GetXmlHttpObject();
			if(xmlHttp==null)
			{
				alert("Your browser does not support AJAX..")
				return;
			}
			
			var url="downloads/ajax_prepPrefDownload.php";
			url=url+"?t="+t+"&key="+k;	
			url=url+"&sid="+Math.random();
			xmlHttp.onreadystatechange=function()
			{
				if (xmlHttp.readyState==4)
				{					
					if (xmlHttp.status== 200)
					{	
						$("#pageshader").hide();
						$("#imgOverlayLoader").hide();
						document.forms[0].action="downloadDB.php?type="+t+"&key="+k;
						document.forms[0].submit();
						
					}
				}
				else
				{
					scroll(0,0);
					$("#pageshader").show();
					$("#imgOverlayLoader").show();
				}	
			}
			xmlHttp.open("get",url,true);
			xmlHttp.send(null);
	}
	else if(t==2)
	{
		document.forms[0].action="downloadDB.php?type=2&key="+k;
		document.forms[0].submit();
	}
}

