jQuery(document).ready(function(){
	showLogo();
	jQuery(".epCtl5a img").mouseover(function(){
		hideEPTerms();
	});
	jQuery(".epCtl5").mouseout(function(){
		hideEPTerms();
	});
	jQuery(".epCtl3,.epCtl5b input").mouseover(function(){
		showEPTerms();
	});
});

jQuery(window).resize(function(){
	showLogo();
});

function handleInquiry() {
	jQuery(".inqNext").click(function(){
		var currPage = jQuery("#currPage").html()-0;
		validateInquiry(currPage);
	});
}

function validateInquiry(intPageNr) {
	var startQst = 1;
	var valid = true;
	
	switch (intPageNr) {
		case 2 : startQst = 5; break; 
		case 3 : startQst = 9; break;
		case 4 : startQst = 13; break;
		default: startQst = 1;
	}
	
	for (var q=startQst; q<startQst+4; q++) {
		var chk = jQuery("#dhq"+q).find(":checked");
		if (chk.length == 0) {
			valid = false;
			jQuery("#hq"+q).addClass("inqErr");
		} else {
			jQuery("#hq"+q).removeClass("inqErr");
		}
	}
	
	if (valid) {
		if (intPageNr == 4) {
			setCookie("eprti_inquiry",1,60,jQuery("#eprtiDomain").html());
			location.href="form,1.html";
		} else {
			jQuery("#inqP"+intPageNr).hide();
			intPageNr++;
			jQuery("#inqP"+intPageNr).show();
			jQuery("#currPage").html(intPageNr);
		}
	}
}

function orderTermsShow() {
	var top = getScrollXY();
	var width = getWindowSize();
	
	width = width[0] - 50;
	
	jQuery("#cluetip").css({
		top: top[1] + 10 + 'px',
		left: '10px',
		width: width + 'px'
	});
}

function orderTermsTop() {
	var top = getScrollXY();
	
	jQuery("#cluetip").css({
		top: top[1] + 10 + 'px',
		left: '10px'
	});
}

/**
 * wybranie zakladki danych hoteli
 * @param {Object} intTabNumber
 */
function selectHotelTab(intTabNumber) {
	jQuery("#hdtab1a").addClass("hdtabsela");
	jQuery("#hdtab2a").addClass("hdtabsela");
	jQuery("#hdtab3a").addClass("hdtabsela");
	jQuery("#hdtab4a").addClass("hdtabsela");

	jQuery("#hdtab1b").addClass("hdtabselb");
	jQuery("#hdtab2b").addClass("hdtabselb");
	jQuery("#hdtab3b").addClass("hdtabselb");
	jQuery("#hdtab4b").addClass("hdtabselb");
	
	jQuery("#hdtab1b div div").show();
	jQuery("#hdtab2b div div").show();
	jQuery("#hdtab3b div div").show();
	jQuery("#hdtab4b div div").show();
	jQuery("#hdtab" + intTabNumber + "b div div").hide();

	jQuery("#hdtab"+intTabNumber+"a").removeClass("hdtabsela");
	jQuery("#hdtab"+intTabNumber+"b").removeClass("hdtabselb");
}

/**
 * pokazuje logo
 * @return
 */
function showLogo() {
	var top = jQuery("#toptd");
	if (top != undefined) {
		var pos = jQuery(top).position();
		if (pos != undefined) {
			jQuery(".logoeprti").css({
				top: pos.top + 10 + "px",
				left: pos.left + 5 + "px"
			});
		}
	}
}

function allShowStep1() {
	jQuery("#a1").removeClass("allS2a").addClass("allS1a");
	jQuery("#a2").removeClass("allS2a allS2b").addClass("allS1a allS1b");
}

function allShowStep2() {
	jQuery("#a1").removeClass("allS1a").addClass("allS2a");
	jQuery("#a2").removeClass("allS1a allS1b").addClass("allS2a allS2b");
}

function showRibbon() {
	showRibbonPositionLogin();
	showRibbonPosition();
	
	jQuery(window).resize(function(){
		showRibbonPositionLogin();
		showRibbonPosition();
	});
}

function showRibbonPositionLogin() {
	var top = 180;
	var pos = jQuery(".lgnTop").position();
	if (pos) {
		var left = pos.left + 410;
		jQuery("#ribbon").css({
			top: top,
			left: left
		}).show();
	}
}

function showRibbonPosition() {
	var top = 125;
	var pos = jQuery("#toptd").position();
	if (pos) {
		var left = pos.left + 195;
		jQuery("#ribbon").css({
			top: top,
			left: left
		}).show();
	}
}

/**
 * zmiana stylu i usunięcie tekstu po wejściu do pola
 */
function inquiryEmailFocus() {
	jQuery("#inqEmail").focus(function(){
		var txt = jQuery("#inqEmailOff").html();
		if (this.value == txt) {
			jQuery(this).addClass("inqe5");
			this.value = '';
		}
	});
}

function showEPTerms() {
	jQuery(".epCtl5").show();
}

function hideEPTerms() {
	jQuery(".epCtl5").hide();
}
