function $(id)
{
	return document.getElementById(id);
} // $


function logBLR()
{
	var obj = null;
	obj = document.getElementById("frmIdentification");
	LogOn('ABCISLANDS', obj.txtcode.value, obj.txtpassword.value, false);
	obj.txtcode.value = "";
	obj.txtpassword.value = "";
} // logBLR



function gotoOption(id)
{
	var obj = null;
	obj = document.getElementById(id);
	if ( obj!=null )
		obj.submit();
} // gotoOption


function is_empty(str)
{
	return ( str==null || str==0 || str=="" || str.length<1 );
} // is_empty



function is_numeric(str)
{
	regularExp = new RegExp("^[0-9-.]*$");
	return regularExp.test(str);
} // is_numeric



function is_email(str)
{
	return ( ( str.indexOf("@")>0 ) && ( str.indexOf(".")>0 ) );
} // is_email


function clear_form(frm) {
	frm.reset();
}

// function to show/hide the promotions restrictions
function toggle(id)
{
	if(document.getElementById(id).style.display == 'none' ){
		document.getElementById(id).style.display = '';
	}else{
		document.getElementById(id).style.display = 'none';
	}
}

// function to change the department based in the parameter sent
function chooseEmail(dpt)
{
	var obj = document.getElementById("contact");
	var opt;

	if ( !is_empty(dpt) )
	{
		dpt = dpt.toLowerCase();

		for(var i=0;i<obj.length;i++)
		{
			opt =obj.options[i].text;
			opt = opt.toLowerCase();

			if ( opt.indexOf(dpt) >= 0 )
			{
				obj.options.selectedIndex=i;
			}//if

		}//for
	}
}//chooseEmail


// funtion to get the url domain of the site
function getURL(uri)
{
	uri.dir = location.href.substring(0, location.href.lastIndexOf('\/'));
	uri.dom = uri.dir;
	var pos = uri.dom.lastIndexOf('\/');
	if (pos > -1)
	{
		uri.dom = uri.dom.substr(0,pos);
	}
	return uri;
}// getURL


//funtion value Form
function contentVerification(){

	var finalMessage = "";
	var error = false;


	var quoteCompany = $('quoteCompany').value;
	var quoteUrl = $('quoteUrl').value;
	var quoteName = $('quoteName').value;
	var quoteEmail = $('quoteEmail').value;
	var quotePhone = $('quotePhone').value;
	var quoteCountry = $('quoteCountry').value;
	var quoteContact = $('quoteContact').value;
	var quoteService = $('quoteService').value;
	var quoteExperience = $('quoteExperience').value;
	var quoteDescription = $('quoteDescription').value;
	var quoteKeywords = $('quoteKeywords').value;
	var quoteFindus = $('quoteFindus').value;
	var quotecode = $('quotecode').value;


	if ( is_empty(quoteCompany) )
	{
		finalMessage += "* Please check Company Name.\n";
		error = true;
	}

	if ( is_empty(quoteUrl) )
	{
		finalMessage += "* Please check URL Site.\n";
		error = true;
	}

	if ( is_empty(quoteName) )
	{
		finalMessage += "* Please check Name.\n";
		error = true;
	}

	if ( is_empty(quoteEmail)  || !is_email(quoteEmail) )
	{
		finalMessage += "* Please check Email.\n";
		error = true;
	}

	 if (is_empty(quotePhone) )
	{
		finalMessage += "* Please check Phone Number.\n";
		error = true;
	}

	if (is_empty(quoteCountry) )
	{
		finalMessage += "* Please check Country.\n";
		error = true;
	}

	if(is_empty(quoteContact) )
	{
		finalMessage += "* Choose the Best Time to Contact.\n";
		error = true;
	}

	if (is_empty(quoteService) )
	{
		finalMessage += "* Choose the service are you interested\n";
		error = true;
	}

	if (is_empty(quoteExperience) )
	{
		finalMessage += "* Choose the long has your website been online\n";
		error = true;
	}

	if (is_empty(quoteDescription) )
	{
		finalMessage += "* Please check Describe.\n";
		error = true;
	}

	if (is_empty(quoteKeywords) )
	{
		finalMessage += "* Please check Keywords.\n";
		error = true;
	}

	if (is_empty(quoteFindus) )
	{
		finalMessage += "* Choose the Findus. \n";
		error = true;
	}

	if ( is_empty(quotecode) )
	{
		finalMessage += "* Please check your code.\n";
		error = true;
	}

	if ( error == false )
	{
		return true;
	}
	else
	{
		alert("It seems there''s a problem sending the information, please take a look to the following error(s):\n\n"+finalMessage);
		return false;
	}

}// contentVerification






// fuction to use target blank in xhtml strict
function transformExternalAnchors()
{
	var i,a,f;
	if ( document.getElementsByTagName )
	{

		a = document.getElementsByTagName("a");
		i = 0;

		// for using in normal href tag, you you have to add: rel="external"
		// example: <a href="http://affiliate.dptsportsgroup.com" rel="external">Affiliate program</a>
		for(i=0;i<a.length;i++)
		{
			if ( a[i].getAttribute('href') && ( a[i].getAttribute("rel")=="external" ) )
			{
				a[i].target = "_blank";
			}
		} // for

		f = document.getElementsByTagName("form");
		i = 0;

		// for using in forms, you have to add in the form tag: title="external"
		// example: 		<form action=# id="frmId" title="external"></form>
		for(i=0;i<f.length;i++)
		{
			if ( f[i].getAttribute('action') && ( f[i].getAttribute("title")=="external" ) )
			{
				f[i].target = "_blank";
			}
		} // for
	} // if
} // transformExternalAnchors

window.onload = transformExternalAnchors;