var open_hidden_block = 0;

$(document).ready(function(){

	var dHeight = $(document).height();
	$("#darkFon").css("height", dHeight+"px");
	setTimeout("bgFon()", 500);

	$(".openSubmenu").click(function(){
		$(".submenu").removeClass("showSubmenu");
		$(this).parent(".menuIteem").children(".submenu").addClass("showSubmenu");
	});
	$(".closeSubmenu").click(function(){
		$(this).parent(".submenu").removeClass("showSubmenu");
	});
	
	$("#closePopUp").click(function(){
		close_pop_up();
	});
	
	$("#darkFon").live("click", function(){
		close_pop_up();
	});
	
	function close_pop_up(){
		$('#popUpContainer').html('');
		$("#darkFon").hide();
		$("#popUp").hide();
		$("#popUp").css("top", "25px");
		dHeight = $(document).height();
		$("#darkFon").css("height", dHeight+"px");
		$("#popUp").css("margin-left", "-250px");
	}
	
	$(".showMap").live("click", function(){
		var show_in = $(window).scrollTop() + 20;
		$("#popUp").css("top", show_in+"px");
		bgFon();
		$('#popUpContainer').html('<div style="height: 320px;"><iframe src="'+hostJs+langJs+'/map/?shop_id='+$(this).attr('shop_id')+'" width="460" height="320" align="left" class="mapIframe"></iframe></div>');
		$("#darkFon").show();
		$("#popUp").show();		
	});
	
	$("#futer_prev_text").click(function(){
		if(open_hidden_block == 0){
			open_hidden_block = 1;
			$("#futer_text").slideToggle(500);
		}
		else if(open_hidden_block == 1){
			open_hidden_block = 0;
			$("#futer_text").slideToggle(500);
		}
	});
});

function orderCostume(){
	var show_in = $(window).scrollTop() + 20;
	$("#popUp").css("top", show_in+"px");
	bgFon();
	$('#popUpContainer').load(hostJs+langJs+'/ajax/?act=order_costume');
	$("#darkFon").show();
	$("#popUp").show();		
}

function openMap(){
	window.location = hostJs+langJs+'/network/';
}

function position_window(){
	var h1 = $(window).height();
	if(h1 > 800){
		hD = h1*0.1;
		$("#giperContainer").css("top", hD+"px");
	}
	
	$("#body").show();
}

function bgFon(){
	var dHeight = $(document).height();
	$("#darkFon").css("height", dHeight+"px");
}


function sendDataToServer(sendUrl, senData, callback){
	$.ajax({
	    type: "GET",
	    url: sendUrl,
	    data: senData,
	    success: function(msg){
			eval(callback);
	    }
	});
}

function loadMiniGalery(galeryId){
	sendDataToServer(hostJs+"ajax/", "act=loadGalary&galeryId="+galeryId, "insertGalery(msg, '"+galeryId+"')");
}

function insertGalery(msg, galeryId){
	if(msg != 1){
		$(".galeryNum"+galeryId).html(msg);
		setTimeout("hideArrows('"+galeryId+"')", 500);
	}
}

function loadFlvVideo(videoId){
	sendDataToServer(hostJs+"ajax/", "act=loadVideo&videoId="+videoId, "insertFlvVideo(msg, '"+videoId+"')");
}

function insertFlvVideo(msg, videoId){
	if(msg != 1){
		$(".flvVideo"+videoId).html(msg);
	}
}

function hideArrows(id){
	if($(".galeryNum"+id).children('.miniGalerySlyde').width() <= 780){
		$(".goLeft"+id).hide();
		$(".goRight"+id).hide();
	}
}
