/* ********************************** */
/* SimplestNet js website utils       */
/* 11 nov 2005 by Eric Grossi         */
/* egrossi@simplestnet.com            */
/* Copyright 2005 SimplestNet Inc.    */
/* ********************************** */

///////////////////////////////////////////////////////////////////////////
function writeFlash(src, w, h, q, extra) {
    if (!extra) extra="";

    var line='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
                   'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0" '+
                   'width="'+w+'" height="'+h+'" '+extra+'><param name="movie" value="'+src+'">'+
                   '<param name="quality" value="'+q+'">'+
                   '<embed src="'+src+'" quality="'+q+'" width="'+w+'" height="'+h+'" type="application/x-shockwave-flash" '+
                   'pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" '+extra+
                   '></embed></object>';
    document.write(line);
}
///////////////////////////////////////////////////////////////////////////
function preloadImages() {
	if ( !window.pre_img )
		window.pre_img=new Array();

	var l=window.pre_img.length;

	for (var i=0; i<preloadImages.arguments.length; i++) {
		window.pre_img[i+l] = new Image();
		window.pre_img[i+l].src = preloadImages.arguments[i];
	}
}
///////////////////////////////////////////////////////////////////////////
function validatecontact()
{
	with(document.forms['contactus'])
	{
		submit.disabled = true;
		reset.disabled = true;
		
		if ( trim(name.value) == "")
		{
			alert(MSG_Lname);
			name.focus();
			submit.disabled = false;
			reset.disabled = false;
			return false;
		}
		if( trim(firstname.value) == "" )
		{
			alert(MSG_Fname);
			firstname.focus();
			submit.disabled = false;
			reset.disabled = false;
			return false;
		}
		if ( country.options(country.selectedIndex).value == "*" )
		{
			alert(MSG_Country);
			country.focus();
			submit.disabled = false;
			reset.disabled = false;
			return false;
		}
		if ( trim(email.value) == "" )
		{
			alert(MSG_Email);
			email.focus();
			submit.disabled = false;
			reset.disabled = false;
			return false;
		}
		if ( email.value.indexOf("@") < 0 || email.value.indexOf(".") < 0 )
		{
			alert(MSG_Email2);
			email.focus();
			submit.disabled = false;
			reset.disabled = false;
			return false;
		}
	}
	return true;
}
///////////////////////////////////////////////////////////////////////////
function trim(strText) {
    // this will get rid of trailing spaces
    while (strText.substring(0,1) == ' ')
        strText = strText.substring(1, strText.length);
    while (strText.substring(strText.length-1,strText.length) == ' ')
        strText = strText.substring(0, strText.length-1);

   return strText;
}
///////////////////////////////////////////////////////////////////////////
var valid = '0123456789.'; // define valid characters
function isValid(string,allowed)
{
    for (var i=0; i< string.length; i++)
	{
       if (allowed.indexOf(string.charAt(i)) == -1)
          return false;
    }
    return true;
}