﻿var Search = {
	WasEdited: false,
	DefaultValue: null,
	sText: null,
	Init: function(){
		Search.DefaultValue = dojo.byId("SearchTextDefaultValue").value;
		Search.sText = dojo.byId("SearchText");
		Search.sText.value = Search.DefaultValue;
		dojo.connect(Search.sText, "onmouseover", Search, "Over");
		dojo.connect(Search.sText, "onmouseout", Search, "Out");
		dojo.connect(Search.sText, "onclick", Search, "Edit");
		//dojo.connect(dojo.byId("SearchBtn"), "onclick", Search, "DoSearch");
	},
	Over: function(){
		Search.sText.className = 'txt Selected';
		if (Search.sText.value==Search.DefaultValue) Search.sText.value = '';
	},
	Out: function(){ 
		if (Search.WasEdited) return;
		Search.sText.className = 'txt';
		Search.sText.value = Search.DefaultValue;
	},
	Edit: function(){ Search.WasEdited = true; },
	//ListenToKeyPress: function(){ if (event.keyCode==dojo.keys.ENTER) Search.DoSearch(); },
	Validate: function(){
		if ((Search.sText.value.length<=0) || (Search.sText.value==Search.DefaultValue)) {
			alert(dojo.byId("YouHaveToFillStringToSearchValue").value);
			return false
		} else return true;
	}
}

dojo.addOnLoad(Search.Init);

//###########################################################################################################################

dojo.addOnLoad(function(){
	var Ad = dojo.byId('TowerAd');
	if (Ad){
		var clientWidth = ieCompatTest().clientWidth;
			if (clientWidth < 990)  { Ad.style.display = 'none'; return false }
		var contentWidth = 750;
		var contentLeft = (clientWidth - contentWidth) / 2
		var adCords = dojo.coords(Ad);
		var left = contentLeft - adCords.w - 10;
			if (left<0) left=0;
		Ad.style.left = left;
	}
});

//###########################################################################################################################

var IfIE = CheckIfIE();
/*------------------------------------------------------*/
function CheckIfIE(){
	var browser;
	/*-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - */
	if (CheckIfIE_checkIt('konqueror')) browser = "Konqueror";
	else if (CheckIfIE_checkIt('safari')) browser = "Safari"
	else if (CheckIfIE_checkIt('omniweb')) browser = "OmniWeb"
	else if (CheckIfIE_checkIt('opera')) browser = "Opera"
	else if (CheckIfIE_checkIt('webtv')) browser = "WebTV";
	else if (CheckIfIE_checkIt('icab')) browser = "iCab"
	else if (CheckIfIE_checkIt('msie')) browser = "Internet Explorer"
	else if (!CheckIfIE_checkIt('compatible')) browser = "Netscape Navigator"
	else browser = "An unknown browser";
	return (browser=="Internet Explorer")
}
/*-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
function CheckIfIE_checkIt(string)
{
	var detect = navigator.userAgent.toLowerCase();
	/*-  -  -  -  -  -  -  -  -  -  -  -  -  -  -  -  - */
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}
/*------------------------------------------------------*/
function CheckAndPrintSideAds(){	//PageLength is defined just before the call to this func
	var clientWidth = ieCompatTest().clientWidth;
	var clientHeight = ieCompatTest().clientHeight;
	var contentWidth = 750;
	var adsWidth = 160;
	var adsHeight = 600;
	//------------------------------------------------------------------------------------
	var SideAds =  document.getElementById("SideAds");
	SideAds.style.width = adsWidth;
	SideAds.style.height= adsHeight;
	var sidePos = ((clientWidth-contentWidth)/2-adsWidth)*(0.95);
		if (isRTL) {
			if (sidePos>0) SideAds.style.left = sidePos;
			else		   SideAds.style.left = 0;
		} else {
			if (sidePos>0) SideAds.style.right = sidePos;
			else		   SideAds.style.right = 0;
		}
	var topPos = adsHeight*(0.45);
		if (PageLength<=2) topPos = 20;
		SideAds.style.top = topPos
	//------------------------------------------------------------------------------------
	if ( contentWidth+adsWidth*2 <= clientWidth ){
		SideAds.style.display = 'inline';
	} else if ( contentWidth+adsWidth <= clientWidth ) {
		var AlignVal = 'right';	if (!isRTL) AlignVal='left';
		document.getElementById("container").style.textAlign=AlignVal;
		document.getElementById("container").style.width='750px';
		SideAds.style.display = 'inline';
	}
}
function ieCompatTest(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}
/*------------------------------------------------------*/