function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.<br />';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.<br />';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.<br />';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.<br />'; }
    } if (errors) {
		//alert('The following error(s) occurred:<br />'+errors);
		showError(errors);
		}
    document.MM_returnValue = (errors == '');
} }

function showError(errorMessage){
	$("#errorMsg").html(errorMessage);
	$("#errorMsg").fadeIn("slow");
}
function hideMsg(){
	if( $("#errorMsg").is(':visible') ) {
		$("#errorMsg").hide();
	}
}

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

$(document).ready(function(){
	// display tabs according to urlparameter
	var showTabIndex = $(document).getUrlParam("showtab"); 
	if( $("#tabs").length > 0 ){
		$("#tabs").tabs();
		if (showTabIndex != null){
			$("#tabs").tabs("option", "selected", showTabIndex);
		}
	}
	
	if( $('#slideshow').length > 0 ){
		$('#slideshow').innerfade({
					animationtype: 'fade',
					speed: 'slow',
					timeout: 3000,
					type: 'sequence', //'random',
					containerheight: '230px'
		});
	}

	$("#enquiry :input").focus(function () {
		 hideMsg();
    });
	
	// gallery carousel 
	if( $('#mycarousel').length > 0 ){
		 $('#mycarousel').jcarousel({
			/*auto: 2,
			animation: 'slow',
			wrap: 'last', */
			scroll: 1,
			initCallback: mycarousel_initCallback
		});
		$("a[rel='conferenceRoom']").colorbox({slideshow:true, slideshowSpeed:3500});
	}
	
});


