//cycle min plugin
;(function($){var ver='Lite-1.3';$.fn.cycle=function(options){return this.each(function(){options=options||{};if(this.cycleTimeout)clearTimeout(this.cycleTimeout);this.cycleTimeout=0;this.cyclePause=0;var $cont=$(this);var $slides=options.slideExpr?$(options.slideExpr,this):$cont.children();var els=$slides.get();if(els.length<2){window.console&&console.log('terminating; too few slides: '+els.length);return;}
var opts=$.extend({},$.fn.cycle.defaults,options||{},$.metadata?$cont.metadata():$.meta?$cont.data():{});var meta=$.isFunction($cont.data)?$cont.data(opts.metaAttr):null;if(meta)
opts=$.extend(opts,meta);opts.before=opts.before?[opts.before]:[];opts.after=opts.after?[opts.after]:[];opts.after.unshift(function(){opts.busy=0;});var cls=this.className;opts.width=parseInt((cls.match(/w:(\d+)/)||[])[1])||opts.width;opts.height=parseInt((cls.match(/h:(\d+)/)||[])[1])||opts.height;opts.timeout=parseInt((cls.match(/t:(\d+)/)||[])[1])||opts.timeout;if($cont.css('position')=='static')
$cont.css('position','relative');if(opts.width)
$cont.width(opts.width);if(opts.height&&opts.height!='auto')
$cont.height(opts.height);var first=0;$slides.css({position:'absolute',top:0,left:0}).each(function(i){$(this).css('z-index',els.length-i)});$(els[first]).css('opacity',1).show();if($.browser.msie)els[first].style.removeAttribute('filter');if(opts.fit&&opts.width)
$slides.width(opts.width);if(opts.fit&&opts.height&&opts.height!='auto')
$slides.height(opts.height);if(opts.pause)
$cont.hover(function(){this.cyclePause=1;},function(){this.cyclePause=0;});var txFn=$.fn.cycle.transitions[opts.fx];txFn&&txFn($cont,$slides,opts);$slides.each(function(){var $el=$(this);this.cycleH=(opts.fit&&opts.height)?opts.height:$el.height();this.cycleW=(opts.fit&&opts.width)?opts.width:$el.width();});if(opts.cssFirst)
$($slides[first]).css(opts.cssFirst);if(opts.timeout){if(opts.speed.constructor==String)
opts.speed={slow:600,fast:200}[opts.speed]||400;if(!opts.sync)
opts.speed=opts.speed/2;while((opts.timeout-opts.speed)<250)
opts.timeout+=opts.speed;}
opts.speedIn=opts.speed;opts.speedOut=opts.speed;opts.slideCount=els.length;opts.currSlide=first;opts.nextSlide=1;var e0=$slides[first];if(opts.before.length)
opts.before[0].apply(e0,[e0,e0,opts,true]);if(opts.after.length>1)
opts.after[1].apply(e0,[e0,e0,opts,true]);if(opts.click&&!opts.next)
opts.next=opts.click;if(opts.next)
$(opts.next).bind('click',function(){return advance(els,opts,opts.rev?-1:1)});if(opts.prev)
$(opts.prev).bind('click',function(){return advance(els,opts,opts.rev?1:-1)});if(opts.timeout)
this.cycleTimeout=setTimeout(function(){go(els,opts,0,!opts.rev)},opts.timeout+(opts.delay||0));});};function go(els,opts,manual,fwd){if(opts.busy)return;var p=els[0].parentNode,curr=els[opts.currSlide],next=els[opts.nextSlide];if(p.cycleTimeout===0&&!manual)
return;if(manual||!p.cyclePause){if(opts.before.length)
$.each(opts.before,function(i,o){o.apply(next,[curr,next,opts,fwd]);});var after=function(){if($.browser.msie)
this.style.removeAttribute('filter');$.each(opts.after,function(i,o){o.apply(next,[curr,next,opts,fwd]);});};if(opts.nextSlide!=opts.currSlide){opts.busy=1;$.fn.cycle.custom(curr,next,opts,after);}
var roll=(opts.nextSlide+1)==els.length;opts.nextSlide=roll?0:opts.nextSlide+1;opts.currSlide=roll?els.length-1:opts.nextSlide-1;}
if(opts.timeout)
p.cycleTimeout=setTimeout(function(){go(els,opts,0,!opts.rev)},opts.timeout);};function advance(els,opts,val){var p=els[0].parentNode,timeout=p.cycleTimeout;if(timeout){clearTimeout(timeout);p.cycleTimeout=0;}
opts.nextSlide=opts.currSlide+val;if(opts.nextSlide<0){opts.nextSlide=els.length-1;}
else if(opts.nextSlide>=els.length){opts.nextSlide=0;}
go(els,opts,1,val>=0);return false;};$.fn.cycle.custom=function(curr,next,opts,cb){var $l=$(curr),$n=$(next);$n.css(opts.cssBefore);var fn=function(){$n.animate(opts.animIn,opts.speedIn,opts.easeIn,cb)};$l.animate(opts.animOut,opts.speedOut,opts.easeOut,function(){$l.css(opts.cssAfter);if(!opts.sync)fn();});if(opts.sync)fn();};$.fn.cycle.transitions={fade:function($cont,$slides,opts){$slides.not(':eq(0)').hide();opts.cssBefore={opacity:0,display:'block'};opts.cssAfter={display:'none'};opts.animOut={opacity:0};opts.animIn={opacity:1};},fadeout:function($cont,$slides,opts){opts.before.push(function(curr,next,opts,fwd){$(curr).css('zIndex',opts.slideCount+(fwd===true?1:0));$(next).css('zIndex',opts.slideCount+(fwd===true?0:1));});$slides.not(':eq(0)').hide();opts.cssBefore={opacity:1,display:'block',zIndex:1};opts.cssAfter={display:'none',zIndex:0};opts.animOut={opacity:0};}};$.fn.cycle.ver=function(){return ver;};$.fn.cycle.defaults={animIn:{},animOut:{},fx:'fade',after:null,before:null,cssBefore:{},cssAfter:{},delay:0,fit:0,height:'auto',metaAttr:'cycle',next:null,pause:0,prev:null,speed:1000,slideExpr:null,sync:1,timeout:4000};})(jQuery);
//QueryString reader fcn
new function(settings){var $separator=settings.separator||'&';var $spaces=settings.spaces===false?false:true;var $suffix=settings.suffix===false?'':'[]';var $prefix=settings.prefix===false?false:true;var $hash=$prefix?settings.hash===true?"#":"?":"";var $numbers=settings.numbers===false?false:true;jQuery.query=new function(){var is=function(o,t){return o!=undefined&&o!==null&&(!!t?o.constructor==t:true);};var parse=function(path){var m,rx=/\[([^[]*)\]/g,match=/^(\S+?)(\[\S*\])?$/.exec(path),base=match[1],tokens=[];while(m=rx.exec(match[2]))tokens.push(m[1]);return[base,tokens];};var set=function(target,tokens,value){var o,token=tokens.shift();if(typeof target!='object')target=null;if(token===""){if(!target)target=[];if(is(target,Array)){target.push(tokens.length==0?value:set(null,tokens.slice(0),value));}else if(is(target,Object)){var i=0;while(target[i++]!=null);target[--i]=tokens.length==0?value:set(target[i],tokens.slice(0),value);}else{target=[];target.push(tokens.length==0?value:set(null,tokens.slice(0),value));}}else if(token&&token.match(/^\s*[0-9]+\s*$/)){var index=parseInt(token,10);if(!target)target=[];target[index]=tokens.length==0?value:set(target[index],tokens.slice(0),value);}else if(token){var index=token.replace(/^\s*|\s*$/g,"");if(!target)target={};if(is(target,Array)){var temp={};for(var i=0;i<target.length;++i){temp[i]=target[i];}
target=temp;}
target[index]=tokens.length==0?value:set(target[index],tokens.slice(0),value);}else{return value;}
return target;};var queryObject=function(a){var self=this;self.keys={};if(a.queryObject){jQuery.each(a.get(),function(key,val){self.SET(key,val);});}else{jQuery.each(arguments,function(){var q=""+this;q=q.replace(/^[?#]/,'');q=q.replace(/[;&]$/,'');if($spaces)q=q.replace(/[+]/g,' ');jQuery.each(q.split(/[&;]/),function(){var key=this.split('=')[0];var val=this.split('=')[1];if(!key)return;if($numbers){if(/^[+-]?[0-9]+\.[0-9]*$/.test(val))
val=parseFloat(val);else if(/^[+-]?[0-9]+$/.test(val))
val=parseInt(val,10);}
val=(!val&&val!==0)?true:val;if(val!==false&&val!==true&&typeof val!='number')
val=decodeURIComponent(val);self.SET(key,val);});});}
return self;};queryObject.prototype={queryObject:true,has:function(key,type){var value=this.get(key);return is(value,type);},GET:function(key){if(!is(key))return this.keys;var parsed=parse(key),base=parsed[0],tokens=parsed[1];var target=this.keys[base];while(target!=null&&tokens.length!=0){target=target[tokens.shift()];}
return typeof target=='number'?target:target||"";},get:function(key){var target=this.GET(key);if(is(target,Object))
return jQuery.extend(true,{},target);else if(is(target,Array))
return target.slice(0);return target;},SET:function(key,val){var value=!is(val)?null:val;var parsed=parse(key),base=parsed[0],tokens=parsed[1];var target=this.keys[base];this.keys[base]=set(target,tokens.slice(0),value);return this;},set:function(key,val){return this.copy().SET(key,val);},REMOVE:function(key){return this.SET(key,null).COMPACT();},remove:function(key){return this.copy().REMOVE(key);},EMPTY:function(){var self=this;jQuery.each(self.keys,function(key,value){delete self.keys[key];});return self;},load:function(url){var hash=url.replace(/^.*?[#](.+?)(?:\?.+)?$/,"$1");var search=url.replace(/^.*?[?](.+?)(?:#.+)?$/,"$1");return new queryObject(url.length==search.length?'':search,url.length==hash.length?'':hash);},empty:function(){return this.copy().EMPTY();},copy:function(){return new queryObject(this);},COMPACT:function(){function build(orig){var obj=typeof orig=="object"?is(orig,Array)?[]:{}:orig;if(typeof orig=='object'){function add(o,key,value){if(is(o,Array))
o.push(value);else
o[key]=value;}
jQuery.each(orig,function(key,value){if(!is(value))return true;add(obj,key,build(value));});}
return obj;}
this.keys=build(this.keys);return this;},compact:function(){return this.copy().COMPACT();},toString:function(){var i=0,queryString=[],chunks=[],self=this;var addFields=function(arr,key,value){if(!is(value)||value===false)return;var o=[key];if(value!==true){o.push("=");o.push(encodeURIComponent(value));}
arr.push(o.join(""));};var build=function(obj,base){var newKey=function(key){return!base||base==""?[key].join(""):[base,"[",key,"]"].join("");};jQuery.each(obj,function(key,value){if(typeof value=='object')
build(value,newKey(key));else
addFields(chunks,newKey(key),value);});};build(this.keys);if(chunks.length>0)queryString.push($hash);queryString.push(chunks.join($separator));return queryString.join("");}};return new queryObject(location.search,location.hash);};}(jQuery.query||{});

function slideshow() {
	if ($(".slideshowContainer").length) {

		var slideWdth = $(".slideshow").width();
		var slideHgt = $(".slideshow").height();
		
		$(".slideshow IMG").each(function() {
			var imgWdth = $(this).width();
			var imgHgt = $(this).height();
			var imgPadW = slideWdth - imgWdth;
			var imgPadH = slideHgt - imgHgt;
//			$(this).css({"padding" : (imgPadH / 2) + "px " + (imgPadW / 2) + "px " + (imgPadH / 2) + "px " + (imgPadW / 2) + "px"});
			$(this).css({"margin" : "4px 3px 3px 3px"});
		});

		$(".slideshow").cycle("fade");
		
	}
}

/*
function lightboxGallery() {
	if ($("DIV.lightboxGallery").length) {
		$('.lightboxGallery').each(function(){
			$('.lightbox', this).lightBox();
		});
	}
}
*/
function onSelectChange() {
	$(".selectMenu").change(function() {
		if($(this).val() != ""){
			window.location = "brokerage.php?boatCategory=" + $(this).val();
		} else {
			window.location = "brokerage.php";
		}
	});

	$(".selectMenuSold").change(function() {
		if($(this).val() != ""){
			window.location = "sold.php?boatCategory=" + $(this).val();
		} else {
			window.location = "sold.php";
		}
	});

}

/*
function enquiryForm() {
	if ($("#frmContainer").length) {
		
		var frmW = $("#frmContent").width();
		var frmH = $("#frmContent").height();
		var scrnW = $(window).width();
		var scrnH = $(window).height();
		
		$("#frmContent").css({
			"top" : ((scrnH - frmH) / 2) + "px",
			"left" : ((scrnW - frmW) / 2) + "px"
//			"margin" : ((scrnH - frmH) / 2) + "px " + ((scrnW - frmW) / 2) + "px " + ((scrnH - frmH) / 2) + "px " + ((scrnW - frmW) / 2) + "px"
		})
		
		$("A.enqLink").click(function() {
			$("BODY").scrollTop(0);
			$("#frmContainer").show();
		});
		
		$("A#frmEnqCls").click(function() {
			$("#frmContainer").hide();
		});
		
		var mouse_is_inside = false;
		
	    $("#frmContent, #ui-datepicker-div").hover(function(){ 
	        mouse_is_inside=true; 
	    }, function(){ 
	        mouse_is_inside=false; 
	    });
	
	    $("#frmContainer").mouseup(function(){ 
	        if(! mouse_is_inside) {
				$("#frmContainer").hide();
			}
	    });
		
	}
}
*/
function enquiryCalendar() {
	if ($("#frmContent").length) {
		$(".datepicker").datepicker({
			showOn: "both",
			buttonImage: "images/calendar.gif",
			buttonImageOnly: true,
			dateFormat: "dd/mm/yy"
		});
	}
}

function enquiryForm() {

	var stepId = $.query.get("step");
	stepId = Number(stepId);

	if (stepId == 0) {
		$("#frmLoading").fadeOut(500, function() {
			$("#frmEnquiry").fadeIn(500);
		});
	}

	if (stepId == 1) {
		$("#frmLoading").fadeOut(500, function() {
			$("#frmEnquiry2").fadeIn(500);
		});
	}
	
	if (stepId == 2) {
		$("#frmLoading").fadeOut(500, function() {
			$("#frmConf").fadeIn(500);
		});
	}
	
/*
	$("A#frmEnqCls").click(function() {
		$.fancybox.close;
	});
*/
	
}

function enquiryValidation() {
	if ($("#frmEnquiry").length) {
		$("#submit").click(function() {
			var errMsg = "";
			if ($("#strFirstname").val() == "") {
				errMsg = errMsg + "Please enter your firstname<br />";
			}
			if ($("#strSurname").val() == "") {
				errMsg = errMsg + "Please enter your surname<br />";
			}
			if ($("#strEmail").val() == "") {
				errMsg = errMsg + "Please enter your email address<br />";
			}
			if (!isValidEmailAddress($("#strEmail").val())) {
				errMsg = errMsg + "Please enter a valid email address<br />";
			}
			if (errMsg != "") {
				$("P#errMsg").html(errMsg).show();
				return false;
			}
		});
	}
	/*if ($("#frmEnquiry2").length) {
		$("#submit").click(function() {
			var errMsg = "";
			if ($("#strDateField").val() == "") {
				errMsg = errMsg + "Please select a date<br />";
			}
			if (errMsg != "") {
				$("P#errMsg").html(errMsg).show();
				return false;
			}
		});
	}*/
}

function isValidEmailAddress(emailAddress) {
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	return pattern.test(emailAddress);
}

$(document).ready(function() {
	setTimeout('slideshow();',1000);
//	lightboxGallery();
	onSelectChange();
	enquiryForm();
	enquiryCalendar();
	enquiryValidation();
});

<!--cycle-->
$(document).ready(function() {
    $('.slider').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
});
