document.write('<script type="text/javascript" src="jslib/jquery-1.6.1.min.js"><\/script><script type="text/javascript" src="jslib/jquery-ui-1.8.13.custom.min.js"><\/script><script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAA2lgIo0riWNzK_6Kom_LNgxRD_ltbQypPnfeCYnP9R6CZ7wcbtxTxOWU4jiO6BpJL2LXz1aqI6ohuUw" type="text/javascript"></script>');
/*document.write('<script type="text/javascript" src="jslib/prototype.js"><\/script><script type="text/javascript" src="jslib/scriptaculous.js"><\/script><script type="text/javascript" src="jslib/xhconn.js"><\/script><script src="http://maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=ABQIAAAA2lgIo0riWNzK_6Kom_LNgxRD_ltbQypPnfeCYnP9R6CZ7wcbtxTxOWU4jiO6BpJL2LXz1aqI6ohuUw" type="text/javascript"></script>');*/
//ABQIAAAA2lgIo0riWNzK_6Kom_LNgxS8efe1tmhuZwZofWgKSN6mmPaqihS32ub6sPL_N_XVj4Xck7Okgm2b6w local
//ABQIAAAA2lgIo0riWNzK_6Kom_LNgxRD_ltbQypPnfeCYnP9R6CZ7wcbtxTxOWU4jiO6BpJL2LXz1aqI6ohuUw web
function isEmpty(checkstr){
	var uzunluk = checkstr.length;
	var bosluk = checkstr.indexOf(' ');
	if (uzunluk == 0) return true;
	else
	if (bosluk == 0) return true;
	else
	return false;
}

function validMail(emailStr){
var checkTLD=1;
var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
var emailPat=/^(.+)@(.+)$/;
var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
var validChars="\[^\\s" + specialChars + "\]";
var quotedUser="(\"[^\"]*\")";
var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
var atom=validChars + '+';
var word="(" + atom + "|" + quotedUser + ")";
var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
var matchArray=emailStr.match(emailPat);

if (matchArray==null) {
	return false;
}

var user=matchArray[1];
var domain=matchArray[2];

for (i=0; i<user.length; i++) {
	if (user.charCodeAt(i)>127) {
		return false;
 }
}

for (i=0; i<domain.length; i++) {
	if (domain.charCodeAt(i)>127) {
		return false;
  }
}

if (user.match(userPat)==null) {
		return false;
}

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {
	for (var i=1;i<=4;i++) {
		if (IPArray[i]>255) {
			return false;
		}
	}
	return true;
}

var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
	if (domArr[i].search(atomPat)==-1) {
		return false;
  }
}

if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) {
	return false;
}

if (len<2) {
		return false;
}

return true;
}

var Gallery = {
	IntVal : 0,
	i : 1,
	Lastid : 0,
	onProcess : false,
	images : new Array(),
	CycleImages : function(){
		Gallery.IntVal = setInterval(Gallery.ImgProcess, 3000);
	},
	ImgProcess : function (){
		if (Gallery.i == Gallery.images.length) Gallery.i = 0;
			new Effect.Fade('imgsrc' + Gallery.Lastid, {duration : 0.2, from: 1.0, to: 0, afterFinish : function(effect){ $('imgsrc' + Gallery.Lastid).style.display = "none"; Gallery.Lastid = Gallery.i++; new Effect.Appear('imgsrc' + Gallery.Lastid, {duration : 0.2, from: 0, to: 1.0, afterFinish : function(effect){ Gallery.onProcess = false; } } );}} );
	},
	showImg : function (id){
		clearInterval(Gallery.IntVal);
		if ($('imgsrc' + Gallery.Lastid).src.search(Gallery.images[id]) == -1 && !Gallery.onProcess) {
			Gallery.onProcess = true;
			new Effect.Fade('imgsrc' + Gallery.Lastid, {duration : 0.2, from: 1.0, to: 0, afterFinish : function(effect){ $('imgsrc' + Gallery.Lastid).style.display = "none"; Gallery.Lastid = id; new Effect.Appear('imgsrc' + Gallery.Lastid, {duration : 0.2, from: 0, to: 1.0, afterFinish : function(effect){ Gallery.onProcess = false; } } );}} );
		}
	}
};

var fadeImg = {
	lastid : 0,
	nextid : 1,
	duration : 400,
	inProcess : false,
	imgInterval : null,
	intervalPeriod : 3000,
	checkImgInterval : null,
	fade : function(direction, sender) {
		if ($('#objContent div#videoContent').length > 0) {
			clearInterval(fadeImg.checkImgInterval);
			clearInterval(fadeImg.imgInterval);
/*			fadeImg.checkImgInterval = 1;
			fadeImg.imgInterval = 1;
			obj.changeObj(direction);*/
		} else {
			if (sender == null) fadeImg.stopInterval();
			var imgCount = $('#objContent img').length;
			if (imgCount > 1 && $('#objContent img').attr('id') != null) {
				if (!fadeImg.inProcess) {
					fadeImg.inProcess = true;
					var imgName = $('#objContent img')[fadeImg.lastid].id;
					var tmpName = imgName;
					if (direction == 'F') fadeImg.nextid = fadeImg.lastid + 1;
					else fadeImg.nextid = fadeImg.lastid - 1;
					if (fadeImg.nextid < 0) fadeImg.nextid = imgCount - 1;
					if (fadeImg.nextid > imgCount - 1) fadeImg.nextid = 0;
					tmpName = $('#objContent img')[fadeImg.nextid].id;
					$('#' + tmpName).fadeIn(fadeImg.duration);
					$('#' + imgName).fadeOut(fadeImg.duration, function(){
																											 fadeImg.lastid = fadeImg.nextid;
																											 fadeImg.inProcess = false;
																										 });
				}
			}
		}
	},
	startInterval : function() {
		fadeImg.imgInterval = setInterval("fadeImg.fade('F', 'proc')", fadeImg.intervalPeriod);
	},
	stopInterval : function() {
		clearInterval(fadeImg.imgInterval);
		fadeImg.imgInterval = null;
		fadeImg.checkImgInterval = setInterval("fadeImg.checkInterval()", fadeImg.intervalPeriod);
	},
	checkInterval : function () {
		if (fadeImg.imgInterval == null) {
			fadeImg.startInterval();
			clearInterval(fadeImg.checkImgInterval);
			fadeImg.checkImgInterval = null;
		}
	},
	deleteInterval : function() {
		clearInterval(fadeImg.checkImgInterval);
		clearInterval(fadeImg.imgInterval);
		fadeImg.imgInterval = null
	},
	showImg : function(imgId) {
		if (!fadeImg.inProcess && fadeImg.lastid != imgId) {
			fadeImg.deleteInterval();
			fadeImg.inProcess = true;
			var imgCount = $('#objContent img').length;
			var imgName = $('#objContent img')[fadeImg.lastid].id;
			var tmpName = $('#objContent img')[imgId].id;
			fadeImg.nextid = imgId;
			if (fadeImg.nextid > imgCount - 1) fadeImg.nextid = 0;
			tmpName = $('#objContent img')[fadeImg.nextid].id;
			$('#' + tmpName).fadeIn(fadeImg.duration);
			$('#' + imgName).fadeOut(fadeImg.duration, function(){
																									 fadeImg.lastid = fadeImg.nextid;
																									 fadeImg.inProcess = false;
																								 });
		}
	}
};

var Brochure = {
	postData : function(){
		if (isEmpty($('#name').val())){
			$('#name').effect('highlight', {color:'#4E3227'}, 1000);
			return false;
		}
		if (isEmpty($('#surname').val())){
			$('#surname').effect('highlight', {color:'#4E3227'}, 1000);
			return false;
		}
		if (!validMail($('#email').val())){
			$('#email').effect('highlight', {color:'#4E3227'}, 1000);
			return false;
		}
		if (isEmpty($('#address').val())){
			$('#address').effect('highlight', {color:'#4E3227'}, 1000);
			return false;
		}
		if (isEmpty($('#city').val())){
			$('#city').effect('highlight', {color:'#4E3227'}, 1000);
			return false;
		}
		if (isEmpty($('#postcode').val())){
			$('#postcode').effect('highlight', {color:'#4E3227'}, 1000);
			return false;
		}
		return true;
		}
};

var Register = {
	postData : function(){
		if (isEmpty($('#name').val())){
			$('#name').effect('highlight', {color:'#4E3227'}, 1000);
			return false;
		}
		if (isEmpty($('#surname').val())){
			$('#surname').effect('highlight', {color:'#4E3227'}, 1000);
			return false;
		}
		if (!validMail($('#email').val())){
			$('#email').effect('highlight', {color:'#4E3227'}, 1000);
			return false;
		}
		return true;
		}
};

var Contact = {
	postData : function(){
		if (isEmpty($('#name').val())){
			$('#name').effect('highlight', {color:'#4E3227'}, 1000);
			return false;
		}
		if (isEmpty($('#surname').val())){
			$('#surname').effect('highlight', {color:'#4E3227'}, 1000);
			return false;
		}
		if (!validMail($('#email').val())){
			$('#email').effect('highlight', {color:'#4E3227'}, 1000);
			return false;
		}
		if (isEmpty($('#comments').val())){
			$('#comments').effect('highlight', {color:'#4E3227'}, 1000);
			return false;
		}
		return true;
		}
};

var Charter = {
	changeArea : function(val){
		for(var i = $("#area").length - 1; i>=0; i--)
			$("#area option").remove(i);
		switch(++val){
			case 1:
				$('#area').append($('<option></option>').val('Fort Lauderdale').html('Fort Lauderdale'));
				$('#area').append($('<option></option>').val('Miami').html('Miami'));
				$('#area').append($('<option></option>').val('Bahama Islands').html('Bahama Islands'));
				break;
			case 2:
				$('#area').append($('<option></option>').val('St. Tropez').html('St. Tropez'));
				$('#area').append($('<option></option>').val('Cannes').html('Cannes'));
				$('#area').append($('<option></option>').val('Monaco').html('Monaco'));
				break;
			case 3:
				$('#area').append($('<option></option>').val('Holland / Belgium').html('Holland / Belgium'));
				break;
		}
	},
	postData : function(){
		if (isEmpty($('#zeelander').val())){
			$('#zeelander').effect('highlight', {color:'#4E3227'}, 1000);
			return false;
		}
		if (isEmpty($('#area').val())){
			$('#area').effect('highlight', {color:'#4E3227'}, 1000);
			return false;
		}
		if (isEmpty($('#crew').val())){
			$('#crew').effect('highlight', {color:'#4E3227'}, 1000);
			return false;
		}
		if (isEmpty($('#startdate').val()) || !date.isValid($('#startdate').val())){
			$('#startdate').effect('highlight', {color:'#4E3227'}, 1000);
			return false;
		}
		if (isEmpty($('#duration').val())){
			$('#duration').effect('highlight', {color:'#4E3227'}, 1000);
			return false;
		}
		if (isEmpty($('#namesurname').val())){
			$('#namesurname').effect('highlight', {color:'#4E3227'}, 1000);
			return false;
		}
		if (!validMail($('#email').val())){
			$('#email').effect('highlight', {color:'#4E3227'}, 1000);
			return false;
		}
		if (isEmpty($('#phone').val())){
			$('#phone').effect('highlight', {color:'#4E3227'}, 1000);
			return false;
		}
		return true;
		}
};

var ZeelInt = {
	CurrentPos : 0,
	Step : 20,
	scrollUp : function() {
		if (ZeelInt.CurrentPos < 0) {
			ZeelInt.CurrentPos = ZeelInt.CurrentPos + ZeelInt.Step;
			$('txtsource').style.top = ZeelInt.CurrentPos + 'px';
			}
		},
	scrollDown : function() {
		if (ZeelInt.CurrentPos > ($('txtscroll').clientHeight - $('txtsource').clientHeight)) {
			ZeelInt.CurrentPos = ZeelInt.CurrentPos - ZeelInt.Step;
			$('txtsource').style.top = ZeelInt.CurrentPos + 'px';
			}
		}
};

var ScrollTxt = {
	CurrentPos : 0,
	Step : 4,
	ScrInt : null,
	Scrolling : false,
	scrollUp : function(elmid) {
		ScrollTxt.ScrInt = setInterval('ScrollTxt.scrUp(' + elmid + ')', 100);
		},
	scrollDown : function(elmid) {
		ScrollTxt.ScrInt = setInterval('ScrollTxt.scrDown(' + elmid + ')', 100);
		},
	cancelInt : function () {
		try{
			clearInterval(ScrollTxt.ScrInt);
		}catch(e){}
		},
	scrUp : function(elmid) {
		if ((ScrollTxt.CurrentPos < 0) && (!ScrollTxt.Scrolling)) {
			ScrollTxt.Scrolling = true;
			ScrollTxt.CurrentPos = ScrollTxt.CurrentPos + ScrollTxt.Step;
			$('#txtsource' + elmid).css({top: ScrollTxt.CurrentPos});
			ScrollTxt.Scrolling = false;
			}
		},
	scrDown : function(elmid) {
		if ((ScrollTxt.CurrentPos > ($('#txtscroll' + elmid).height() - $('#txtsource' + elmid).height())) || (ScrollTxt.CurrentPos > ($('#txtscroll' + elmid).height() - $('#txtscroll' + elmid).css('height'))) && (!ScrollTxt.Scrolling)) {
//		if ((ScrollTxt.CurrentPos > ($('#txtscroll' + elmid).height() - $('#txtsource' + elmid).height())) || (ScrollTxt.CurrentPos > ($('#txtscroll' + elmid).height() - $('#txtscroll' + elmid).css('height'))) && (!ScrollTxt.Scrolling)) {
			ScrollTxt.Scrolling = true;
			ScrollTxt.CurrentPos = ScrollTxt.CurrentPos - ScrollTxt.Step;
			$('#txtsource' + elmid).css({top: ScrollTxt.CurrentPos});
			ScrollTxt.Scrolling = false;
			}
		}
};

var Dealers = {
	LastArea : 0,
	selectArea : function(areaid) {
		$('#cbmsrc' + Dealers.LastArea).slideUp();
		Dealers.LastArea = areaid;
		$('#cbmsrc' + Dealers.LastArea).slideDown();
		},
	setLocation : function(dealerid, pos) {
		try{
			$.ajax({
				url: "dealerpopup.inc.php",
				global: false,
				cache: false,
				type: "POST",
				data: ({dealerid : dealerid}),
				dataType: "html",
				success: function(data){
					var pointPosition = $('#point' + dealerid).offset();
					$('#dealerpopup').fadeOut(10).html(data).css({top: Math.round(pointPosition.top - ($('#dealerpopup').height() / 2)), left: Math.round(pointPosition.left - ($('#dealerpopup').width() / 2))}).fadeIn('slow');
				}
			});
		} catch(err){alert(err);}
	},
	windowOpen : function(dealerid) {
		var myWindow = window.open("map.php?dealerid=" + dealerid, "mywindow", "width = 600, height = 450, sizeable = 0");
	},
	mapInitalize : function(cid) {
		if (GBrowserIsCompatible()) {
			var map = new GMap2(document.getElementById("gmap"));
			var ll = new GLatLng(cid[0], cid[1]);
			map.setCenter(ll, cid[cid.length - 1]);
			map.setUIToDefault();
			var i = 0;
			while(i < cid.length - 2)
				map.addOverlay(new GMarker(new GLatLng(cid[i++], cid[i++])));
		}
	}
}

var hint = {
	findPosX : function(obj){
		var curleft = 0;
		if(obj.offsetParent)
				while(1){
					curleft += obj.offsetLeft;
					if(!obj.offsetParent) break;
					obj = obj.offsetParent;
				}
		else if(obj.x) curleft += obj.x;
		return curleft;
	},
	findPosY : function(obj){
		var curtop = 0;
		if(obj.offsetParent)
				while(1){
					curtop += obj.offsetTop;
					if(!obj.offsetParent) break;
					obj = obj.offsetParent;
				}
		else if(obj.y) curtop += obj.y;
		return curtop;
	},
	setHint : function(anchorelm, hintdiv, pos, hinttxt){
		$(hintdiv).innerHTML = '<center>' + hinttxt + '</center>';
		$(hintdiv).style.display = $(hintdiv).style.display == 'block' ? 'none' : 'block';
		switch(pos){
			case 'top':
				if (Prototype.Browser.IE) $(hintdiv).style.left = (hint.findPosX(anchorelm) + anchorelm.offsetWidth / 2 - $(hintdiv).offsetWidth / 2);
				else $(hintdiv).style.left = (hint.findPosX(anchorelm) + anchorelm.offsetWidth / 2 - $(hintdiv).offsetWidth / 2);
				if (Prototype.Browser.IE) $(hintdiv).style.top = hint.findPosY(anchorelm) - $(hintdiv).clientHeight - anchorelm.clientHeight;
				else $(hintdiv).style.top = hint.findPosY(anchorelm) - $(hintdiv).offsetHeight - anchorelm.offsetHeight;
			break;
			case 'left':
				$(hintdiv).style.left = hint.findPosX(anchorelm) - $(hintdiv).offsetWidth - 5;
				$(hintdiv).style.top = hint.findPosY(anchorelm) - anchorelm.offsetHeight / 2 - $(hintdiv).offsetHeight / 2;
			break;
			case 'right':
				$(hintdiv).style.left = hint.findPosX(anchorelm) + anchorelm.offsetWidth + 5;
				$(hintdiv).style.top = hint.findPosY(anchorelm) - anchorelm.offsetHeight / 2 - $(hintdiv).offsetHeight / 2;
			break;
			default:
				if (Prototype.Browser.IE) $(hintdiv).style.left = (hint.findPosX(anchorelm) + anchorelm.offsetWidth / 2 - $(hintdiv).clientWidth / 2);
				else $(hintdiv).style.left = (hint.findPosX(anchorelm) + anchorelm.offsetWidth / 2 - $(hintdiv).offsetWidth / 2);
				if (Prototype.Browser.IE) $(hintdiv).style.top = hint.findPosY(anchorelm);
				else $(hintdiv).style.top = hint.findPosY(anchorelm);
			break;
		}
	}
};

var date = {
	toInt : function(value){
		if (date.isValid(value)){
			dateval = value.split(".");
			var gunDeger = { 
				gun : parseInt(dateval[0], 10),
				ay : 0,
				aygun : (parseInt(dateval[1], 10) - 1 == 0) ? 12 : (parseInt(dateval[1], 10) - 1),
				yil : parseInt(dateval[2], 10) - 1900,
				aylar : [31, ((this.yil % 4 == 0) ? 29 : 28), 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
			};
			for (var i = 0; i < gunDeger.aygun; i++) gunDeger.ay += gunDeger.aylar[i];
			gunDeger.yil = (Math.floor(gunDeger.yil / 4) * 366) + ((gunDeger.yil - Math.floor(gunDeger.yil / 4)) * 365);
			return gunDeger.gun + gunDeger.ay + gunDeger.yil;
		} else return -1;
	},
	isValid : function(value){
		if (value != null || value !=  '') return /^\d{1,2}(\/)\d{1,2}(\/)\d{4}$/.test(value);
		else return false;
	}
};


