/* Toogle text in search field functions
---------------------------------------------------------------- */

function focusField(f,txt){
	// Declare variable
	var field = document.getElementById(f.id);
	
	// Clean field, markup if text is not the same as original
	if(field.value==txt){
		field.value = '';
	}else{
		field.select();
	}
} // focusField

function blurField(f,txt){
	// Declare variable
	var field = document.getElementById(f.id);
	
	// Restore field if not text is original
	if(field.value==''){
		field.value = txt;
	}
} // blurField
/* Link function
---------------------------------------------------------------- */

function goToUrl(popup,url){
	// If popup is true, then open in popup, else open normal
	if(url){
		if(popup){
			window.open(url);
		}else{
			if ( document ) if ( document.body ) if ( document.body.style ) document.body.style.cursor="wait";
			location.href = url;
		}
	}
} // goToUrl
function openPopup(name,url,width,height) {
	window.open(url,name,"height="+height+",width="+width+",menubar=0,resizable=1,toolbar=0");
} // openPopup

// used in project type template
function checkUrl(url, obj)
{
	if(url == "Project Company not registered")
	{
		document.getElementById(obj).innerHTML = "Project Company not registered";
		return false;
	}
	if(url == "N/A")
	{
		document.getElementById(obj).innerHTML = "";
		return false;
	}

     var theurl=url
     //var tomatch= /http:\/\/[A-Za-z0-9\.-]{3,}\.[A-Za-z]{3}/
     var tomatch= /\//

     if (tomatch.test(theurl)){
		aTheUrl = theurl.split("/")
//		document.getElementById(obj).innerHTML = '<a href="http://'+theurl+'" target="_blank">'+aTheUrl[0]+'</a>';
//         alert("URL OK.");
         return true;
     }
     else
     {
	
//        document.getElementById(obj).innerHTML = theurl;
         //alert("URL invalid. Try again.");
         return false;
     }
}
