var IMAGE_PATH = "/images/search";
var COMMON_IMAGE_PATH = "/images/search/common";
var Errpopup = true;
function showError(id, msg, title)
{
	if(!Errpopup)
		return false;
	var version = navigator.appVersion;
	var index = version.indexOf('MSIE') + 5;
	var ver = version.substr(index, 3);
	var browser = navigator.appName;
	
	var fontSize = '10pt';
	
	if ( browser == "Microsoft Internet Explorer")
	{
		var userAgent = navigator.userAgent;
		if ( userAgent.indexOf("Opera") >= 0)
			browser = "Opera";
		
		if(ver >= 5.5)
			fontSize = '8pt';
	}
	
	id.focus();
	
	if (title == null || title == "")
			title = E_JS_INVALIDDATA;
	
	image = "<TABLE BORDER=0 "+errStyle[5]+"><TR><TD><IMG style='margin:0px' src='" + COMMON_IMAGE_PATH + "/info.gif'></TD>";
	title = "<TD style='color:white;font-size:"+ fontSize + "'><b>" + title + "</b></TD></TR>";
	msg = "<TR><TD colspan=2 align=justify style='color:"+errStyle[0]+";background-color:"+errStyle[1]+";font-family:"+errStyle[2]+";font-size:"+errStyle[3]+";font-weight:"+errStyle[4]+";padding-left:10px;padding-right:10px'>" + msg + "</TD></TR></TABLE>";
		
	if((ver >= 5.5)  && (browser == "Microsoft Internet Explorer"))
	{
		var oPopup = window.createPopup();
		var oPopBody = oPopup.document.body;
		
		oPopBody.style.color = errStyle[0];
		oPopBody.style.backgroundColor = errStyle[1];
		oPopBody.style.border = "solid white 1px";
		oPopBody.style.margin = "1px";
		oPopBody.style.fontFamily = errStyle[2];
		oPopBody.style.fontSize = errStyle[3];
		oPopBody.style.fontWeight = errStyle[4];
		
		oPopBody.innerHTML = image + title + msg;
		oPopup.show(id.offsetWidth - 10, 10, 260, 100, id);
		var realHeight = oPopBody.scrollHeight + 10;
		oPopup.show(id.offsetWidth - 10, 10, 260, realHeight, id);
	}
	else
	{
		if (timer)
			{
				clearTimeout(timer);
				timer = false;
			}
		err = document.getElementById("popErr");
		
		btable = "<TABLE "+errStyle[5]+" style='border:solid white 1px;margin:1px;background-color:"+errStyle[1]+"'><TR><TD>";
		endbtable = "</TD></TR></TABLE>";
		tempid = id;
		posx = 0;
		posy = 0;
		
		while (tempid)
		{
			posx += tempid.offsetLeft;
			posy += tempid.offsetTop;
			tempid = tempid.offsetParent;
		}
		
		
		err.innerHTML = btable + image + title + msg + endbtable;
		err.style.left= posx+ id.offsetWidth - 10;
		err.style.top = posy+10;
		err.style.visibility = "visible";
		
		timer = setTimeout("hideErr()",5000); 
	}
	
	return false;
}

function hideErr()
{
	err = document.getElementById("popErr");
	err.style.visibility = "hidden";
}

function trimString(str)
{
    return str.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

function openNewWindow(theURL,winName,features) 
{
	window.open(theURL,winName,features);
}

function submitFeedback(sid)
{
	openNewWindow("?ACTION=FEEDBACK&sid="+sid , "_feedback", "width=400,height=240");
}

function showTip(msg,id)
{
	
	var version = navigator.appVersion;
	var index = version.indexOf('MSIE') + 5;
	var ver = version.substr(index, 3);
	var browser = navigator.appName;
	
	var fontSize = '10pt';
	
	if ( browser == "Microsoft Internet Explorer")
	{
		var userAgent = navigator.userAgent;
		if ( userAgent.indexOf("Opera") >= 0)
			browser = "Opera";
			
		if(ver >= 5.5)
			fontSize = '8pt';
	}
	
	title = "<TD style='color:white;font-size:"+ fontSize + "'><B>" + TT_JS_QUICKHELP + "</B></TD></TR>";	
	image = "<TABLE BORDER=0 width=250px "+tipStyle[5]+"><TR><TD><IMG style='margin:0px' src='" + COMMON_IMAGE_PATH + "/info.gif'></TD>";
	msg = "<TR><TD colspan=2 align=justify style='color:"+tipStyle[0]+";background-color:"+tipStyle[1]+";font-family:"+tipStyle[2]+";font-size:"+tipStyle[3]+";font-weight:"+tipStyle[4]+";padding-left:10px;padding-right:10px'>" + msg + "</TD></TR></TABLE>";
	
	
	if((ver >= 5.5) && (browser == "Microsoft Internet Explorer"))
	{
		var tipPopup = window.createPopup();
		var tipPopBody = tipPopup.document.body;
		
		tipPopBody.style.color = tipStyle[0];
		tipPopBody.style.backgroundColor = tipStyle[1];
		tipPopBody.style.border = "solid white 1px";
		tipPopBody.style.margin = "1px";
		tipPopBody.style.fontFamily = tipStyle[2];
		tipPopBody.style.fontSize = tipStyle[3];
		tipPopBody.style.fontWeight = tipStyle[4];
		
		tipPopBody.innerHTML = image + title + msg;
		tipPopup.show(0 , 20, 250, 0, id);
		var realHeight = tipPopBody.scrollHeight + 10;
		poppedTip = tipPopup;
		tipPopup.show(-20, 20, 250, realHeight, id);
	}
	else
	{
		tip = document.getElementById("popTip");
		
		btable = "<TABLE "+tipStyle[5]+" style='border:solid white 1px;margin:1px;background-color:"+tipStyle[1]+"'><TR><TD>";
		endbtable = "</TD></TR></TABLE>";
		tempid = id;
		posx = 0;
		posy = 0;
		
		while (tempid)
		{
			posx += tempid.offsetLeft;
			posy += tempid.offsetTop;
			tempid = tempid.offsetParent;
		}
		tip.innerHTML = btable + image + title + msg + endbtable;
		
		tip.style.left= posx-20;
		tip.style.top = posy+25;
		
		tip.style.visibility = "visible";
	}
	return true;
}

function showTipFocus(msg, id)
{
	id.focus();
	showTip(msg,id);
	return true;
}

function hideTip()
{
	var version = navigator.appVersion;
	var index = version.indexOf('MSIE') + 5;
	var ver = version.substr(index, 3);
	var browser = navigator.appName;
	
	if ( browser == "Microsoft Internet Explorer")
	{
		var userAgent = navigator.userAgent;
		if ( userAgent.indexOf("Opera") >= 0)
			browser = "Opera";
	}
	
	if((ver >= 5.5) && (browser == "Microsoft Internet Explorer"))
	{
		if (poppedTip)
		{
			poppedTip.hide();
			poppedTip = false;
		}
	}
	else
	{
		tip = document.getElementById("popTip");
		tip.innerHTML="";
		tip.style.visilbility = "hidden";
	}
}

function JSconfirm(msg)
{

	if( (window.showModalDialog)&& showModalDlg)	//showModalDlg is false to support utf-8 encoding
	{	
		var res;
		res = window.showModalDialog("./scripts/dialogs/confirmdialog.php?msg="+msg+"&title="+E_JS_CONFIRMTITLE+"&yes="+E_JS_YES+"&no="+E_JS_NO,"","dialogWidth:420px; dialogHeight:140px; scroll:no; status:no;");
		
		if(res != null)
			return true;
		else
			return false;
	}
	else
		return confirm(msg);
	
}

//	ally assigned it to do for sec and dir input (started by monir)
function setEnableOnStep6Sec()
{
	f = document.cinfofrm;
	var comboValue;
	var selIndex = f.soutsideuk.selectedIndex;
	comboValue = f.soutsideuk.options[selIndex].value;
	
	//alert(comboValue);
	if(comboValue=="Outside EEA")
	{	
		enableField(f.elements['slawgoverned'],true);	
		enableField(f.elements['slegalform'],true);
	}
	else
	{
		enableField(f.elements['slawgoverned'],false);
		enableField(f.elements['slegalform'],false);
	}
}
//	ally assigned it to do for sec and dir input (ended by monir)




