jQuery().ready(function(){
		//open/close search
		jQuery('#list3').accordion({
			header: 'div.title',
			alwaysOpen: false,
			animated: 'slide',
			fillSpace: false, 
			active: '.selected', 
   			selectedClass: 'active'
		});
		
		//inventory list
		//hide the all of the element with class msg_body
		$(".msg_body").hide();
		//toggle the componenet with class msg_body
		$(".msg_head").click(function(){
			$(this).next(".msg_body").slideToggle(600);
		});

		// back to top
		    //Click event handler for any anchor that has an href that ends in top
		      $("a[class=backToTop]").click(function() {

			//Animates scroll to the top of the page...and take 1 second to do it.
			$('html, body').animate({ scrollTop:0 }, '1000');

			//return false to prevent the default action of the anchor tag when clicked.
			return false;

		      });
		
		//searchform bases filter init
		BaseID=$("select[name=BaseID]").val();
		$("select[name=RegionID]").change();
		if (BaseID) $("select[name=BaseID]").val(BaseID);
		
		//init validation strings if booking forms exist
		strValidateFormName = $("input[name=strValidateFormName]").val();
		strValidateFormPhoneEmail = $("input[name=strValidateFormPhoneEmail]").val();
		strValidateFormEmailFormat = $("input[name=strValidateFormEmailFormat]").val();
		
	});
	
function YachtTypeFilterURL (URL) {
	document.location.href = URL.replace('$$$', $("select[name=YachtTypeFilter]").val());
}
	
//
// LAYER TOGGLE
//
function toggleDiv(element, element2, text, text2){
	  document.getElementById(element).style.display = 'none';
	  document.getElementById(element2).style.display = 'block';
	  document.getElementById(text).style.display = 'none';
	  document.getElementById(text2).style.display = 'block';
}
	

//regions selector popup
function changeRegion(RegionID) {
	$("select[name=RegionID]").val(RegionID).change();
	$.prettyPhoto.close();
}

function closePrettyPhotoFrame() {
 $.prettyPhoto.close();
}

// references text fade-in-out
			$(document).ready(function()
			{
				setupRotator();
			});	
			function setupRotator()
			{
				if($('.textItem').length > 1)
				{
					$('.textItem:first').addClass('current2').fadeIn(1000);
					var currentItemHeight = $('.current2').height();
					$('#quotes').css({"height": currentItemHeight+70});
					setInterval('textRotate()', 6000);
				}
			}
			function textRotate()
			{
				var current = $('#quotes > .current2');
				if(current.next().length == 0)
				{
					current.removeClass('current2').fadeOut(1000);
					$('.textItem:first').addClass('current2').fadeIn(1000);
				}
				else
				{
					current.removeClass('current2').fadeOut(1000);
					current.next().addClass('current2').fadeIn(1000);
					var currentItemHeight = $('.current2').height();
					$('#quotes').css({"height": currentItemHeight+70});
				}
			}

// PRETY PHOTO GALLERY
$(document).ready(function(){
		$("a[rel^='prettyPhoto']").prettyPhoto({
			animation_speed: 'normal', /* fast/slow/normal */
			slideshow: false, /* false OR interval time in ms */
			autoplay_slideshow: false, /* true/false */
			opacity: 0.60, /* Value between 0 and 1 */
			default_width: 600,
			default_height: 344,
			show_title: true, /* true/false */
			allow_resize: false, /* Resize the photos bigger than viewport. true/false */
			overlay_gallery: false /* If set to true, a gallery will overlay the fullscreen image on mouse over */
		});
	});
	
startList = function() {
   if (document.all&&document.getElementById) {
      navRoot = document.getElementById("selector");
      for (i=0; i<navRoot.childNodes.length; i++) {
         node = navRoot.childNodes[i];
         if (node.nodeName=="LI") {
            node.onmouseover=function() {
               this.className+=" over";
            }
            node.onmouseout=function() {
               this.className=this.className.replace(" over", "");
            }
         }
      }
   }
}


function popUp(page) {
fineline=eval("window.open('"+page+"','fineline','toolbar=0,scrollbars=1,location=0,status=0,menubars=0,resizable=1,width=1005,height=400')")
width=(screen.width/2)-400
height=(screen.height/2)-300
fineline.window.moveTo(width,height)
}

function ShowFlash(id, source, width, height, FlashVarsValue)
{
	var classid = "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000";
	var codebase = "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0";
	var ScaleValue = "noscale";
	var MenuValue = "false";
	var QualityValue = "high"
	var WmodeValue = "transparent"
	var AllowScriptValue = "sameDomain";
	var TypeValue = "application/x-shockwave-flash";
	var PluginPageValue = "http://www.macromedia.com/go/getflashplayer"

	document.write('<OBJECT classid="'+classid+'" codebase="'+codebase+'" width="'+width+'" height="'+height+'" id="'+id+'">');
	document.write('<PARAM NAME="allowScriptAccess" VALUE="'+AllowScriptValue+'" />');
	document.write('<PARAM NAME="FlashVars" VALUE="'+FlashVarsValue+'" />');
	document.write('<PARAM NAME="movie" VALUE="'+source+'" />');
	document.write('<PARAM NAME="scale" VALUE="'+ScaleValue+'" />');
	document.write('<PARAM NAME="menu" VALUE='+MenuValue+' />');
	document.write('<PARAM NAME="quality" VALUE="'+QualityValue+'" />');
	document.write('<PARAM NAME="wmode" VALUE="'+WmodeValue+'" />');
	document.write('<EMBED src="'+source+'" scale="'+ScaleValue+'" menu='+MenuValue+' quality="'+QualityValue+'" width="'+width+'" height="'+height+'" name="'+id+'"');
	document.write('wmode="'+WmodeValue+'" FlashVars="'+FlashVarsValue+'" type="'+TypeValue+'" pluginspage="'+PluginPageValue+'"></EMBED>');
	document.write('</OBJECT>');
}


// Filter Bases based on selected region

function fillBases(intStart,fTypes,fItems) {
    var a = arItems;
    var b, c, d, intItem, intType

    if ( intStart > 0 ) {
        for ( b = 0; b < a.length; b++ ) {
            if ( a[b][1] == intStart )
                intType = a[b][0];
        }

        for ( c = 0; c < fTypes.length; c++ ) {
            if ( fTypes.options[ c ].value == intType )
                fTypes.selectedIndex = c;
        }
    }

    if ( intType == null )
        intType = fTypes.options[ fTypes.selectedIndex ].value;

    fItems.options.length = 0;

    for ( d = 0; d < a.length; d++ ) {
        if ( a[d][0] == intType )
            fItems.options[ fItems.options.length ] = new Option( a[d][2], a[d][1] );

        if ( a[d][1] == intStart )
            fItems.selectedIndex = fItems.options.length - 1;
    }
}

// Booking forms validations
////////////////////////////////////////////////////////////////////

//function to check empty fields
function isEmpty() {
strfield1 = document.bookingform.FullName.value
strfield2 = document.bookingform.Phone.value
strfield3 = document.bookingform.email.value
document.bookingform.FullName.style.borderColor = '#000000';
document.bookingform.Phone.style.borderColor = '#000000';
document.bookingform.email.style.borderColor = '#000000';

    if (strfield1 == "" || strfield1 == null || !isNaN(strfield1) || strfield1.charAt(0) == ' ')
    {
    alert(strValidateFormName);
    document.bookingform.FullName.focus();
    document.bookingform.FullName.style.borderColor = '#cc0000';
    return false;
    }
    if ((strfield2 == "" || strfield2 == null || strfield2.charAt(0) == ' ') && (strfield3 == "" || strfield3 == null || strfield3.charAt(0) == ' '))
    {
    alert(strValidateFormPhoneEmail);
    document.bookingform.Phone.focus();
    document.bookingform.Phone.style.borderColor = '#cc0000';
    document.bookingform.email.style.borderColor = '#cc0000';
    return false;
    }
    if (strfield3 != "" && strfield3 != null && strfield3.charAt(0) != ' ') {
    	if (! isValidEmail(strfield3)) {
    		return false;
    	}
    }
    return true;
}

//function to check valid email address
function isValidEmail(strEmail){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  strEmail = document.bookingform.email.value;

   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1)
   {
      alert(strValidateFormEmailFormat);
      document.bookingform.email.style.borderColor = '#cc0000';
      document.bookingform.email.focus();
      return false;
    }
    document.bookingform.email.style.borderColor = '#000000';
    return true;
}

//function that performs all functions, defined in the onsubmit event handler
function check(form){
	if (isEmpty()) {
		return true;
		}
	return false;
}

//function to check empty fields
function isEmpty2(strfield1, strfield2, strfield3) {
strfield1 = document.bookingform2.FullName.value
strfield2 = document.bookingform2.Phone.value
strfield3 = document.bookingform2.email.value
document.bookingform2.FullName.style.borderColor = '#000000';
document.bookingform2.Phone.style.borderColor = '#000000';
document.bookingform2.email.style.borderColor = '#000000';

    if (strfield1 == "" || strfield1 == null || !isNaN(strfield1) || strfield1.charAt(0) == ' ')
    {
    alert(strValidateFormName);
    document.bookingform2.FullName.focus();
    document.bookingform2.FullName.style.borderColor = '#cc0000';
    return false;
    }
    if ((strfield2 == "" || strfield2 == null || strfield2.charAt(0) == ' ') && (strfield3 == "" || strfield3 == null || strfield3.charAt(0) == ' '))
    {
    alert(strValidateFormPhoneEmail);
    document.bookingform2.Phone.focus();
    document.bookingform2.Phone.style.borderColor = '#cc0000';
    document.bookingform2.email.style.borderColor = '#cc0000';
    return false;
    }
    if (strfield3 != "" && strfield3 != null && strfield3.charAt(0) != ' ') {
 	if (! isValidEmail2(strfield3)) {
		return false;
	}
    }
    return true;
}

//function to check valid email address
function isValidEmail2(strEmail){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  strEmail = document.bookingform2.email.value;

   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1)
   {
      alert(strValidateFormEmailFormat);
      document.bookingform2.email.style.borderColor = '#cc0000';
      document.bookingform2.email.focus();
      return false;
    }
    document.bookingform2.email.style.borderColor = '#000000';
    return true;
}


//function that performs all functions, defined in the onsubmit event handler
function check2(form){
	if (isEmpty2(form.Fullname)) {
		return true;
		}
	return false;
}
