var zindex = 3;

function reloadPage() {
	$("body").css("display","inline").css("display","block");
}

function initTable() {
	$("table.price").each(function() {
		//$(this).find("tr").hover(function(){$(this).addClass("hover");}, function(){$(this).removeClass("hover");});
		$(this).find("tr>*:first-child").addClass("first-child");
		$(this).find("tr>*:last-child").addClass("last-child");
	});
}

function switchTab(current,aaa) {
	if(!$(current).parent("li").hasClass("active")) {
		if($(current).parents("ul").find("li:first-child").hasClass("active")) {
			$(current).parents("ul").find("li.bl").css("border-top","1px solid #dadada");
		} else {
			$(current).parents("ul").find("li.bl").css("border-top","none");
		}
		$(current).parents("ul").find("li").removeClass("active");
		$(current).parent("li").addClass("active");
	}
	return false;
}

function switchCardTab(current,who) {
	switchTab(current);
	$("#card .card-tab").hide();
	$("#card ."+who).show();
	return false;
}

function switchAddTab(current,who) {
	if(current.tagName=="A") {
		switchTab(current);
	} else {
		$("#add ul.tabs li.active").removeClass("active").next().addClass("active");
	}
	$("#add .add-tab").hide();
	$("#add ."+who).show();
	return false;
}

function showPopup(who,whotab) {
	$("body").addClass("hideselects");
	zindex++;
	$("#"+who).css("z-index",zindex);
	$("#"+who).show();
	if (whotab) {
		var whotab2 = whotab.replace(who,"tab");
		$("#"+who+" .card-tab").hide();
		$("#"+who+" ."+whotab).show();
		$("#"+who+" ul.tabs li").removeClass("active");
		$("#"+who+" ."+whotab2).addClass("active");
	}
	if ($(".card-foto").size() > 0) {m1SliderInit();}
	return false;
}
function hidePopup(who) {
	if ($("body").hasClass("hideselects")) {$("body").removeClass("hideselects");}
	$("#"+who).hide();
	return false;
}

function setWord(l, lf, r, rs) {
	document.getElementById(lf).value = l;
	document.getElementById(rs).value = r;
}

function showWinPopup(current) {
	$(current).parents(".markers").find(".window").hide();
	$(current).next().next(".window").show();
	return false;
}
function closeWinPopup(current) {
	$(current).parent().parent(".window").hide();
	return false;
}


$(document).ready(function(){
	initTable();
	if ($(".card-foto").size() > 0) {m1SliderInit();}
})