function searchbox_clickSearchImage(e,clientID, nFolderID, strLang, obj)
{	
	// get search pharse
	var sreachTextBox = document.getElementById(clientID + "searchInput");
	if ( !sreachTextBox ) 
	{
		alert('no search box');
		return;
	}
	
	//var strSearchText = document.all[clientID + "searchInput"].value;
	strSearchText = sreachTextBox.value;

	// check for not empty pharse
	if (searchbox_isEmpty(strSearchText) == true)
	{
		alert(arrMessagesSearchBox['pharse_empty']);
		return;
	}
	
	// check for legal pharse
	if (searchbox_validPharse(strSearchText) == false)
	{
		alert(arrMessagesSearchBox['pharse_error']);
		return;
	}
	
	// get path

	var strLocationPath = searchbox_getLocationPath(clientID) + "Templates/Search/Search.SearchResults.aspx"; 		
	// params
	var params = "?FolderID=" + nFolderID + "&lang=" + strLang + "&SearchText=" + strSearchText;
	
	//////////////////////////
	// NOT GENERIC SEARCH - START
	//////////////////////////
	
	//var strSection = document.all[clientID + "slcSection"].value;
	//if (strSection != "0")
	//{
	//	params += "&Section=" + strSection;;
	//}
	
	//////////////////////////
	// NOT GENERIC SEARCH - END
	//////////////////////////
	if ( document.all )
		event.returnValue = false;
	else
	    e.preventDefault();
	location.href = strLocationPath + params;
	/*
	alert(666);
	*/
}

function searchbox_SearchImageByEnter(e,clientID, nFolderID, strLang, obj)
{
    var code =(window.event)? event.keyCode: e.keyCode;
	if(code==13)
	{
        searchbox_clickSearchImage(e,clientID, nFolderID, strLang, obj);   
    }
}

function searchbox_overSearchImage(obj)
{
	obj.src = searchbox_On.src;
	obj.style.cursor = 'hand';
}

function searchbox_outSearchImage(obj)
{
	obj.src = searchbox_Off.src;
}

function searchbox_isEmpty(strValue)
{
	// if the field value is empty, return true (error)
	if (strValue == "")
	{
		return true;
	}
	
	return false;	
		
}

var strNotLegalChars = "!@#$%^&~\?;:";
function searchbox_validPharse(strSearchText)
{
	for (var i=0 ; i<strSearchText.length ; i++)
	{
		if (strNotLegalChars.indexOf(strSearchText.charAt(i)) > -1)
		{
			return false;
		}
	}
	
	return true;
}

var searchbox_strLocation = "";
function searchbox_getLocationPath(clientID)
{
	if (searchbox_strLocation == "")
	{
		searchbox_strLocation = document.all[clientID + "txtLocation"].value;
		//var arrLocation = String(document.links[0]).split('Templates');
		//searchbox_strLocation = arrLocation[0];
	}
	return searchbox_strLocation;
}

function searchbox_getParam(strParam)
{
	var url = document.URL.split('?');
	
	if (url.length != 2)
	{
		return "";
	}

	var params = url[1].split('&');

	for (var i=0 ; i<params.length ; i++)
	{
		var param = params[i].split('=');

        if (param.length != 2)
        {
			return "";
		}

		if (param[0].toLowerCase() == strParam.toLowerCase())
		{
			return param[1];
		}
	}

	return "";
}



