 function jmenutab(iLink,iTotal){

		for (i=0;i<=iTotal;i++) {
			t=document.getElementById("menu_" + i);
			o=document.getElementById("tab_" + i);
			t.style.display="none";
			o.className="menu-tab-off"
		}

		t=document.getElementById("menu_" + iLink);
		o=document.getElementById("tab_" + iLink);
		t.style.display="block";
		o.className="menu-tab-on"

 }


function jLaunchWindow( sURL, sWidth, sHeight ){
	sParams = "'directories=no,height=300,location=no,menubar=no,resizable=no,scrollbars=no,status=no,width=" + sWidth + ",height=" + sHeight + ",toolbar=no'"
	 newWin = window.open( sURL,'Help', sParams);
}

function jfIsValid( sValue, strValidChars  ) {
	var isValid = new Boolean()
	isValid=true
	var myChar=""
	var myInt=0

	if (sValue!="" && typeof(sValue)=="string") {
		for (i=0;i<sValue.length;i++) {
			myChar=sValue.charAt(i)
			myInt=strValidChars.indexOf(myChar)

			if (myInt == -1) {
				isValid=false
				break;
			}
		}
	}
	else {
		isValid=false
	}

	return isValid
}

function jfIsDate(data,datename)
{

// function created : 31.12.03
// created by 		: Farrakh Aslam
// input paramaters : data     - the formname
//datename - the fieldname specified when calling the vbscript date box function
// description      : Can be used to validate any of the vbscript date box functions
data = "document." + data + "."

var day   = eval( data + datename + "_d.value")
var month = eval( data + datename + "_m.value")
var year  = eval( data + datename + "_y.value")

var calcYear = (year % 4 == 0)
if (!calcYear)
	{
	leapDays = 28
	}
else
	{
	leapDays = 29
	}

if (month == 02)
	{
	if (day > leapDays)
	   {
	   return false;
	   }


	}
else if (month == 04 || month == 06 || month == 09 || month == 11)
	{
	if (day > 30)
	   {
	   return false;
	   }

	}
return true;
}

function jfIsEmail(incoming) {

	var emailstring = incoming;
	var ampIndex = emailstring.indexOf("@");
	var afterAmp = emailstring.substring((ampIndex + 1), emailstring.length);
		// find a dot in the portion of the string after the ampersand only
	var dotIndex = afterAmp.indexOf(".");
		// determine dot position in entire string (not just after amp portion)
	dotIndex = dotIndex + ampIndex + 1;
		// afterAmp will be portion of string from ampersand to dot
	afterAmp = emailstring.substring((ampIndex + 1), dotIndex);
		// afterDot will be portion of string from dot to end of string
	var afterDot = emailstring.substring((dotIndex + 1), emailstring.length);
	var beforeAmp = emailstring.substring(0,(ampIndex));

	var email_regex = /^\w(?:\w|-|\.(?!\.|@))*@\w(?:\w|-|\.(?!\.))*\.\w{2,3}/
		// index of -1 means "not found"
	if ((emailstring.indexOf("@") != "-1") &&
		(emailstring.length > 5) &&
		(afterAmp.length > 0) &&
		(beforeAmp.length > 1) &&
		(afterDot.length > 1) &&
		(email_regex.test(emailstring)) ) {
		  return true;
	} 
	else {
			return false;
	}
}

function jfIsPhoneNum( sValue ) {

	var isPhoneNum = new Boolean()
	isPhoneNum=true
	var myChar=""
	var myInt=0
	var strValidChars = "0123456789 ";

	if (sValue!="" && typeof(sValue)=="string") {
		for (i=0;i<sValue.length;i++) {
			myChar=sValue.charAt(i)
			myInt=strValidChars.indexOf(myChar)

			if (myInt == -1) {
				isPhoneNum=false
			}
		}

	} else {
		isPhoneNum=false
	}
	
	return isPhoneNum
}

function jfIsInt( sValue ) {
	var isInteger = new Boolean()
	isInteger=true
	var myChar=""
	var myInt=0

	if (sValue!="" && typeof(sValue)=="string") {
		for (i=0;i<sValue.length;i++) {
			myChar=sValue.charAt(i)
			myInt=parseInt(myChar)

			if (isNaN(myInt)) {
				isInteger=false
			}
		}

	} else {
		isInteger=false
	}

	return isInteger
}

function jsubmitnews(){
	frm = document.frmNews

	if( frm.txtEmail.value == "" ){
		alert("Please enter a valid email address.")
	}
	else if( jfIsEmail(frm.txtEmail.value) == false ){
		alert("Please enter a valid email address.")
	}
	else{
		frm.submit()
	}
}

function jlogin(){
	frm = document.frmLogin

	if (frm.txtEmail.value == ""){
		alert("Please enter your email address.")
		return;
	}
	else if (frm.txtPassword.value == ""){
		alert("Please enter your password.")
		return;
	}

	frm.submit()
}

function jcharacterlimit( iMax ){
	frm = document.frmComment
	if( frm.txtComment.value.length > iMax ){
		alert("The comment can not be greater than " + iMax + " charcters in length.")
	}
}

function jsumbitcomment( iMax ){
	frm = document.frmComment
	if( frm.txtComment.value.length > iMax ){
		alert("The comment can not be greater than " + iMax + " charcters in length.")
	}
	else{
		frm.submit()
	}
}

//	////////
//	GALLERY.ASP
//	////////

function jswapimage( sRoot, iExhibitor, iExhibitorImage ){

	document.getElementById("img_main").src = sRoot + 'z_images/exhibitor/' + iExhibitor + '/' + iExhibitorImage + '.jpg';
}


//	////////
//	ITEM.ASP
//	////////

function jsubmititem( iAction ){

	frm = document.frmBuy

	if (jfeature1() == false){
		return;
	}
	if (jfeature2() == false){
		return;
	}
	if (jfeature3() == false){
		return;
	}	
	if (jfeature4() == false){
		return;
	}
	if (jfeature5() == false){
		return;
	}	
	
	if ( iAction == 1 ) {
		frm.action ="basket.asp"
	}
	else if ( iAction == 2 ) {
		frm.action ="favourites.asp?txtMode=1"
	}
	frm.txtAction.value = 0
	frm.submit()


}

function jbasket( iBasket, iAction ){

	frm = eval("document.frmBasket_" + iBasket)

	frm.txtAction.value = iAction
	frm.submit()
}

function jsDelivery(iUpdate){

	frm = document.frmDelivery

	if ( iUpdate == 1 ){
		frm.optDeliveryType.value = -1
	}
	frm.txtAction.value = 1
	frm.submit()
}

function jsPaymentGateway(){

	frm = document.frmAccount
	frm.action = 'basket.asp'
	frm.submit()
}

function jchangecolor(){
	frm = document.frmBuy
	frm.action ="item.asp"
	frm.submit()
}



//	//////////////
//	BASKET.ASP
//	//////////////

function jsubmitbasket(iMode){
	frm = document.frmOrder
	frm.txtMode.value = iMode
	frm.submit()
}

//	//////////////
//	SEARCH.ASP
//	//////////////

function jMovePage( iPage ){
	frm = document.frmSearch
	iMaxPage = frm.txtMaxPage.value
	if ( iPage == 0 ){
		iPage = 1
	}
	else if ( iPage >= iMaxPage ){
		iPage = iMaxPage
	}
	frm.txtPage.value = iPage
	frm.submit();
}


//	//////////////
//	CONTACTUS.ASP
//	//////////////

function jsubmitcontactus(){
	frm = document.frmContactUs
	var iError = -1
	cssNormal = "textnormal"
	cssRequired =  'textred'
	cssInvalid =  'textblue'

	sAlpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz- '()"


	// First Name //
	if (frm.txtName.value ==""){
		frm.txtName.focus()
		alert("Please enter your full name.")
		return;
	}
	else if (frm.txtName.value.length < 3){
		frm.txtName.focus()
		alert("Your full name must be greater than 3 characters in length.")
		return;
	}
	else if (jfIsValid (frm.txtName.value, sAlpha) == false){
		frm.txtName.focus()
		alert("Your full name must contain alphabetic characters only.")
		return;
	}

// Home Tel //
	//if ( frm.txtHomeTel.value.length < 11 ){
	//	if ( iError == -1 ){ frm.txtHomeTel.focus()}
	//	iError = 9
	//	document.getElementById( 'tr_2' ).className = cssRequired
	//	alert("Please enter a valid home phone number.")
	//	return;
	//}
	//else if ( jfIsPhoneNum(frm.txtHomeTel.value) == false){
	//	if ( iError == -1 ){ frm.txtHomeTel.focus()}
	//	iError = 9
	//	document.getElementById( 'tr_2' ).className = cssInvalid
	//	alert("Please enter a valid home phone number.")
	//	return;
	//}


	// Email Address //
	if ( frm.txtEmail.value == ""){
		frm.txtEmail.focus()
		alert("Please enter your email address.")
		return;
	}
	else if ( jfIsEmail(frm.txtEmail.value) == false){
		frm.txtEmail.focus()
		alert("Please enter a valid email address.")
		return;
	}

	frm.submit();

}


//	//////////////
//	ACCOUNT.ASP
//	//////////////

function jsAccount( iMode ){
	frm = document.frmAccount
	frm.txtMode.value = iMode
	frm.submit();
}

function jsBack( iMode ){

	frm = document.frmAccount
	//frm.txtMode.value = iMode
	//frm.txtStep.value = 1
	//frm.submit();
	history.go(-2)
	
}

function jfHelp( iHelp ){

}

function jsubmitaccount( iMode ){
	frm = document.frmAccount
	var iError = -1
	cssNormal = "textnormal"
	cssRequired =  'textred'
	cssInvalid =  'textblue'

	sAlpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz- '()"

// ==== Personal Details ==== //

	// Full Name //
	if (frm.txtFullName.value ==""){
		frm.txtFullName.focus()
		alert("Please enter your full name.")
		return;
	}
	else if (frm.txtFullName.value.length < 3){
		frm.txtFullName.focus()
		alert("Your full name must be 3 or more characters in length.")
		return;
	}
	else if (jfIsValid (frm.txtFullName.value, sAlpha) == false){
		frm.txtFullName.focus()
		alert("Your full name must contain alphabetic characters only.")
		return;
	}

	// Email Address //
	if ( frm.txtEmail.value == ""){
		frm.txtEmail.focus()
		alert("Please enter your email address.")
		return;
	}
	else if ( jfIsEmail(frm.txtEmail.value) == false){
		frm.txtEmail.focus()
		alert("Please enter a valid email address.")
		return;
	}


// Password //
	if ( frm.txtPassword.value.length < 6 ){
		frm.txtPassword.focus()
		alert("Your password must be 6 or more characters in length.")
		return;
	}
	else if (jfIsValid (frm.txtPassword.value, sAlpha) == false){
		frm.txtPassword.focus()
		alert("Your password must contain alphabetic characters only.")
		return;
	}

// Home Tel //
	if ( frm.txtTel.value.length < 11 ){
		frm.txtTel.focus()
		alert("Please enter a valid telephone number.")
		return;
	}
	else if ( jfIsPhoneNum(frm.txtTel.value) == false){
		frm.txtTel.focus()
		alert("Please enter a valid telephone number.")
		return;
	}


// House Number //
	if ( frm.txtAdd1.value == ""){
		frm.txtAdd1.focus()
		alert("Please enter the first line of your address.")
		return;
	}
	else {
		document.getElementById( 'tr_6' ).className = cssNormal
	}
// City //
	if ( frm.txtCity.value == "" ){
		frm.txtCity.focus()
		alert("Please enter your town/city.")
		return;
	}

// County //
	if ( frm.txtCounty.value == "" ){
		frm.txtCounty.focus()
		alert("Please enter your county.")
		return;
	}

// Postcode //
	if ( frm.txtPostcode.value == "" ){
		frm.txtPostcode.focus()
		alert("Please enter your postcode.")
		return;
	}
	else if ( frm.txtPostcode.value.length < 6 ){
		frm.txtPostcode.focus()
		alert("Please enter a valid postcode.")
		return;
	}
	else {
		document.getElementById( 'tr_10' ).className = cssNormal
	}

//===Submit form if no errors found ===/

	frm.txtMode.value = iMode
	if (iMode > 0 ){
		frm.action = "account.asp"
	}
	//alert(frm.txtMode.value)
	frm.submit();

}


function jfIsDate(data,datename)
{

// function created : 31.12.03
// created by 		: Farrakh Aslam
// input paramaters : data     - the formname
//					  datename - the fieldname specified when calling the vbscript date box function
// description      : Can be used to validate any of the vbscript date box functions

var day   = eval("data." + datename + "_d.value")
var month = eval("data." + datename + "_m.value")
var year  = eval("data." + datename + "_y.value")


var calcYear = (year % 4 == 0)
if (!calcYear)
	{
	leapDays = 28
	}
else
	{
	leapDays = 29
	}

if (month == 02)
	{
	if (day > leapDays)
	   {
	   return false;
	   }
	}
else if (month == 04 || month == 06 || month == 09 || month == 11)
	{
	if (day > 30)
	   {
	   return false;
	   }

	}
return true;
}


function jmenuclick(iMenu,sAction){
 	
 	frm = document.frmMenu
 	
 	frm.optMenu.value = iMenu
 	frm.action = sAction
 	frm.submit();
 }
 
 
 // Secure.asp
 
 function jsSecurePayment(){
 
 	frm = document.frmSecure
 
 	sAlpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz- '()"
 	sAlphaNumeric = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-1234567890'()"


 // ==== Personal Details ==== //

	// Full Name //
	if (frm.txtFullName.value ==""){
		frm.txtFullName.focus()
		alert("Please enter your full name.")
		return;
	}
	else if (frm.txtFullName.value.length < 3){
		frm.txtFullName.focus()
		alert("Your full name must be 3 or more characters in length.")
		return;
	}
	else if (jfIsValid (frm.txtFullName.value, sAlpha) == false){
		frm.txtFullName.focus()
		alert("Your full name must contain alphabetic characters only.")
		return;
	}

	// Email Address //
	if ( frm.txtEmail.value == ""){
		frm.txtEmail.focus()
		alert("Please enter your email address.")
		return;
	}
	else if ( jfIsEmail(frm.txtEmail.value) == false){
		frm.txtEmail.focus()
		alert("Please enter a valid email address.")
		return;
	}
	
 // Home Tel //
 	if ( frm.txtTel.value.length < 11 ){
 		frm.txtTel.focus()
 		alert("Please enter a valid phone number.")
 		return;
 	}
 	else if ( jfIsPhoneNum(frm.txtTel.value) == false){
 		frm.txtTel.focus()
 		alert("Please enter a valid phone number.")
 		return;
 	}

 // House Number //
 	if ( frm.txtAdd1.value == ""){
 		frm.txtAdd1.focus()
 		alert("Please enter the first line of your address.")
 		return;
 	}

 // City //
 	if ( frm.txtCity.value == "" ){
 		frm.txtCity.focus()
 		alert("Please enter your town/city.")
 		return;
 	}
 
 // County //
 	if ( frm.txtCounty.value == "" ){
 		frm.txtCounty.focus()
 		alert("Please enter your county.")
 		return;
 	}
 	
 // Postcode //
 	if ( frm.txtPostcode.value == "" ){
 		frm.txtPostcode.focus()
 		alert("Please enter your postcode.")
 		return;
 	}
 	else if ( frm.txtPostcode.value.length < 6 ){
 		frm.txtPostcode.focus()
 		alert("Please enter a valid postcode.")
 		return;
 	}

 // ==== Card Type ==== //
 	if ( frm.optcardtype.value == 0 ){
 		frm.optcardtype.focus()
 		alert("Please select your credit card.")
 		return;
 	}	
 

 // ==== Card Number ==== //
 	if ( jfIsInt(frm.txtcardnum.value ) == false ){
 		frm.txtcardnum.focus()
 		alert("Please enter a valid credit card number.")
 		return;
 	}	
 
 	if ( frm.optvalidfrommonths.value == "" || frm.optvalidfromyears.value == "" ){
 		frm.optvalidfrommonths.focus()
 		alert("Please enter a valid from date.")
 		return;
 	}
 	
 	if ( frm.optexpirymonths.value == "" || frm.optexpiryyears.value == "" ){
 		frm.optexpirymonths.focus()
 		alert("Please enter a valid expiry date.")
 		return;
 	}
 	
 	if ( frm.txtsecuritycode.value == ""){
 		frm.txtsecuritycode.focus()
 		alert("Please enter the last 3 digits of your security code.")
 		return;
 	}	
 	
 // ==== Card Holders ==== //
 	if (frm.txtCardHoldername.value == "" ){
 		frm.txtCardHoldername.focus()
 		alert("Please enter the card holder's name.")
 		return;
 	}	
 	
 	frm.submit();
 }
 
 function jsSecure(){
 	frm = document.frmSecure
 	frm.submit();
}

 function jsPaypal(){
 	frm = document.frmPaypal
 	frm.submit();
}

function jsRecommend(){

	frm = document.frmEmail

	// Email Address //
	if ( frm.txtTo.value == ""){
		frm.txtTo.focus()
		alert("Please enter a valid email address.")
		return;
	}
	else if ( jfIsEmail(frm.txtTo.value) == false){
		frm.txtTo.focus()
		alert("Please enter a valid email address.")
		return;
	}
	
	// First Name //
	if (frm.txtFromName.value ==""){
		frm.txtFromName.focus()
		alert("Please enter your name.")
		return;
	}
	else if (frm.txtFromName.value.length < 3){
		frm.txtFromName.focus()
		alert("Your name must be greater than 3 characters in length.")
		return;
	}
	//else if (jfIsValid (frm.txtFromName.value, sAlpha) == false){
	//	frm.txtFromName.focus()
	//	alert("Your name must contain alphabetic characters only.")
	//	return;
	//}


	// Email Address //
	if ( frm.txtFrom.value == ""){
		frm.txtFrom.focus()
		alert("Please enter your email address.")
		return;
	}
	else if ( jfIsEmail(frm.txtFrom.value) == false){
		frm.txtFrom.focus()
		alert("Please enter a valid email address.")
		return;
	}

	frm.submit();

}

function jsCallback(){
	frm = document.frmCallBack

	if (frm.txtFullName.value == ""){
		frm.txtFullName.focus()
		alert("Please enter your Full Name.")
		return;
	}
	else if (frm.txtTel1.value == "" && frm.txtTel2.value == ""){
		frm.txtTel1.focus()
		alert("Please enter a contact Telephone Number.")
		return;
	}

	frm.submit()
}

function jsMailing(){

	frm = document.frmMailing

	// Email Address //
	if ( frm.txtEmail.value == ""){
		frm.txtEmail.focus()
		alert("Please enter a valid email address.")
		return;
	}
	else if ( jfIsEmail(frm.txtEmail.value) == false){
		frm.txtEmail.focus()
		alert("Please enter a valid email address.")
		return;
	}

	frm.submit();

}

function jsQuickSearch(){
	frm = document.frmQuickSearch
	frm.submit();
}

function jsOpenBox(iOrder){

	t = document.getElementById("order_" + iOrder);
	i = document.getElementById("img_" + iOrder);

	if (t.style.display=="block"){
		t.style.display="none";
		i.src='images/btn_view.gif'
	}
	else{
		t.style.display="block";
		i.src='images/btn_hide.gif'
	}
}

function jsMenu( iMenu ){

	if (document.getElementById("Group_"+iMenu).style.display=="none"){
		document.getElementById("Group_"+iMenu).style.display="";
	}
	else{
		document.getElementById("Group_"+iMenu).style.display="none";
	}

}


function jsTextOnly()
{

	var blTextOnly = (Cookie.read('mfonex_textonly') && (Cookie.read('mfonex_textonly') == 'true'));
	
	if(blTextOnly)
	{
		strToLoad = "textonly.css";
	
		var arrBits = $('mainstyle').href.split('/');
		arrBits[ (arrBits.length - 1) ] = strToLoad;
		$('mainstyle').href = arrBits.join('/'); 
		
		$('textonly').innerHTML = "graphical version";
	}

	$('textonly').onclick = function()
	{
		var blTextOnly = (Cookie.read('mfonex_textonly') && (Cookie.read('mfonex_textonly') == 'true'));

		if(blTextOnly)
		{
			Cookie.write('mfonex_textonly', 'false', {duration: 365, path:'/'});									
		}
		else
		{
			Cookie.write('mfonex_textonly', 'true', {duration: 365, path:'/'});									
		}

		document.location = document.location;
	};
}

function jsTextSize()
{
	var objBody = $$('html')[0];
	$('textsmall').onclick = function()
							{
								objBody.setStyle('font-size', '100%');
							};
	$('textmedium').onclick = function()
							{
								objBody.setStyle('font-size', '110%');
							};
	$('textlarge').onclick = function()
							{
								objBody.setStyle('font-size', '120%');
							};
}


//	//////////////
//	EXHIBITOR.ASP
//	//////////////

function jfSubmit_m3_s1( iTotal ){

	var frm = document.frmUpload

	var bExists = false

	for (p=1;p<=iTotal;p++){

		var f0 = document.getElementById("txtFile_"+p)
		var f1 = document.getElementById("txtFile_"+p).value.toLowerCase()

		if ( f1 != "" ){
			bExists = true
		}
		else if ( f1 != "" && f1.indexOf(".jpg") == -1 && f1.indexOf(".gif") == -1 ){
			alert("Please enter valid file type for file " + p + ".")
			f0.focus();
			return;
		}
	}

	if (bExists==false){
		alert("Please select at least 1 file to upload.")
		return;
	}

	sAlpha = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz- '()"

	// Gallery Name //
	if (frm.txtGalleryName.value ==""){
		frm.txtGalleryName.focus()
		alert("Please enter your gallery name.")
		return;
	}
	else if (frm.txtGalleryName.value.length < 3){
		frm.txtGalleryName.focus()
		alert("Your gallery name must be greater than 3 characters in length.")
		return;
	}
	else if (jfIsValid (frm.txtGalleryName.value, sAlpha) == false){
		frm.txtGalleryName.focus()
		alert("Your gallery name must contain alphabetic characters only.")
		return;
	}

	// Gallery Contact //
	if (frm.txtContact.value ==""){
		frm.txtContact.focus()
		alert("Please enter a contact name for the gallery.")
		return;
	}
	else if (frm.txtContact.value.length < 3){
		frm.txtContact.focus()
		alert("Your gallery name must be greater than 3 characters in length.")
		return;
	}
	else if (jfIsValid (frm.txtContact.value, sAlpha) == false){
		frm.txtContact.focus()
		alert("Your gallery name must contain alphabetic characters only.")
		return;
	}

	// Email Address //
	if ( frm.txtEmail.value == ""){
		frm.txtEmail.focus()
		alert("Please enter your email address.")
		return;
	}
	else if ( jfIsEmail(frm.txtEmail.value) == false){
		frm.txtEmail.focus()
		alert("Please enter a valid email address.")
		return;
	}
	
 	// Telephone //
 	if ( frm.txtTel.value.length < 11 ){
 		frm.txtTel.focus()
 		alert("Please enter a valid phone number.")
 		return;
 	}
 	else if ( jfIsPhoneNum(frm.txtTel.value) == false){
 		frm.txtTel.focus()
 		alert("Please enter a valid phone number.")
 		return;
 	}	

	// Terms and Conditions //
	if ( frm.chkAccept.checked == false){
		frm.chkAccept.focus()
		alert("You must accept the terms and conditions to apply for an exhibition space.")
		return;
	}



	frm.action="exhibitor.asp?txtMode=1"
	frm.submit();

}
