﻿$(document).ready(function(){
	
    initMainMenu();
    $('.service-item a').click(function(){
        var id = $(this).attr('id').replace('servicename', 'service');
        $('#'+id).toggle(300);
    });
    initHeights(".same_height", ".height_elem");
    initSearch();
    initCover();
    initSliderVisual();
    initTabsSliderTech();
	initTabsSliderTechDown();
    //initTabsSliderProc();
    initProcedureMainCover();
    initPopup();
    initContactsPopup();
    initTabs();
    initInnerTab();
    initContacts();
    initTabsRound();
    initCost();
	//moveLists();
    //initArrowSlide();
    //initButtonSlide();
    //initPhotos();
    
    swfobject.embedSWF("/images/swf/ohana.swf", "ohana_promo", "210", "170", "9.0.0", "", {}, {});
    slideDown();

	$(".banner_rotator").click(function(){
		window.location="/network_of_clinics/conference/";
	});
});

slideDown = function(){
	$(".slideDown").click(function(){
		$(this).next(".slideContent").slideToggle();
	});
}

// POP-UP
initPopup = function(){
    $("a.popup_inline").fancybox({
        'type'              : 'ajax',
        'titlePosition'		: 'inside',
        'transitionIn'		: 'none',
        'transitionOut'		: 'none'
    });
    $("a.fancy_photo").fancybox({
        'titlePosition'		: 'inside'
    });
}

// MAIN MENU
initMainMenu = function(){
    var td_width = ["0px", "10%", "3px", "15%", "3px", "9%", "3px", "9%", "3px", "13%", "3px", "9%", "3px", "14%", "3px", "10%","3px","10%"];
    var ul_width = [];
    var ul_height = [];
    
    $("#main_menu td").each(function(i){
        $(this).width(td_width[i]);
    });
    $("#main_menu td:last").addClass("last");
    $("#main_menu td .submenu_wrap ul").each(function(i){
        ul_width[i] = $(this).width();
        ul_height[i] = $(this).innerHeight();
        if ($.browser.msie) {
            $(this).find("li:last div.dash").css("background", "none");
        }
    });
    if ($.browser.opera) {
        ul_width = ["270", "246", "266", "255", "157", "205"]
    }

    var menu_elem = $("#main_menu div.sub_div");
    menu_elem.mouseover(function(){
        var ind = $("#main_menu div.sub_div").index(this);
        $(this).find("div.submenu_wrap").width(ul_width[ind]).stop().animate({height:ul_height[ind]}, {duration: 150}, 150);
        $(this).find("div.s_left").show();
        $(this).find("div.s_right").show();
    });
    menu_elem.mouseout(function(){
        $(this).find("div.submenu_wrap").stop().animate({height: "0px"}, {duration: 150}, 150);
        $(this).find("div.s_left").hide();
        $(this).find("div.s_right").hide();
    });
}

// 4 MAIN PAGE BLOCKS
initHeights = function(elem, elem_inner){
    var heights = [];
    var max = [];
	$(elem).each(function(j){
        heights[j] = [];
        $(this).find(elem_inner).each(function(i){
            heights[j].push($(this).height());
        });
        max[j] = Math.max.apply(Math, heights[j]);
        $(this).find(elem_inner).height(max[j]);
    });
    // + laennek banner
    //initVisualAnim = function(){
        animatedBlock = $("#content div.main_article div.right_main_photo");
        images = [
            "/images/laennek.jpg",
            "/images/woman.jpg"
        ];
        var i = 0;
        var image = animatedBlock.find("img");
        count = images.length;
        
        showSlide = function(){
            image.attr("src", images[i]);
            image.css({
                "position": "relative",
                "opacity": 0,
                "z-index": 5
            });
            image.stop().animate({"opacity":1}, 1200);       
            i++;
            if (i > count - 1) i = 0;
        }
        
        showSlide(1);
        var show = setInterval(showSlide, 6000);
		
		
		
		animatedBlock2 = $("div#spec_info_inner div.#event-500 div.wrap");
        images2 = [
            "/images/act_september1.jpg",
            "/images/act_september2.jpg",
			"/images/act_september3.jpg",
            "/images/act_september4.jpg",
        ];
        var i2 = 0;
        var image2 = animatedBlock2.find("img");
        count2 = images2.length;

        showSlide2 = function(){
            image2.attr("src", images2[i2]);
            image2.css({
                "position": "relative",
                "opacity": 0,
                "z-index": 5
            });
            image2.stop().animate({"opacity":1}, 3000);       
            i2++;
            if (i2 > count2 - 1) i2 = 0;
        }
        
        showSlide2(1);
		
		animatedBlock3 = $("div#spec_info_inner div.#event-611");
        images3 = [
            "/images/exilis_t.jpg",
            "/images/exilis.jpg",
        ];
		href3 = [
            "/technology/exilis/",
            "/technology/exilis_lico/",
        ];
        var i3 = 0;
        var image3 = animatedBlock3.find("img");
        var link3 = animatedBlock3.find("a");
        count3 = images3.length;

        showSlide3 = function(){
            image3.attr("src", images3[i3]);
            link3.attr("href", href3[i3]);
            image3.css({
                "position": "relative",
                //"opacity": 0,
                "z-index": 5
            });
            //image3.stop().animate({"opacity":1}, 3000);       
            i3++;
            if (i3 > count3 - 1) i3 = 0;
        }
        
        showSlide3(1);
        var show3 = setInterval(showSlide3, 5000);
		
		
		
		
		animatedBlock4 = $("#exilis_anim");
		images4 = [
            "/images/exilis_r1.jpg",
            "/images/exilis_r2.jpg",
        ];
		href4 = [
            "/technology/exilis/",
            "/technology/exilis_lico/",
        ];
		text4 = [
            "Подробнее тело",
            "Подробнее лицо",
        ];
        var i4 = 0;
        var link4 = animatedBlock4.find("a");
        count4 = 2;

        showSlide4 = function(){
            animatedBlock4.css("background", "#4682c1 url('" + images4[i4] + "') center center no-repeat");
            link4.attr("href", href4[i4]);
            link4.html(text4[i4]);  
            i4++;
            if (i4 > (count4 - 1)) i4 = 0;
        }
        
        showSlide4(1);
        var show4 = setInterval(showSlide4, 5000);
		
		
		
		
    //} // BNR
}

/* Search */
initSearch = function(){
	$("#search_block input.text").focus(function(){
		if ( $(this).attr("title") == $(this).attr("value") ){
			$(this).attr({"value": ""});
		}
	});
	$("#search_block input.text").blur(function(){
		 if ( !$(this).attr("value")){
			var defText = $(this).attr("title");
			$(this).attr({"value": defText});
			}
	});
	$("#search_block input.button").click(function(){
		if ( $("#search_block input.text").attr("title") == $("#search_block input.text").attr("value") ){
			return false;
		}
	});
}

/* Cover */
initCover = function(){
    $(".cover_content").hide();
    $(".cover_content.active").show();
    $(".cover .link").click(function(){
        if ($(this).parent().hasClass("active")) {
			$(".cover_content").hide(450);
		} else {
			var i = $(".cover .link").index(this);
			$(".cover h2").removeClass("active");
			$("ul.cover li").removeClass("active");
			$("div.cover div").removeClass("active");
			$(".title").removeClass("active");
			$(this).parent().addClass("active");
			$(".cover_content").hide(450);
			$(".cover_content").eq(i).toggle(450);
		}
    });
    
    $("div.more_text").hide();
    $(".link_block a.more").click(function(){
        $(this).parents("div.link_item").find("div.more_text").slideToggle(450);
        return false;
    });
}

// Slider (  NEWS )
initSliderVisual = function(){
	var startPos = 0,
		frameCount = 1,
		slideStep = 1,
		i = 0,
		animateTime = 600,
		elemWidth = 261;
    var move = true;
	var too = 1;
	
	var slideBlock = $("#event_elem_wrap");
    var slideElem = slideBlock.find("div.event_elem");
    var arrowLeft = $("#spec_info .left");
    var arrowRight = $("#spec_info .right");
    
	
	/* КОСТЫЛЬ */
	//if (slideElem.attr("id") == 'event-611'){
	/*if (i == '0'){
		var intrval = 10000;
	}else{
		var intrval = 5000;
	}*/
	/* /КОСТЫЛЬ */
	
	
    if (slideElem.size() == 0){
        arrowLeft.hide();
        arrowRight.hide();
    }
    
    slideBlock.width(elemWidth*(slideElem.size()));
    
    if (slideElem.size() <= frameCount) {
        arrowRight.hide();
        arrowLeft.hide();
    }
    
    arrowRight.click(function(){
    if (move){
        move = false;
        if (!$(this).hasClass("na_right")){
            i++;
            slideBlock.animate({"left":"-"+slideStep*elemWidth*i+"px"}, animateTime, function(){
                if (elemWidth*(slideElem.size()) + parseInt(slideBlock.css("left")) == frameCount*elemWidth) arrowRight.addClass("na_right");
                if (parseInt(slideBlock.css("left")) < 0) arrowLeft.removeClass("na_left");
                move = true;
            });
        }
        
    }
    return false;
    });
    arrowLeft.click(function(){
    if (move){
        move = false;
        if (!$(this).hasClass("na_left")){
            i--;
            slideBlock.animate({"left":"-"+slideStep*elemWidth*i+"px"}, animateTime, function(){
                if (parseInt(slideBlock.css("left")) == 0) arrowLeft.addClass("na_left");
                if (elemWidth*(slideElem.size()) + parseInt(slideBlock.css("left")) > frameCount*elemWidth) arrowRight.removeClass("na_right");
                move = true;
            });
        }
    }
    return false;
    });
	
	setTimeout(function(){
		var intrval = 5000;
		setInterval(function(){
			if (move){
					move = false;
					if ($(arrowLeft).hasClass("na_left")){
						too = 1;
					}
					
					if (!$(arrowRight).hasClass("na_right") && too == 1){
						i++;
						slideBlock.animate({"left":"-"+slideStep*elemWidth*i+"px"}, animateTime, function(){
							if (elemWidth*(slideElem.size()) + parseInt(slideBlock.css("left")) == frameCount*elemWidth) arrowRight.addClass("na_right");
							if (parseInt(slideBlock.css("left")) < 0) arrowLeft.removeClass("na_left");
							move = true;
						});
					} else if (!$(arrowLeft).hasClass("na_left")){
						too = 0;
						i--;
						slideBlock.animate({"left":"-"+slideStep*elemWidth*i+"px"}, animateTime, function(){
							if (parseInt(slideBlock.css("left")) == 0) arrowLeft.addClass("na_left");
							if (elemWidth*(slideElem.size()) + parseInt(slideBlock.css("left")) > frameCount*elemWidth) arrowRight.removeClass("na_right");
							move = true;
						});
					} 
				}
				return too;
		}, intrval);
	}, 5000);
	
}


// Tabs ( MAIN SLIDER)
initTabs = function(){
    $("#service_block_tabs a").click(function(){
        var i = $("#service_block_tabs a").index(this);
        if (i == 1){
            $("#service_block .shadow").hide();
            $("#service_block .arrow").hide();
        }
        else{
            $("#service_block .arrow").show();
            $("#service_block .shadow").show();
        }
        $("div.service_block_tab_content").removeClass("active");
        $("div.service_block_tab_content").eq(i).addClass("active");
        $("#service_block_tabs li").removeClass("active");
        $("#service_block_tabs li").eq(i).addClass("active");
        return false;
    })
    $("#service_block_tabs li").click(function(){
        $(this).find("a").click();
    });
    // ANIMATION
    anim_elem = $("#service_block_tabs li").eq(animted_tab);
    loadingTimer = null;
    timer = null;
    pos = 0;
    moveTabBg = function(){
        var stopMove = false;
        flashAnimate = function(){
            if (stopMove){
                clearInterval(loadingTimer);
                return;
            }
            if (pos<=-148) {
                pos = 0
                stopMove = true;
            }
            anim_elem.css({'background-position':'left ' + pos + 'px'});
            pos -= 37;
        };
        loadingTimer = setInterval("flashAnimate()", 120);
    }
    timer = setInterval("moveTabBg()", 2000);
}   

// TODO переделать на объекты (prototype?), с созданием копий объектов
initArrowSlide = function() {
    anim_elems_left = $('a.left');
    loadingTimer_left = null;
    timer_left = null;
    pos_left = 0;
    moveTabBg_left = function() {
        var stopMove_left = false;
        flashAnimate_left = function(){
            if (stopMove_left){
                clearInterval(loadingTimer_left);
                return;
            }
            if (pos_left<=-184) {
                pos_left = 0
                stopMove_left = true;
            }
            anim_elems_left.css({'background-position':'left ' + pos_left + 'px'});
            pos_left -= 46;
        };
        loadingTimer_left = setInterval("flashAnimate_left()", 120);
    }
    timer_left = setInterval("moveTabBg_left()", 2000);

    anim_elems_right = $('a.right');
    loadingTimer_right = null;
    timer_right = null;
    pos_right = 0;
    moveTabBg_right = function() {
        var stopMove_right = false;
        flashAnimate_right = function(){
            if (stopMove_right){
                clearInterval(loadingTimer_right);
                return;
            }
            if (pos_right<=-184) {
                pos_right = 0
                stopMove_right = true;
            }
            anim_elems_right.css({'background-position':'right ' + pos_right + 'px'});
            pos_right -= 46;
        };
        loadingTimer_right = setInterval("flashAnimate_right()", 120);
    }
    timer_right = setInterval("moveTabBg_right()", 2000);
}

initButtonSlide = function() {
    anim_elems_btn = $('a.more_slide');
    loadingTimer_btn = null;
    timer_btn = null;
    pos_btn = 0;
    moveTabBg_btn = function() {
        var stopMove_btn = false;
        flashAnimate_btn = function(){
            if (stopMove_btn){
                clearInterval(loadingTimer_btn);
                return;
            }
            if (pos_btn<=-100) {
                pos_btn = 0
                stopMove_btn = true;
            }
            anim_elems_btn.css({'background-position':'left ' + pos_btn + 'px'});
            pos_btn -= 25;
        };
        loadingTimer_btn = setInterval("flashAnimate_btn()", 120);
    }
    timer_btn = setInterval("moveTabBg_btn()", 2000);
}

var timer = null;
var timeRun = 1;
initTabsSliderTech = function() {
    var block_width = [];  // Ширина блоков в ленте прокрутки
    var line_width = 0,    // Ширина ленты прокрутки
        slider_pos = 0;    // Начальная позиция ленты
        var dx = 2;
    // Ширина видимой области слайдера
    var frame_width = $("#service_block_wrap").innerWidth();
    // Вычисляем ширину ленты прокрутки
    $("#technology_block div.slide_block").each(function(i){
        var count = $(this).find("ul li").size();
        block_width[i] = count*181 + 50;    // 50 - paddings
        line_width = line_width + block_width[i];
    });
    $('#service_block .left').mouseover(
        function(){
            clearInterval(timer);
            timer = setInterval(movePosXprev, timeRun);
        }
    );
    $('#service_block .right').mouseover(function(){ 
        clearInterval(timer); 
		timer = setInterval(movePosXnext, timeRun); 
    });
    $('#service_block .left, #service_block .right').mouseout(function(){
        clearInterval(timer);
    });
	// Создаем бесконечную ленту
	first_clone = $("#technology_block div.slide_block:first").clone();
	last_clone = $("#technology_block div.slide_block:last").clone();
	last_clone.insertBefore("#technology_block div.slide_block:first");
	first_clone.insertAfter("#technology_block div.slide_block:last");
	// Устанавливаем свойства ленты прокрутки
	line_width = line_width*2;
	var index = 1;
	$("#technology_block").css({
		width	: line_width,
		left	: -block_width[index]
	});
    // SLIDE LEFT | RIGHT
    movePosXprev = function(){
		slider_pos = parseInt($("#technology_block").css("left"));
		
        if (slider_pos >= 0){
			if (index == 0) index = 2;
			index--;
			// Если лента в начальной позиции, копируем последний элемент перед первым
            $("#technology_block div.slide_block:last").clone().insertBefore("#technology_block div.slide_block:first");
			$("#technology_block div.slide_block:last").remove();
			slider_pos = -block_width[index];
            $("#technology_block").css({
                left    : slider_pos             // переопределяем начальное положение ленты
            });
        }
		slider_pos = slider_pos + dx
        $("#technology_block").css("left", slider_pos);
    }
    movePosXnext = function(){
		slider_pos = parseInt($("#technology_block").css("left"));
        if (slider_pos <= frame_width - line_width){
			// Если лента в конечной позиции, копируем первый элемент после последнего
            $("#technology_block div.slide_block:first").clone().insertAfter("#technology_block div.slide_block:last");
			$("#technology_block div.slide_block:first").remove();
			slider_pos = frame_width - line_width + block_width[index];
            $("#technology_block").css({
                left    : slider_pos              // переопределяем начальное положение ленты
            });
			if (index == 1) index = -1;
			index++;
        }
		slider_pos = slider_pos - dx;
        $("#technology_block").css("left", slider_pos);
    }
}

var timer_d = null;
var timeRun_d = 1;
initTabsSliderTechDown = function() {
	var block_width = [];
	var line_width = 0;
	var start_width_block = 465;
	var start_width_line = 1428;
	var frame_width = $(".service_block_wrap_down").innerWidth();
	var dx = 2;
	line_width = start_width_line - (frame_width - start_width_block);
	//alert(line_width);
	
	//1428  465
	//1300  593
	//1264  634
	//1154  750
	
	$('#service_block_down .left').hide();
	
	/*$(".technology_block_down div.slide_block").eq(1).each(function(i){
        var count = $(this).find("ul li").size();
        block_width[i] = count*150-50;
        line_width = line_width + block_width[i];
    });*/
	
	$('#service_block_down .left').mouseover(
        function(){
            clearInterval(timer_d);
            timer_d = setInterval(movePosXprev_d, timeRun_d);
        }
    );
    $('#service_block_down .right').mouseover(function(){ 
        clearInterval(timer_d); 
		timer_d = setInterval(movePosXnext_d, timeRun_d); 
    });
    $('#service_block_down .left, #service_block_down .right').mouseout(function(){
        clearInterval(timer_d);
    });
	 $('#service_block_down .left, #service_block_down .right').click(function(){
        return false;
    });
	movePosXnext_d = function(){
		$('#service_block_down .left').show();
		slider_pos = parseInt($(".technology_block_down").css("left"));
		slider_pos = slider_pos - dx;
		if (slider_pos+line_width < 0){
			$('#service_block_down .right').hide();
			clearInterval(timer_d);
        }
        $(".technology_block_down").css("left", slider_pos);
    }
	movePosXprev_d = function(){
		$('#service_block_down .right').show();
		slider_pos = parseInt($(".technology_block_down").css("left"));
		slider_pos = slider_pos + dx;
		if (slider_pos > 0){
			$('#service_block_down .left').hide();
			clearInterval(timer_d);
        }
        $(".technology_block_down").css("left", slider_pos);
    }
}

initProcedureMainCover = function(){
    var li_elem = $("#procedure_block div.slide_block ul li ul li");
    li_elem.each(function(){
        var count_inner = $(this).find("li").size();
        if (count_inner > 0){
            $(this).addClass("clickable");
            $(this).find("ul").hide();
            $(this).find("a").click(function(){
                $("#procedure_block div.slide_block ul li.clickable ul").hide();
                $(this).parents("li.clickable").find("ul").show();
                return false;
            });
            $(this).find("ul li a").click(function(){
                window.location = $(this).attr("href");
            });
        }
    });
}

initContactsPopup = function(){
    $("#header_inner ul.contacts li a.show_pop").click(function(e){
        $("#header_inner ul.contacts li div.full_contacts").hide();
        var XCoord = parseInt($(this).offset().left - $("#main").offset().left - 60);
        //var YCoord = parseInt($("#main").offset().top);
        $(this).parents("li").find(".full_contacts").css({"left": XCoord, "top": 0}).show();
        return false;
    });
    $("#header_inner ul.contacts li a.close_pop").click(function(e){
        $("#header_inner ul.contacts li div.full_contacts").hide();
        return false;
    });
}

initInnerTab = function(){

    var is_open = false;
    
    $("#slide_down a.toggle_slider").click(function(){
        var index = $("#slide_down a.toggle_slider").index($(this));
        $("#slide_down #service_block_content .service_block_tab_content").hide();
        $("#slide_down #service_block_content .service_block_tab_content").eq(index).show();
        $("#slide_down a.toggle_slider_arr").addClass("active");
        if (index == 1){
            $("#service_block").addClass("gray");
        }else{$("#service_block").removeClass("gray");}
        is_open = true;
        return false;
    });
    
    $("#slide_down a.toggle_slider_arr").click(function(){
        if (is_open) {
            $("#slide_down a.toggle_slider").parent("li").removeClass("active");
            $("#slide_down a.toggle_slider_arr").toggleClass("active");
            $("#slide_down #service_block_content .service_block_tab_content").slideUp(600);
            $("#slide_down div.shadow, #slide_down a.arrow").hide();
            $("#service_block").removeClass("gray");
            is_open = false;
        }else{
            $("#slide_down a.toggle_slider").eq(0).parent("li").toggleClass("active");
            $("#slide_down a.toggle_slider_arr").toggleClass("active");
            $("#slide_down #service_block_content .service_block_tab_content").eq(0).slideToggle(600);
            $("#slide_down div.shadow, #slide_down a.arrow").toggle();
            is_open = true;
        }
        
        return false;
    });
}

initContacts = function(){
    $("dl.contacts dt").hover(function(){
        $(this).toggleClass("active");
    });
    $("dl.contacts dd").hover(function(){
        var i = $("dl.contacts dd").index(this);
        $("dl.contacts dt").eq(i).addClass("active");
    }, function(){
        var i = $("dl.contacts dd").index(this);
        $("dl.contacts dt").removeClass("active");
    });
}

initTabsRound = function(){
    $("div.tab_contnet div.tab_text").hide();
    
    $("div.tab_contnet ul.tabs_round li").each(function(i){
        if ($(this).hasClass("active")){
            $("div.tab_contnet").find("div.tab_text").eq(i).show();
        }
    });
    
    $("div.tab_contnet ul.tabs_round li").click(function(){
        var index = $("div.tab_contnet ul.tabs_round li").index(this);
        
        $("div.tab_contnet ul.tabs_round li").removeClass("active");
        $(this).addClass("active");
        
        $("div.tab_contnet div.tab_text").hide();
        $("div.tab_contnet").find("div.tab_text").eq(index).show();
    });
}

initCost = function(){
    $("#cost_page tr.na").hover(function(){
        $(this).toggleClass("na");
    });
    $("#cost_page tr").click(function(){
        if ($(this).find("a").size() > 0){
            var href = $(this).find("a").attr("href");
            if (href != "")
                window.location = href;
        }
    });
}

initPhotos = function(){
    var c_pos = 0; // Current position
    var curr = 0; // Current index
    var total = $("#photo_slider li").length; // Total count
    // Click img
    var imgs = [];
    for (j = 0; j < total; j++){
        imgs[j] = $("a.thumb_photo").eq(j).attr("href");
        $("#photo_slider div.big_photo").append('<img src="'+imgs[j]+'" style="display:none"/>');
    }
    // Click img
    $("#photo_slider li").click(function(){
        var src = $(this).find("a.thumb_photo").attr("href");
        $("#photo_slider div.big_photo img.image_back").attr("src", src);
        $("#photo_slider div.big_photo img.image").stop().animate({"opacity":0}, 400, function(){
            $(this).attr("src", src).animate({"opacity":1}, 400);
        });
        $("#description_gallery_file").html('<p>' + $(this).find('img').attr('alt') + '</p>');
        $("#photo_slider ul li").removeClass("active");
        $(this).addClass("active");
        curr = $("#photo_slider li").index(this);
        
        if (curr == 0) {
            $("#photo_slider a.left").addClass("na");
            $("#photo_slider a.right").removeClass("na");
        }
        else if (curr == total - 1){
            $("#photo_slider a.right").addClass("na");
            $("#photo_slider a.left").removeClass("na");
        }
        else{
            $("#photo_slider a.left, #photo_slider a.right").removeClass("na");
        }
        
        return false;
    });
    // Slider
    $(".photos").css("overflow","hidden");
	var w = 140*($(".photos ul li").length);
	$(".photos ul").width(w);
	$(".photos ul").width()
    initSliderH = function(){
		var frame_elem = $(".photos ul");
		var elem_size = 140;
		var elem_count = $(".photos ul li").size();
		var start_pos = 0, frame_count = 3;
		var frame_actions = elem_count - frame_count;
		var cRight = frame_actions, cLeft = 0;
		var frame_elem_size = elem_size*elem_count;
		var slider_width = $("#photos_slide").width();
		var slider_scale = (elem_size*elem_count)/slider_width;
		$("#photos_slide").slider({
			orientation: "horizontal",
			range: "min",
			min: 0,
			max: frame_actions*elem_size,
			slide: function(event, ui) {
				slide_pos = (-1)*ui.value;
				frame_elem.css("left", slide_pos);
			}
		});
	}
	initSliderH();
    // Arrows
    $("#photo_slider a.left").click(function(){
        $("#photo_slider a.right").removeClass("na");
        $(this).removeClass("na");
        curr--;
        $("#photo_slider li").eq(curr).click();
        slide_preview();
        
        return false;
    });
    $("#photo_slider a.right").click(function(){
        $("#photo_slider a.left").removeClass("na");
        $(this).removeClass("na");
        curr++;
        $("#photo_slider li").eq(curr).click();
        slide_preview();
        
        return false;
    });
    slide_preview = function(){
        if (curr < total - 2){
            c_pos = -140*curr;
            $(".photos ul").animate({"left": c_pos}, 400);
            $("#photos_slide").slider({
                value: -c_pos
            });
        }
    }
}

/*moveLists = function(){
	$('#list1').pan({fps: 30, speed: 0.1, dir: 'down', depth: 30});
	$('#list2').pan({fps: 30, speed: 0.1, dir: 'down', depth: 50});
	$('#girl').pan({fps: 30, speed: 0.1, dir: 'down', depth: 70});
	$('#list3').pan({fps: 30, speed: 0.1, dir: 'down', depth: 90});
	$('#list1, #list2, #list3').spRelSpeed(3);
	$('#girl').spStop();
	
	var w = $('div#girl').width()/2-184;

	$('div#girl').parallax({
	  'elements': [
		{
		  'selector': 'div#girl',
		  'properties': {
			'x': {
			  'background-position-x': {
				'initial': w,
				'multiplier': 0.1,
			  }
			}
		  }
		}
	  ]
	});	
}*/

