var currentP = '';
var currentI = 0;

window.onload = function () {



menuBtn('btn_menuhome', 'p=home', '0px -46px');
menuBtn('btn_menumonsoon', 'p=maldives-liveaboard', '0px -46px');
menuBtn('btn_menumaldives', 'p=maldives-info', '0px -46px');
menuBtn('btn_menucns', 'p=cruise-and-stay', '0px -46px');
menuBtn('btn_menubook', 'p=book', '0px -46px');
menuBtn('btn_menucontact', 'p=contact', '0px -46px');
menuBtn('btn_monsoon', 'p=monsoon', 'bottom left');


  if (document.getElementById('content')) {
		currentP = document.getElementById('content').name;
  }

  if (document.getElementById('galThumb')) {
			setPic('thumbEen', '1');
			setPic('thumbTwee', '2');
			setPic('thumbDrie', '3');
			setPic('thumbVier', '4');
			setPic('thumbVijf', '5');
			setPic('thumbZes', '6');
			setPic('thumbZeven', '7');
			setPic('thumbAcht', '8');
			setPic('thumbNegen', '9');
			setPic('thumbTien', '10');
  }



startShow();
menuEffect();
}





function startShow() {
  if(document.getElementById('bigVisual')) {
    var bigVisual = document.getElementById('bigVisual');
	  setTimeout("picCycle()",3600);
  }
}


function picCycle() {
	var slides = new Array();
	slides["home"]=['./gfx/liveaboard-safari-maldives.jpg',
					'./gfx/dive-spot-maldives.jpg',
					'./gfx/maldives-monsoon.jpg',
					'./gfx/dive-maldives.jpg',
					'./gfx/monsoon-liveaboard.jpg',
					'./gfx/maldives-exclusive.jpg',
					'./gfx/safari-maldives.jpg',
					'./gfx/liveaboard-maldives.jpg'
					];

	slides["monsoon"]=['./gfx/liveaboard-safari-maldives.jpg',
					   './gfx/maldives-monsoon.jpg',
					   './gfx/dive-maldives.jpg',
					   './gfx/dive-spot-maldives.jpg',
					   './gfx/maldives-exclusive.jpg',
					   './gfx/safari-maldives.jpg',
					   './gfx/liveaboard-maldives.jpg'
					   ];

	slides["maldives-diving"]=['./gfx/liveaboard-safari-maldives.jpg',
							   './gfx/scuba-diving.jpg',
							   './gfx/maldives-monsoon.jpg',
							   './gfx/dive-maldives.jpg',
							   './gfx/dive-spot-maldives.jpg',
							   './gfx/maldives-exclusive.jpg',
							   './gfx/safari-maldives.jpg',
							   './gfx/liveaboard-maldives.jpg'
							 ];


	slides["kuredu-island-resort"]=['./gfx/maldives-resort.jpg',
									  './gfx/kuredu-dive-holiday.jpg'
							 ];

	slides["komandoo-island-resort"]=['./gfx/komandoo-maldives.jpg',
									  './gfx/komandoo-maldives-holiday.jpg',
									  './gfx/spot-maldives-komandoo.jpg'
							 ];


	if(slides[currentP]) {
	 bigVisual.src=slides[currentP][currentI];

	if(currentI <= slides[currentP].length-2) {
		currentI++;
	}  else {
		currentI=0;
	}

	startShow();  // Back to startShow()
	}

}





function menuBtn(btnId, params, onOverPos) {
  if(document.getElementById(btnId)) {
  var btn=document.getElementById(btnId);
    btn.onmouseover=function() {
	  this.style.backgroundPosition=onOverPos;
    }

    btn.onmouseout=function() {
  	  this.style.backgroundPosition='';
    }
  }
//  btn.onclick= function (){
//	  asyncReq('GET', './index.php', params, 'right');
//  }
}



function clearField(fieldId) {
  var field = document.getElementById(fieldId);
  field.value='';
}



function tabEffect(pic,status) {
  var item = document.getElementById(pic);
  item.src='./../gfx/crm/'+pic+status+'.gif';
}


function numbersOnly(evt){

  evt = (evt) ? evt : event;

  var c = (evt.charCode) ? evt.charCode :

 ((evt.keyCode) ?
 	evt.keyCode : ((evt.wich) ? evt.wich : 0));

   if (c > 31 && (c < 48 || c > 57)) {
    alert("Please enter a number.");
    return false;
   }

   return true;
}



function valideerVeld(fieldId, minLength, imageId)  {
	 var veld = document.getElementById(fieldId);
	 var image = document.getElementById(imageId);
	 if (veld.value.length >= minLength) {
			image.src='./../gfx/ok_gn.gif';
		}
	 else {
			image.src='./../gfx/ok_gy.gif';
		}
	}


function valideerEmail(fieldId, imageId) {
	var veld = document.getElementById(fieldId);
	var image = document.getElementById(imageId);

	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(veld.value)){
		image.src='./../gfx/ok_gn.gif';
	}
	else {
		image.src='./../gfx/ok_gy.gif';
	}
}






function setPic(id, view) {
		document.getElementById(id).onmouseover= function() {
			this.style.cursor='pointer';
		}
		document.getElementById(id).onclick= function() {
	    document.getElementById('bigVisual').src = './gfx/gallery/'+document.getElementById(id).name+'-'+view+'.jpg';
		}
}

function setJustPic(pic) {
	    document.getElementById('bigVisual').src = pic;
}


function setDeck(id) {
		document.getElementById('raq-monsoon-sundeck').style.visibility="hidden";
		document.getElementById('raq-monsoon-restaurant').style.visibility="hidden";
		document.getElementById('raq-monsoon-bar').style.visibility="hidden";
		document.getElementById('raq-monsoon-cabins').style.visibility="hidden";

		document.getElementById('deckmap').style.backgroundImage="url(./gfx/"+id+".png)";
		document.getElementById('raq-'+id).style.visibility="visible";
		//setJustPic('./gfx/liveaboard-safari-maldives.jpg')
		asyncReq('GET', 'index.php', 'p='+id, 'deckmap');
}


function hoverEffect(id) {
	pic = document.getElementById(id);
	pic.src = "./gfx/monsoon-"+id+"-over.png";
	pic.onmouseout = function() {
						pic.src = pic.src = "./gfx/monsoon-"+id+".png";
				 	 }

}


function asyncReq(type, actie, params, doel) {
	if (typeof xmlHttp == 'undefined') {
		if (window.ActiveXObject) {
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		} else if (window.XMLHttpRequest) {
			xmlHttp = new XMLHttpRequest();
		  }
		requestHandle(xmlHttp, type, actie, params, doel);
	} else {
			if (window.ActiveXObject) {
				xmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP");
			} else if (window.XMLHttpRequest) {
				xmlHttp2 = new XMLHttpRequest();
			  }
			requestHandle(xmlHttp2, type, actie, params, doel);
	  }

}



function requestHandle(xmlHttpObj, type, actie, params, doel) {
	if(type == "GET") {
		actie = actie+'?'+params;
	}

    xmlHttpObj.open(type, actie, true);
    xmlHttpObj.onreadystatechange = function () {
		if((xmlHttpObj.readyState == 4) && (xmlHttpObj.status == 200)) {
     			document.getElementById(doel).innerHTML = xmlHttpObj.responseText;
					//alert(type+' - params:'+params);
		}
	}

	if(type == "GET") {
    	xmlHttpObj.send(null);
	} else {
    	xmlHttpObj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
    	xmlHttpObj.send(params);
	}
}



function menuEffect() {

  var btn=document.getElementsByName("menuButton");


  for(var i=0;i<btn.length;i++) {
	  btn[i].style.display="block";
	  btn[i].style.paddingBottom="1px";
	  btn[i].style.marginBottom="1px";

  	btn[i].onmouseover=function() {
	  this.style.filter='Alpha(opacity=65)';
	  this.style.MozOpacity=0.65;
	  this.style.cursor='pointer';

    }

    btn[i].onmouseout=function() {
	  this.style.filter='Alpha(opacity=100)';
	  this.style.MozOpacity=1;
    }
  }
}

