﻿var m = 0;

$(document).ready(function() {
	$(".abzac").html('<div>'+$(".abzac").html()+'</div>');
	$(".menu td").mouseover(function() {
		if ($(this).attr("class").indexOf("activ")==-1) {
			$(this).css("background", "url(/images/bg_menu_over.png) repeat-x left top");
		}
	});
	$(".menu td").mouseout(function() {
		if ($(this).attr("class").indexOf("activ")==-1) {
			$(this).css("background", "url(/images/bg_menu.png) repeat-x left top");
		}
	});
	$(".menu td").mousedown(function() {
		if ($(this).attr("class").indexOf("activ")==-1) {
			$(this).css("background", "url(/images/bg_menu_activ.png) repeat-x left top");
		}
	});
	$(".menu td").mouseup(function() {
		if ($(this).attr("class").indexOf("activ")==-1) {
			$(this).css("background", "url(/images/bg_menu_over.png) repeat-x left top");
		}
	});
	
	
	
	$(".city").click(function() {
		$(this).attr("class", "city_activ");
		$(".sub_city").show();
	});
	
	$(".top_right, .div_lang, .ico, .logo, .main_menu").mouseover(function() {
		$(".sub_city").hide();
		$(".city_activ").attr("class", "city");
	});
	
	$("#sub_lang").click(function() {
		$(this).attr("class", "activ");
	});
	
	$("#all_raz, .main_menu, .div_top").mouseover(function() {
		$("#sub_lang").attr("class", "");
	});
	
	$("#all_raz").click(function() {
		$(".sub_menu").show()
	});
	
	$(".sub_menu .fl100 span, .sub_menu .fl100 em").click(function() {
		$(".sub_menu").hide()
	});
	
	$(".vote div").mouseover(function(){
		$(this).attr("class", "activ");
	});
	
	$(".vote div").mouseout(function(){
		$(this).attr("class", "");
	});
	
	$(".bottom_part img").mouseover(function(){
		$(this).attr("src", $(this).attr("color"));
	});
	$(".bottom_part img").mouseout(function(){
		$(this).attr("src", $(this).attr("black"));
	});
	
	var search = $("#searchInput").val();
	$("#searchInput").focus(function(){
        $(this).css("color", "black");
        if ($(this).val() == search) {
            $(this).val("");
        }
    }).blur(function(){
        if ($(this).val() == "") {
            $(this).css("color", "#969696");
            $(this).val(search);
        }
    });
	
	$('.main_center .fl h2, .text h1').gradientText({
        colors: ['#289828', '#73c14c']
    });
	
	auto_img = $(".auto").find("img");
	img = new Array();
	mov =  new Array();
	for (i=0;i<auto_img.length;i++) {
		if ($(auto_img[i]).attr("movie") == 1) {
			mov[mov.length] = $(auto_img[i]).attr("id");
		} else {
			img[i] = $(auto_img[i]).attr("id");
		}
	}
	
	last_img = img[(img.length-1)];
	setTimeout('$("#'+img[0]+'").show(); mor(1, "'+img+'")', 100);
	
	
	$(".auto div img").mouseover(function(){
		if (m == 0) {
			m = 1;
			setTimeout('$("#'+mov[0]+'").show(); changde_mov1(1, "'+mov+'")', 1550);
		}
	});
	$(".auto div div, .mt20, .main_center").mouseout(function(){
		m = 0;
	});
});

function mor(id, img_array) {
	img_array = img_array.split(",");
	if (img_array[id]!=undefined && img_array[id]!='') {
		setTimeout('$("#'+img_array[(id-1)]+'").hide(); $("#'+img_array[id]+'").show(); mor('+(id+1)+', "'+img_array+'")', 100);
	}
}

function changde_mov1(id, mov_array) {
	if (m == 1) {
		mov_array = mov_array.split(",");
		if (mov_array[id]==undefined || mov_array[id]=='') {
			id = 0;
		}
		if ($("#"+last_img).css("display") != "none")
			 $("#"+last_img).hide();
		 
		id < 0 ? l = last_img : l = (id-1);
		setTimeout('$("#'+mov_array[l]+'").hide(); $("#'+mov_array[id]+'").show(); changde_mov1('+(id+1)+', "'+mov_array+'")', 150);
	}
}

$(window).resize(function() {

});
