$(document).ready(function() {
	// === HOMEPAGE TOP BANNER ===
    $('#slide_block').cycle({
		fx:     'fade',
	    timeout: 4000,
	    next:   '#next_slide',
    	prev:   '#prev_slide'
	});
});


// ========= Recommended products slider =========
function mycarousel_initCallback(carousel) {
    jQuery('#mycarousel-next').bind('click', function() {
        carousel.next();
        return false;
    });
    jQuery('#mycarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};
jQuery(document).ready(function() {
    jQuery("#mycarousel").jcarousel({
        scroll: 4,
        initCallback: mycarousel_initCallback,
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
});


// ========= Special offers products slider =========
function mycarousel_initCallback2(carousel) {
    jQuery('#mycarousel-next2').bind('click', function() {
        carousel.next();
        return false;
    });
    jQuery('#mycarousel-prev2').bind('click', function() {
        carousel.prev();
        return false;
    });
};
jQuery(document).ready(function() {
    jQuery("#mycarousel2").jcarousel({
        scroll: 4,
        initCallback: mycarousel_initCallback2,
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
});


////////////////////////////////////////
function mycarousel_initCallbackv(carousel) {
    jQuery('#mycarousel-nextv').bind('click', function() {
        carousel.next();
        return false;
    });

    jQuery('#mycarousel-prevv').bind('click', function() {
        carousel.prev();
        return false;
    });
};

// Ride the carousel...
jQuery(document).ready(function() {
    jQuery("#mycarouselv").jcarousel({
        scroll: 1,
		vertical: true,
		auto: 4,
        wrap: "last",
        initCallback: mycarousel_initCallbackv,
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
});


// ========= Sells out products slider =========
function mycarousel_initCallback3(carousel) {
    jQuery('#mycarousel-next3').bind('click', function() {
        carousel.next();
        return false;
    });
    jQuery('#mycarousel-prev3').bind('click', function() {
        carousel.prev();
        return false;
    });
};
jQuery(document).ready(function() {
    jQuery("#mycarousel3").jcarousel({
        scroll: 4,
        initCallback: mycarousel_initCallback3,
        buttonNextHTML: null,
        buttonPrevHTML: null
    });
});

// ================== banner home bottom ================

jQuery(document).ready(function() {
    jQuery('#mycarousel-vertical').jcarousel({
        vertical: true,
        scroll: 1,
        auto: 4,
        wrap: "last"
    });
});


// === SITE ALERTS ===
$(document).ready(setFade);
function setFade(){
	if ($('.alert-block').css('display') == "block"){
		setTimeout('$(".alert-block").fadeOut(1000);',3000);
	}
}

function MM_goToURL() {
	var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
	for (i=0; i<(args.length-1); i+=2){
		eval(args[i]+".location='"+args[i+1]+"'");
	}
}

function addslashes(str) {
	str=str.replace(/\\/g,'\\\\');
	str=str.replace(/\'/g,'\\\'');
	str=str.replace(/\"/g,'\\"');
	str=str.replace(/\0/g,'\\0');
	return str;
}

$(document).ready(function() {
	// === FEEDBACK ===
	$("#feedback-link").click(function () {
		if($('.feedback').hasClass("close")) {
			$('.feedback').animate({left: "-662"}, "fast");
			$('.feedback').removeClass("close");
		}else{
    		$('.feedback').animate({left: "-1"}, "fast");
    		$('.feedback').addClass("close");
		}
    });
    $(".allcontainer").click(function () {
    	if($('.feedback').hasClass("close")) {
			$('.feedback').animate({left: "-662"}, "fast");
			$('.feedback').removeClass("close");
		}
    });
});

function open_window(link, width, height) {
	interactive_window = null;

	if(!width) {
		width=500;
	}
	if(!height) {
		height=500;
	}
	var left = (screen.width/2)-(width/2);
	var top = (screen.height/2)-(height/2);

	if(interactive_window) {
		if(false == interactive_window.closed) {
			interactive_window.close();
		}
	}
	interactive_window = window.open (link,"interactive_window","status=1,toolbar=0,width="+width+",height="+height+",top="+top+",left="+left);
}

$(document).ready(loadCartBox);
function loadCartBox(){
	$('#navc li').hover(
		function () {
			$('ul', this).slideDown(100);
		},
		function () {
			$('ul', this).slideUp(100);
		}
	);
}

$(document).ready(loadTooltips);
function loadTooltips(){
	$(function(){
		$('.north').tipsy({gravity: 'nw'});
	});
}



// === DETAILS PAGE BOTTOM SLIDER ===
$(function() {
    $('#main-photo-slider').cycle({
        fx:     'scrollDown',
        speed: 300,
        timeout: 5000,
        pager:  '#nav34',
        pagerAnchorBuilder: function(idx, slide) {
            // return sel string for existing anchor
            return '#nav34 li:eq(' + (idx) + ') a';
        }
    });
});

$(document).ready(function() {
	$('a.show-hide').click(function() {
		if ($(this).hasClass("down")){
			$(this).parents(".group-elem").find("p.hide_video_detalii.down").hide();
			$(this).parents(".group-elem").find(".video").show();
			$(this).parents(".group-elem").find("p.hide_video_detalii.up").show();

		}else if ($(this).hasClass("up")){
			$(this).parents(".group-elem").find("p.hide_video_detalii.up").hide();
			$(this).parents(".group-elem").find(".video").hide();
			$(this).parents(".group-elem").find("p.hide_video_detalii.down").show();
		}
		return false;
	});
});
