
function init(_elementID)
{
	if(_elementID == null)
	{	
		//elementID = "SearchControlNew_TextField";
		elementID = "SearchControlNew__ctl0_TextField";
	}
	else
	{
		elementID = _elementID;
	}
//	setTextFocus(elementID);	
}

function validateUrl(obj){
	var str = document.getElementById(obj).value;		
	return str != "" && str != "http://" && str!="https://"
}		

function showNotFoundPage(href)
{
	//alert(href);
	parent.document.location = href; 
}

function setAsHomePage(obj,pageName)
{
    if (window.sidebar) 
    { 
        // Mozilla Firefox Bookmark
        //alert("FireFox");
        //var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
        //alert(prefs);
        //prefs.setCharPref('browser.startup.homepage',pageName);
        window.sidebar.addPanel("Au HomePage", pageName,"");
        //alert(window.menubar);
    } 
    else if( window.external ) 
    { // IE Favorite
        obj.style.behavior='url(#default#homepage)';
	    obj.setHomePage(pageName);
        //window.external.AddFavorite( url, title); 
    }
    else if(window.opera && window.print) 
    { 
        // Opera Hotlist
        return true; 
    }    
}

//NIU
/*
function sendBugToIndex(elementName)
{
	var s = document.getElementById(elementName);	
	openWindowByParams('SendToIndex.aspx?searchKey=' + s.value, 'SendToFriend', 500, 250);
	return false;
}
*/

function MoveToLocation(aHref){
	document.location.href = aHref;
	return false;
}

function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

	function refocus(ctrl){
		if(searchTextObject){
			searchTextObject.focus();
			//searchTextObject = null;
			return;
		}
		obj = document.getElementById('SearchControlNew__ctl0_TextField');
		if(obj == null)
			obj = document.getElementById('_ctl0_TextField');
        obj.focus();        
	}
		
var isFirstTimeClick = false;
var isFirstTimeFocus = true;
var searchTextObject;
function setCaretToEnd (control) {
  if (control.createTextRange) {
    var range = control.createTextRange();
    if(isFirstTimeFocus){
		// removing this line will mark the text;
		//range.collapse(false);
	}
	isFirstTimeFocus = false;
    range.select();
    searchTextObject = control;
    setTimeout("refocus()",500);
  }
  else if (control.setSelectionRange) {
    control.focus();
    var length = control.value.length;
    if(window.event)
		control.setSelectionRange(length, length);
	else
		control.setSelectionRange(0, length);
  }
}
		
	function markTextIfFirstTime(obj){
		if(isFirstTimeClick){
			markTextAsSelected(obj);
		}
		isFirstTimeClick = false;
	}
	
	function markTextAsSelected( x ) {
		if(!x) return;
		var txtRange = x.createTextRange();
		txtRange.select();
	}
	
	function showTime(time){
		//var obj = document.getElementById(elementName);
		//window.status = obj.innerText;
		window.status = time;
	}
	
function isValidEmail(elementId){
  
  //validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  validRegExp = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/i;
	var obj = document.getElementById(elementId);
	strEmail = obj.value;
   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1)
   {
      return false;
    } 
    return true; 
}

function validSendToFriendForm(emailId, eMsg, nameId, nMsg){
	if(!isValidEmail(emailId, eMsg))
		return false;
		
	if(document.getElementById(nameId).value == ''){
		return false;	
	}		
	return true;
}

	function shs(msg)
	{
		//alert(msg);
		str = new String(msg);
	    str = str.replace("netex_sq1", "'");	
		window.status = str;
		return true;
	}
	
	function clrs()
	{
	    //alert("Clear Status");
		window.status='';
	}
	
	function changeMoreSuggestsStatus()
	{
		if(event != null && event.ctrlKey == true){
			document.location.href = "spellingqa.aspx";
			return false;
		}
		if(document.getElementById('moreSuggests').style.display == 'none')
			document.getElementById('moreSuggests').style.display = 'block'
		else
			document.getElementById('moreSuggests').style.display = 'none';
	}
//-------------- MoreFieldsControl start
	var ImagesPath;
	var MoreListText;
	var LessListText;
	
	function ShowMore(id)
	{
		
		if(id == 0){
			if(document.getElementById("MoreTable" + id) == null)
				return false;
			displayStatus = document.getElementById("MoreTable" + id).style;
			if(displayStatus.display == "none"){
				displayStatus.display = "block";
			}else{
				displayStatus.display = "none";				
			}
			return false;
		}
		for(i = 1; i < 3; i ++){
			if(document.getElementById("MoreTable" + i) == null) break;
			displayStatus = document.getElementById("MoreTable" + i).style;
			//text = document.getElementById("MoreFieldsCtrl_moreButtonTd");
			if(displayStatus.display == "none"){
				displayStatus.display = "block";
				//text.innerHTML = "<br><a><img onclick=\"return ShowMore(0);\" src=\"images/heb/list_close.gif\" width=\"351\" height=\"16\" border=\"0\" onmouseover=\"this.src='images/heb/list_close_o.gif';this.style.cursor='pointer';\" onmouseout=\"this.src='images/heb/list_close.gif'\"></a>";
			}else{
				displayStatus.display = "none";				
				//text.innerHTML = "<br><a><img onclick=\"return ShowMore(0);\" src=\"images/heb/list_close.gif\" width=\"351\" height=\"16\" border=\"0\" onmouseover=\"this.src='images/heb/list_close_o.gif';this.style.cursor='pointer';\" onmouseout=\"this.src='images/heb/list_close.gif'\"></a>";
			}
		}
		return false;
	}
	
	function change(which) {
		document.getElementById('right' + which).src = ImagesPath + '/e_right_over.gif';
		document.getElementById('MoreFieldsCtrl_center' + which).className = 'all_over';
		document.getElementById('left' + which).src = ImagesPath + '/e_left_over.gif';
	}
	
	function changeBack(which) {
		document.getElementById('right' + which).src = ImagesPath + '/e_right.gif';
		document.getElementById('MoreFieldsCtrl_center' + which).className = 'all';
		document.getElementById('left' + which).src = ImagesPath + '/e_left.gif';
		window.status = '';
	}
// -------------- MoreFieldsControl end

//--------------RelatedFieldsControl Start
	function ShowMoreRelated(id){
		displayStatus = document.getElementById("RelatedTable" + id).style;
		//text = "Test";//document.getElementById("AttributesDisplayer_yoter");
		//text = document.getElementById("RelatedFieldsCtrl_MoreButton");
		if(displayStatus.display == "none"){
			displayStatus.display = "block";			
			//text.innerHTML = LessListText;
		}else{
			displayStatus.display = "none";
			//text.innerHTML = MoreListText;
		}
		return false;
	}
		function changeRelated(which) {
			document.getElementById('right' + which).src = ImagesPath + '/e_right_over.gif';
			document.getElementById('RelatedFieldsCtrl_center' + which).className = 'all_over';
			document.getElementById('left' + which).src = ImagesPath + '/e_left_over.gif';
			//window.status = where;
		}
		function changeRelatedBack(which) {
			document.getElementById('right' + which).src = ImagesPath + '/e_right.gif';
			document.getElementById('RelatedFieldsCtrl_center' + which).className = 'all';
			document.getElementById('left' + which).src = ImagesPath + '/e_left.gif';
			window.status = '';
		}		
//----------- RelatedFieldControl end

// ------------AttributeDisplayerControl start
	var MoreAttributes;
	var LessAttributes;
	
	/*function ShowMoreAttributes(){
		displayStatus = document.getElementById("MoreAttributesTable").style;
		displayStatus.display = "block";
		document.getElementById("yoter").style.display = "none";
		document.getElementById("yoter").style.textDecoration = "none";		
	}
	*/
// ------------AttributeDisplayerControl end
// --------- SearchControl Start
	function setTextFocus(elementID){
		var obj = document.getElementById(elementID);
		if(obj){
			obj.focus();
			//isEnterEnabled = false;
		}
	}
	
//------LowerMenu start
	function openWindowByParams(url, windowName, width, height){
		var width = width;
		var height = height;
		var x = (screen.width - width ) / 2;
		var y = (screen.height - height) / 2;		
		open(url, windowName, "resizable=yes, width=" + width + ", height=" + height + ", left=" + x + ", top=" + y);	
	}
	
	function openExtSearchWindow(tarUrl)
	{
		window.open(tarUrl);		
		return false;
	}
					
	function searchAport(query, providerID, langID, engineID, searchPhrase)
	{		
		document.location.href="Stats.aspx?url=http://sm.aport.ru/scripts/template.dll?That=std&from=au_ru&r=" + encodeURI(searchPhrase)+"&isAportRedirect=1";
	}
