function getURLFromDocumentLocation()
{
	var u = ''+document.location
	var p = u.split('\/')
	var strURL = 'http://'+p[2]+'/'

	if (p[2]=='localhost'){
		strURL = strURL + p[3]+'/'
	}
	return strURL
}

function getLocationPostVar(strName)
{
	var strRet = '';
	var query = window.location.search.substring(1)
	var parms = query.split('&')
	for (var i=0; i<parms.length; i++) {
		var pos = parms[i].indexOf('=')
		if (pos > 0) {
			var key = parms[i].substring(0,pos)
			var val = parms[i].substring(pos+1)
			if (key == strName) {
				strRet = val
			}
		}
	}
	return strRet
}

function clearDiv(strDivID)
{
	var elm = document.getElementById(strDivID)



	if (elm)
	{
		elm.innerHTML=''
		elm.style.backgroundColor = ""
		elm.style.border = ""
		elm.style.padding = ""
	}
}

function writeInformationMessage(strDivID, strMsg)
{
	var elmDiv = document.getElementById(strDivID)
	if (elmDiv) {
		elmDiv.innerHTML = strMsg
	}
	else {
		alert(strMsg)
	}
}

function writeErrorMessage(strFieldName, strMsg)
{
	var elmDiv = document.getElementById(strFieldName+'_msg')
	if (elmDiv) {
		elmDiv.innerHTML = strMsg

		elmDiv.focus
		//TODO style to be moved to the required CSS
		elmDiv.style.backgroundColor = "#F8E5E5"
		elmDiv.style.border = "1px solid #A90000"
		elmDiv.style.color = "#A90000"
		elmDiv.style.fontWeight = "bold"
		elmDiv.style.textAlign = "center"
		elmDiv.style.marginTop = "2px"
		elmDiv.style.padding = "2px"

	}
	else {
		alert(strMsg)
	}
}

function clear_textbox()
{
	var textBox = document.getElementById("searchbox");
	textBox.value = "";
	return true;
}


function ajax_result_to_div(strURL,strPostData,strDivID)
{
	try{
		jQuery.ajax({
			type: "POST",
			url: strURL,
			data: strPostData,
			success: function(result){
				document.getElementById(strDivID).innerHTML=result
			}
		});
	}
	catch(ex)
	{
		alert(ex)
	}
}