﻿function validateFormOnSubmit(theForm) {
	reason = "";
	
	reason += validateEmpty(theForm.full_name,"Enter your full name",'','fullnameText');
	//reason += validateEmpty(theForm.telephone_number,"Please fill valid Telephone Number",'','telephone_numberText');
	reason += validateEmail(theForm.email,'emailText');
	reason += validateEmpty(theForm.country,"Select your country",'','countryText');
	reason += validateEmpty(theForm.city,"Enter your city",'','cityText');
    reason += validateEmpty(theForm.arrival_date,"Enter Arrival Date",'','a_Text');
    reason += validateEmpty(theForm.departure_date,"Enter Departure Date",'','d_Text');
	reason += validateEmpty(theForm.recaptcha_response_field,"Complete the security check",'','recaptcha_response_fieldText');

	if (reason != "") {
		if(document.getElementById('errorbox2')){document.getElementById('errorbox2').style.display='none';};
		if(document.getElementById('inner_contant_red2')){document.getElementById('inner_contant_red2').style.display='none';};
		if(document.getElementById('errorbox_error')){document.getElementById('errorbox_error').style.display='none';};
		document.getElementById('errorbox').style.display = 'block';
		document.getElementById('inner_contant_red').style.display = 'block';
		document.getElementById('inner_contant_red').innerHTML = '<ul style="padding-left:15px;"><b>Please correct the following errors:</b><br />'+reason+'</ul>';
		scrollTo(0,200);
		//alert("Please correct errors :\n" + reason);
		return false;
	} else {
		if(document.getElementById('errorbox2')){document.getElementById('errorbox2').style.display='none';};
		if(document.getElementById('inner_contant_red2')){document.getElementById('inner_contant_red2').style.display='none';};
		if(document.getElementById('errorbox_error')){document.getElementById('errorbox_error').style.display='none';};
		document.getElementById('loadingimage').style.display = 'block';
		document.getElementById('errorbox').style.display = 'none';
		document.getElementById('inner_contant_red').style.display = 'none';
		document.getElementById('inner_contant_red').innerHTML = '';
		return true;
	}
}

			// We only want these styles applied when javascript is enabled
			$('div.navigation').css({'width' : '160px', 'float' : 'left'});
			$('div.content').css('display', 'block');

			// Initially set opacity on thumbs and add
			// additional styling for hover effect on thumbs
			var onMouseOutOpacity = 1;
			$('#thumbs ul.thumbs li').css('opacity', onMouseOutOpacity)
				.hover(
					function () {
						$(this).not('.selected').fadeTo('fast', 1.0);
					}, 
					function () {
						$(this).not('.selected').fadeTo('fast', onMouseOutOpacity);
					}
				);

			$(document).ready(function() {
				// Initialize Advanced Galleriffic Gallery
				var galleryAdv = $('#gallery').galleriffic('#thumbs', {
					delay:                  2000,
					numThumbs:              4,
					preloadAhead:           10,
					enableTopPager:         true,
					enableBottomPager:      true,
					imageContainerSel:      '#slideshow',
					controlsContainerSel:   '#controls',
					captionContainerSel:    '#caption',
					loadingContainerSel:    '#loading',
					renderSSControls:       true,
					renderNavControls:      true,
					playLinkText:           'P',
					pauseLinkText:          'P ',
					prevLinkText:           'P',
					nextLinkText:           'N',
					nextPageLinkText:       'Next',
					prevPageLinkText:       'Previous',
					enableHistory:          true,
					autoStart:              false,
					onChange:               function(prevIndex, nextIndex) {
						$('#thumbs ul.thumbs').children()
							.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
							.eq(nextIndex).fadeTo('fast', 1.0);
					},
					onTransitionOut:        function(callback) {
						$('#caption').fadeTo('fast', 0.0);
						$('#slideshow').fadeTo('fast', 0.0, callback);
					},
					onTransitionIn:         function() {
						$('#slideshow').fadeTo('fast', 1.0);
						$('#caption').fadeTo('fast', 1.0);
					},
					onPageTransitionOut:    function(callback) {
						$('#thumbs ul.thumbs').fadeTo('fast', 0.0, callback);
					},
					onPageTransitionIn:     function() {
						$('#thumbs ul.thumbs').fadeTo('fast', 1.0);
					}
				});
			});
	
	
	function setcurrent(){

var scnbc = querySt("current");
if(scnbc == "overview"){
countries.expandit(0);
}else if (scnbc == "details") {
countries.expandit(1);
}
else if (scnbc == "map") {
countries.expandit(2);
}
else if (scnbc == "photos") {
countries.expandit(3);
}
else if (scnbc == "reviews") {
countries.expandit(4);
}
else if (scnbc == "contact") {
countries.expandit(5);
}
}
function querySt(ji)
{

hu = window.location.search.substring(1);
gy = hu.split("&");
for (i=0;i<gy.length;i++)
{
ft = gy[i].split("=");
if (ft[0] == ji)
{
return ft[1];
}
}
return "";
}


    function back(){
        jQuery("#back_form").submit();
    }

var countries=new ddtabcontent("countrytabs")
countries.setpersist(true)
countries.setselectedClassTarget("link") //"link" or "linkparent"
countries.init()



$(document).ready(function() {
    $("#arrival_date").datepicker({showOn: 'both', buttonImage: 'images/calendar.gif', buttonImageOnly: true});
    $('#arrival_date').datepicker('option', {dateFormat: "dd-mm-yy"});
    $('#arrival_date').datepicker('option', 'yearRange', '2010:2015');
    $('#arrival_date').datepicker('option', 'changeYear', true);
    $('#arrival_date').datepicker('option', 'changeMonth', true);

    $("#departure_date").datepicker({showOn: 'both', buttonImage: 'images/calendar.gif', buttonImageOnly: true});
    $('#departure_date').datepicker('option', {dateFormat: "dd-mm-yy"});
    $('#departure_date').datepicker('option', 'yearRange', '2010:2015');
    $('#departure_date').datepicker('option', 'changeYear', true);
    $('#departure_date').datepicker('option', 'changeMonth', true);
});




