//ToDO:Remove this after updateing drawskin-IE
// Skin MouseOver for IE
blnMouseOvr = false;
var imgId
function BrowserImg(imgId,TdId) {
//	imgId=imgId;
	if (!blnMouseOvr){
		blnMouseOvr = true;
		document[imgId].src ="/images/interface.gif"; 
	}
}
function RemoveBrowserImg(imgId) {
	blnMouseOvr = false;
	document[imgId].src = "/images/null.gif";
}
//endToDO:Remove this after updateing drawskin-IE




var guide = GetParam('guide');
var guidename = GetParam('guidename');
var bannerid =	GetParam('bannerid');
var redir = GetParam('redir');
var redirex = GetParam('redirex');
var mailid = GetParam('mailid');
var gstrParameters
var ServerName = location.host;
var onloadHeight;
var onloadWidth;
var curSkin = -1;
var blnShowOverLay = false;
if (isNS) {
	onloadHeight = window.innerHeight;
	onloadWidth = window.innerWidth;
}


function GetParam(ParamName) 
{
	var	StartInd=0
	var	URLtoParse	= window.document.location.href
	var	ParamLen = ParamName.length	+ 1
	var	EndInd=0
	var lwrURLtoParse
	
	ParamName =	ParamName.toLowerCase()
	lwrURLtoParse	= URLtoParse.toLowerCase()	
	StartInd = lwrURLtoParse.indexOf(ParamName + '=')
	if (StartInd ==	-1) return ''
	EndInd = lwrURLtoParse.indexOf('&', StartInd + 1)
	if (EndInd == -1) EndInd = lwrURLtoParse.length - (StartInd + ParamLen)
	else EndInd = EndInd - (StartInd + ParamLen)
	return unescape(URLtoParse.substr(StartInd + ParamLen, EndInd))
}



function MakeUI(Prefix) {
	if (Prefix == '' ||	Prefix.length != 2){
		Prefix = 'st'
	}
	var ui = HbCtl.GetHbr('options','ui');
	if (ui == '' || ui == null || ui=='undefined') {
		ui = GetCookie('ui');
		if (ui == '' || ui == null || ui=='undefined') {
			var	uid	= new Date();
			var	uidt = uid.getTime();
			var	uird = Math.round(Math.random()	* 1000000);
			ui = Prefix	+ '-' +	 uidt +	'-'	+ uird;
		}
		HbCtl.SetHbr('options','ui',ui);
	}
	if (GetCookie('ui') != ui) SetCookie('ui',ui);

	// Set the sample group in the cookie	
	if (CtlVer==2) {
		var sg = HbCtl.GetSampleGroup();
		if (GetCookie('sg') != sg) SetCookie('sg',sg);
	}
}



function OnLoadEvent() {
	var img =	GetParam('img');
	var imgpath = GetParam('imgpath');
	var paramimg = '';
	if (img != '') {
		paramimg = 'http://skins.hotbar.com/skins/xip/' + img.substring(0,4) + '/' + img + '.xip';
		var ParamName = 'img';
		}
	else if (imgpath != '') {
		paramimg = imgpath;
		var ParamName = 'imgpath';
	}
	if (HbCtl.GetHbr('options','firsttime') != 'no') HbCtl.SetHbr('options','firsttime','no');
	if (paramimg != ''){
		LoadSkin(paramimg)
		var urlLocation = GetUrl()
		var urlParams = ParamSet(ParamName,'')
			urlParams = urlParams.substr(1,urlParams.length-1)
			if (urlParams != ''){urlParams = '?' + urlParams}
		location.replace(urlLocation + urlParams)
	}	
}

function GetUrl() {
	var slocation = location.host + location.pathname
	return slocation;
}



function ParamListInit(){
	var strLocation = window.document.location.href;
	qPos = strLocation.indexOf('?');
	if(qPos != -1){
		gstrParameters = unescape('&' + strLocation.substr(qPos+1,strLocation.length +1) + '&') 
	}
	else {
		gstrParameters = '&&'	
	}
}	



function ParamSet(ParamName,ParamValue){		
	ParamListInit();
	var lwrstrParameters = gstrParameters.toLowerCase();
	ParamNameStartPos = lwrstrParameters.indexOf('&' + ParamName + '=');
	if (ParamNameStartPos != - 1 ){ 		
		ParamValueStartPos = ParamNameStartPos + ParamName.length + 1;
		ParamValueEndPos = lwrstrParameters.indexOf('&',ParamValueStartPos)-1;
		if (ParamValueEndPos != -1){
			var LeftPart = lwrstrParameters.substr(0,ParamNameStartPos);
			var RightPart = lwrstrParameters.substr(ParamValueEndPos+1 ,lwrstrParameters.length-1);
			if (ParamValue != ''){ 
  				gstrParameters = LeftPart + '&' + ParamName + '=' + ParamValue + RightPart;
			}
			else {
				gstrParameters = LeftPart + RightPart; 			 		
			}
		}
	}
	else {
		 gstrParameters = gstrParameters + ParamName + '=' + ParamValue;  
	}
return gstrParameters;
}



function GetCookie(sName) 
{
	var aCookie = document.cookie.split(";");
	for (var i=0; i < aCookie.length; i++) 
	{
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0]) 
			return unescape(aCrumb[1]);
	}
	return null;
}



function SetCookie(sName, sVal) {
		var exp = new Date();
		var TenYears = exp.getTime() + ( 3650 * 24 * 3600 * 1000);
		exp.setTime(TenYears);
		if (isIE) document.cookie = sName + "=" + escape(sVal) + "; domain=hotbar.com; path=/; expires=" + exp.toGMTString();
		else if (isNS) document.cookie = sName + "=" + escape(sVal) + "; path=/; expires=" + exp.toGMTString();
}



function validemail(email) {
	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
	return (!reg1.test(email) && reg2.test(email))
}

function checkEmail(SubmitionURL,FormName) 
{ 
	var errmsg = 'Please check your email for mistakes and submit again';
	if (!(validemail(document[FormName].email.value))) {
		document[FormName].email.focus(); 
		alert(errmsg);
	}
	else {
		document[FormName].action = SubmitionURL
		document[FormName].submit();
	} 
}



function nohref() {
}

function HoveredStatus(txt) {
	window.status = txt;
	setTimeout('window.status = "Hotbar.com"',1800);
}


function resizeHandler() {	
	if (isNS) {
		if ((onloadHeight != window.innerHeight) || (onloadWidth != window.innerWidth)) {
			window.location.reload();
		}
	}
}



/*this functions belong to subscribe.asp file*/
function delMail()	{
	if(document.SubscribeForm.email.value == 'your email here'){
		document.SubscribeForm.email.value = '';
	}
}
function writeMail()	{
	if(document.SubscribeForm.email.value == ''){
		document.SubscribeForm.email.value = 'your email here';
	}
}

function clearIEgui() {
	if(curSkin != -1){
		HideOverlay(curSkin);
	}
}

function ShowOverlay(SkinImgNumber) {
	if(!(blnShowOverLay)){
		if(curSkin != -1){
			HideOverlay(curSkin);
		}
	
		eval('null' + SkinImgNumber + '.style.display = \'none\';');
		eval('iegui' + SkinImgNumber + '.style.display = \'\';');		
		HoveredStatus('LoadSkin')
		curSkin = SkinImgNumber;
		blnShowOverLay = true;
	}
}

function HideOverlay(SkinImgNumber) {
	if(blnShowOverLay){
		eval('iegui' + SkinImgNumber + '.style.display = \'none\';');						
		eval('null' + SkinImgNumber + '.style.display = \'\';');
		blnShowOverLay = false;
	}
}

function pgShowOverlay(SkinImg) {
	SkinImg.src ="/images/interface.gif"; 
	HoveredStatus("LoadSkin")
}

function pgHideOverlay(SkinImg) {
	SkinImg.src ="/images/null.gif"; 
}

function LoadThis(fp){
	//alert('Inside LoadThis with > ' + fp);
	fx = String(fp).replace(/.jpg$/,'.xip').replace('/jpg/','/xip/') //File Xip
	//alert('fx > '+ fx);	
	LoadSkin(fx)
}



function Set_HomePage()	{
	if (isIE) {
		if (CtlVer==2) {
			HbCtl.SetHomePage(); 
		}
		else {
			HbCtl.SetHomePage("");
		}
	}
	if (isNS)	{
		window.location.href="/site/sethome.htm";
	}
}


function openWindow(URL,NAME,W,H) {
	new Object()                                                                                                                                       ;
}

function copyr(ext){openWindow('/site/copyright.' + ext,'copyr','450','300')}	
function Infringement(ext){openWindow('/site/Infringement.' + ext,'Infring','450','300')}
function license(ext) {openWindow('/site/license.' + ext,'license','600','400')}
function privacy(ext) {openWindow('/site/privacy.' + ext,'privacy','630','400')}
function cont() {openWindow('/install/instcont.htm','cont','600','500')}	

function openTour()	{
	window.location.href = '/install/TourFrame.asp';	
}
