function clearField(obj){
	if(obj.value == 'Keyword Search') obj.value = '';
	obj.style.color = '#000000';
}
function fillField(obj,value){
	if(obj.value == ''){
		obj.value = value;
		obj.style.color = '#999999';
	}
}

function Gallery() {

	this.arrImages = Array();
	this.currentImg = 0;
	this.noImages = 0;
	
	this.registerImage = function( strFile, intImageNo ) {
	
		this.arrImages[intImageNo] = strFile;
		this.noImages++;
	
	}

	this.switchGallery = function( intImageNo ) {

		// get image elements		
		objMainImg = document.getElementById('main_gallery_image');
		strNewImage = this.arrImages[intImageNo];
	
		// split new url with original filename on the end
		var arrTmp = objMainImg.src.split("\/l_");
	
		// change file to large copy
		arrTmp[arrTmp.length-1] = "l_"+strNewImage;
	
		// join source back together
		strTmp = arrTmp.join("/");

		// switch image
		objMainImg.src = strTmp;
		this.currentImg = intImageNo;
		this.fixHeight();

	}

	this.prevImage = function() {


		if( this.currentImg == 0 ) this.currentImg = this.noImages;
		
		this.currentImg--;
		
		this.switchGallery( this.currentImg );

	}

	this.nextImage = function() {

		if( this.currentImg == (this.noImages-1) ) {
			this.currentImg = 0;
		} else {
			this.currentImg++;
		}
		
		this.switchGallery( this.currentImg );

	}
	
	this.fixHeight = function() {
	
		objBigImg = document.getElementById('main_gallery_image');
		
		intH = objBigImg.offsetHeight;

		objBigImg.style.top = "50%";
		objBigImg.style.marginTop = "-"+(intH/2)+"px";
		
	}

}

objGallery = new Gallery();

function submitContact( objRef ) {

	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	
	strEmail = objRef.email.value;
	strName = objRef.name.value;
	strCountry = objRef.country.value;
	strProvince = objRef.province.value;
	strPhone = objRef.phone.value;
	strCode = objRef.security_code.value;
	strNews = objRef.Newsletter.checked;

	if( (strEmail == '' && strPhone == '') || strName == '' || strCountry == '' || strProvince == '' || strCode == '' ) {
		alert( "Please fill out all required fields." );
		return false;
	}
	
	if( strNews && strEmail == '' ) {
		alert( "You must enter an e-mail address in order to subscribe to the newsletter" );
		return false;
	}
	
	if( strEmail != '' && reg.test(strEmail) == false) {
   			
      	alert('Please supply a valid e-mail address.');
      	return false;
      	
   	}
   	
    return true;

}
function _submitContact( objRef ) {

	var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	
	strEmail = objRef.email.value;

	if( strEmail == '' ) {
		alert( "Please fill out all required fields." );
		return false;
	}
	
	if(reg.test(strEmail) == false) {
   			
      	alert('Please supply a valid e-mail address.');
      	return false;
      	
   	}
   	
    return true;

}

function showMailInput( objRef ) {
	objRef2 = document.getElementById('mailing_address');

	if( objRef.checked ) {
		objRef2.style.display = 'table-row';
	} else {
		objRef2.style.display = 'none';
	}
}