/********************************************/
/*              DISPLAY FLASH               */
/********************************************/
function WriteFlashObject(protocol, filename, _w, _h,_t) {
	var FlshTags= '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="' + protocol + '://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + _w + '" height="' + _h + '" title="' + _t + '">'
	+ '<param name="movie" value="' + filename + '" />'
	+ '<param name="wmode" value="transparent">'
	+ '<param name="quality" value="high" />'
	+ '<embed src="' + filename + '" quality="high" pluginspage="' + protocol + '://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" width="' + _w + '" height="' + _h + '"></embed>'
	+ '</object>';

	document.write(FlshTags);

}


/********************************************/
/*              CHECK ACCOUNT               */
/********************************************/
function ValidateAccount(thisform,fieldName){
var FormAccount = eval("document."+ thisform +"." + fieldName);
	
	if (FormAccount.value == ""){
		alert("Username is required");
		FormAccount.focus();
		return false;
	}else{
		return true;
	}

}


/********************************************/
/*             CHECK FIRST NAME             */
/********************************************/
function ValidateName(thisform,fieldName){
	var FormName = eval("document."+ thisform +"." + fieldName);

	if (FormName.value == ""){
		alert("First name is required");
		FormName.focus();
		return false;
	}else{
		return true;
	}

}


/********************************************/
/*             CHECK LAST NAME              */
/********************************************/
function ValidateLastName(thisform,fieldName){
	var FormLastName = eval("document."+ thisform +"." + fieldName);

	if (FormLastName.value == ""){
		alert("Last name is required");
		FormLastName.focus();
		return false;
	}else{
		return true;
	}

}


/********************************************/
/*  CHECK FIRST NAME AND LAST NAME LENGTH   */
/********************************************/
function ValidateFullName(thisform,Name,LastName){
	var FormFullName = eval("document."+ thisform +"." + Name + ".value") + " " + eval("document."+ thisform +"." + LastName + ".value"); 

	if (FormFullName.length < 5){
		alert("Customer name and last name are too short or have invalid characters");
		eval("document."+ thisform +"." + Name).select();
		return false;
	}else{
		return true;
	}

}


/********************************************/
/*           CHECK EMAIL ADDRESS            */
/********************************************/
function ValidateEmail(thisform,fieldName){
	var ValidStatus  = true;
	var FormEmail    = eval("document."+ thisform +"." + fieldName);

	if ((ValidStatus) && (FormEmail.value == "")){
		alert("Please provide an email address");
		FormEmail.focus();
		ValidStatus = false;
	}else if ((ValidStatus) && (FormEmail.value.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1)){
		alert("Please enter a valid email address");
		FormEmail.select();
		ValidStatus = false;
	}

	if (!ValidStatus){
		return false;
	}else{
		return true;
	}

}


/********************************************/
/*             CHECK PASSWORD               */
/********************************************/
function ValidatePassword(thisform,fieldName){
	var FormPassword  = eval("document."+ thisform +"." + fieldName);

	if (FormPassword.value == ""){
		alert("Password is required");
		FormPassword.focus();
		return false;
	}else{
		return true;
	}

}


/********************************************/
/*          VALIDATE FORMS - MAIN           */
/********************************************/
function Validator(thisform){
	var Valid = true;
	switch (thisform) {

		case "contact" :
			if (!ValidateName(thisform,'firstNameEntry'))						{Valid = false; return false;} else {Valid = true;}
			if (!ValidateLastName(thisform,'lastNameEntry'))					{Valid = false; return false;} else {Valid = true;}
			if (!ValidateFullName(thisform,'firstNameEntry','lastNameEntry'))	{Valid = false; return false;} else {Valid = true;}
			if (!ValidateEmail(thisform,'emailEntry'))							{Valid = false; return false;} else {Valid = true;}
			break;

		case "login" :
			if (!ValidateAccount(thisform,'account'))							{Valid = false; return false;} else {Valid = true;}
			if (!ValidatePassword(thisform,'password'))							{Valid = false; return false;} else {Valid = true;}
		break;

	}

}

/********************************************/
/*               SHOW NEWS                  */
/********************************************/
function showNews(Active){
	var NewsStr = "";

	if ( Active ){

		NewsStr = '<div id="NewsMsg"><div id="NewsMsgClose"><a href="#" onclick="document.getElementById(\'NewsMsg\').style.display=\'none\'"><span class="ImgLink">Close</span></a></div></div>';
		document.write(NewsStr);

	}else{

		return false;

	}
}
