function tccGetExhibitions(objList) {
 
   var dosubmit = false;
	
   if (objList.options.selectedIndex > 0) {
       dosubmit = true;
   } else {
       dosubmit = false;
   }
 
   if (dosubmit) {
       document.exhibitions.submit();
   }
 
   return dosubmit;
 
}

function tccGetPress(objList) {
 
   var dosubmit = false;
	
   if (objList.options.selectedIndex > 0) {
       dosubmit = true;
   } else {
       dosubmit = false;
   }
 
   if (dosubmit) {
       document.press.submit();
   }
 
   return dosubmit;
 
}


function tccChangeBG(objRow, mouseState)    {

    if (mouseState == 'on')
        {
        	sColor = '#FFFFCC';
    }
    else if (mouseState == 'off')
        {
        	sColor = 'transparent';
    }
	
    objRow.style.backgroundColor = sColor;
    objRow.style.cursor = "default";

}

function tccValidateNonNumber (evt) {

    var keyCode = evt.which ? evt.which : evt.keyCode;
    return (keyCode >= 8 && keyCode <=9) || (keyCode >= 48 && keyCode <=57);

}

function toggleLayer(whichLayer)
	{
		if (document.getElementById) {
		// this is the way the standards work
			var style2 = document.getElementById(whichLayer).style;
			style2.display = style2.display? "":"block";
		} else if (document.all) {
		// this is the way old msie versions work
			var style2 = document.all[whichLayer].style;
			style2.display = style2.display? "":"block";
		} else if (document.layers)	{
		// this is the way nn4 works
			var style2 = document.layers[whichLayer].style;
			style2.display = style2.display? "":"block";
	}
}

function tccValidateForm(objform) {

    var validated = true;

    for (var i=0, j=objform.elements.length; i<j; i++) {
        controltype = objform.elements[i].type;
		fieldname = objform.elements[i].name;
		
		usedclass = objform.elements[i].className;
		
		if (usedclass.substring(0,3) == 'req') {
			if (objform.elements[i].disabled == false) {
				if (controltype == 'password' || controltype == 'text' || controltype == 'textarea') {
					if (objform.elements[i].value == '') {
						validated = false;
					}
				}
		
				if (controltype == 'select-one' || controltype == 'select-multiple') {
					objlist = objform.elements[i];
					if (objlist.options.selectedIndex == 0) {
						validated = false;
					}
				}
			}
		}
    }

    return validated;
}

function tccValidateRegForm() {

	var state = false;
	var objform = document.register;
	state = tccValidateForm(objform);

	if (state) {
		objform.submit()
	} else {
		alert('Please ensure that all the required fields have been completed.');
	}

	return state;

}

function tccValidateFriendsForm() {

	var state = false;
	var objform = document.friends;
	state = tccValidateForm(objform);

	if (state) {
		objform.submit()
	} else {
		alert('Please ensure that all the required fields have been completed.');
	}

	return state;

}

function tccValidateContactUsForm() {

	var state = false;
	var objform = document.contactus;
	state = tccValidateForm(objform);

	if (state) {
		objform.submit()
	} else {
		alert('Please ensure that all the required fields have been completed.');
	}

	return state;

}

function tccValidateRegisterForm() {

	var state = false;
	var objform = document.registerme;
	state = tccValidateForm(objform);

	if (state) {
		objform.submit()
	} else {
		alert('Please ensure that all fields marked with an (*) have been completed.');
	}

	return state;

}

function tccCheckSearchField() {
	
	var objform = document.searchform;
	var searchfor = objform.fullsearch.value;
	var submitstate = false;
	
	if (searchfor.length == 0) {
		alert('Please enter your search criteria.');
		submitstate = false;
	} else {
		objform.submit();
		submitstate = true;
	}
	
	return submitstate;
}

function tccShowPopUp(strName, ShowPage, intwidth, intheight, ShowScrollBar, intOffSet) {

	var leftpos = ((screen.width - intwidth - intOffSet) / 2);
	var toppos = ((screen.height - intheight - intOffSet) / 2);
	var winprops = 'toolbar=0, scrollbars=' + ShowScrollBar + ', location=0, statusbar=0, menubar=0, width=' + intwidth + ', height=' + intheight + ', left=' + leftpos + ', top=' + toppos + ', resizable=0';
    var popupwindow = window.open(ShowPage, strName, winprops);
    popupwindow.focus();
}

function tccUpdateProductImage(showimage) {
	
	var productimage = document.getElementById('productimage');
	productimage.src = "productimages/" + showimage;
	
}

function tccCheckEmail(str) {

	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	
	var validstate = true;
	
	if (str.indexOf(at)==-1){
	   validstate = false;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   validstate = false;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	   validstate = false;
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	   validstate = false;
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	   validstate = false;
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	   validstate = false;
	 }
	
	 if (str.indexOf(" ")!=-1){
	   validstate = false;
	 }

	 return validstate;		
	 
}

function tccValidateEmailAddress(emailaddress) {
	
	var emailstr = emailaddress.value;
	var emailvalid = true;
	
	if (emailstr.length > 0) {
		emailvalid = tccCheckEmail(emailstr);
	 
		if (!emailvalid) {
			alert('The Email address entered is invalid.  Please correct.');
			emailaddress.focus();
		}
	}
	
	return emailvalid;
}
