//home page swipe
$(window).load(function () {
    $(".transparent_bg_home").css("width", ($(window).width()));
    $(".transparent_bg_home").css("height", ($(document).height()));
    $(".transparent_right").css("height", ($(document).height()));
    // $(".transparent_bg_home").css("width", ($(window).height() - div.height())/2  + 'px');
    //$(".top_left_links ul li:nth-child(1) a").css("padding-left", 0);
    //$(".top_left_links ul li a").first().css("padding-left", 0);
    //mCustomScrollbars();
});

$(window).resize(function () {
		$('.transparent_bg_home').width($(window).width());
		$('.transparent_bg_home').height($(window).height());
		$('.transparent_right').height($(window).height());
});

$(document).ready(function () {
    //$("a[rel^='prettyPhoto']").prettyPhoto({ theme: 'facebook' });
    //$(".product_sections:nth-child(4n)").after('<div class="cl"></div>');
    $(".inner_products_area .product_sections_sml:nth-child(6n)").append('<div class="cl"></div>');
    //home page swipe
    //$(".more_sidebar a").click(function () {
    //       $(".transparent_bg_home").animate({ left: -($(window).width()) + 'px' }, 2000);
    //	   $(".more_sidebar .closeDiv").fadeIn(1000);
    //    });


    $(".more_sidebar a").toggle(function () {
        $(".transparent_bg_home").animate({ left: -($(window).width()) + 'px' }, 2000);
        $(".more_sidebar .closeDiv").fadeIn(1000);
    }, function () {
        $(".transparent_bg_home").animate({ left: 0 }, 500);
        $(".more_sidebar .closeDiv").fadeOut(1000);
    });

    $(".more_sidebar .closeDiv").click(function () {
        $(".transparent_bg_home").animate({ left: 0 }, 500);
        $(".more_sidebar .closeDiv").fadeOut(1000);
    });

    $(document).mouseup(function () {
        $(".transparent_bg_home").animate({ left: 0 }, 500);
        $(".more_sidebar .closeDiv").fadeOut(1000);
    });

    $("a[rel^='fancyBox_iframe']").fancybox({
        'modal': true,
        'transitionIn': 'fade',
        'transitionOut': 'none',
        'width': 875,
        'height': 460,
        'padding': 0,
        'showNavArrows': false,
        'type': 'iframe'
    });

    $("a[rel^='fancyBox_press']").fancybox({
        //'modal'			: true,
        'overlayColor ': '#000000',
        'hideOnOverlayClick': false,
        'transitionIn': 'fade',
        'transitionOut': 'none',
        'width': 875,
        'height': 460,
        'padding': 0,
        'showNavArrows': false,
        'showCloseButton': false
    });

    $("a[rel^='fancyBox_addtocart']").fancybox({
        'opacity': true,
        'overlayShow': false,
        'transitionIn': 'elastic',
        'transitionOut': 'none',
        'width': 430,
        'height': 170,
        'showNavArrows': false,
        'type': 'iframe'
    });

    // design gallery popup
    $("a[rel^='fancyBox_product_main']").fancybox({
        'opacity': true,
        'overlayShow': false,
        'width': 880,
        'height': 470,
        'padding': 0,
        'showNavArrows': false
    });

    // design gallery popup product
    $("a[rel^='fancyBox_design_gallery_product']").fancybox({
        //'modal'			: true,
        'overlayColor ': '#000000',
        'hideOnOverlayClick': false,
        'transitionIn': 'fade',
        'transitionOut': 'none',
        'width': 875,
        'height': 460,
        'padding': 0,
        'showNavArrows': false,
        'showCloseButton': false
    });

    $("a[rel^='fancyBox_normal']").fancybox({
		//'centerOnScroll' : true,
        'showNavArrows': false
    });
	
	$("a[rel^='fancyBox_ajax']").fancybox({
		ajax : {
		    type	: "POST",
		    data	: 'mydata=test'
		}
    });

    //home main banner rotate function
    $('.home_banner').cycle({
        delay: 1000, speed: 1000
    });
	
	 //home left banner rotate function
    $('.image_fadding').cycle({
		fx: 'fade',
        delay: 1000,
		speed: 1000,
		slideExpr: 'img'
    });

    $('.slideshow_store').cycle({
        fx: 'fade',
        //prev:   '#prev',
        //next:   '#next',
        //easing: 'easeInOutQuad',
        //nowrap:  1,
        speed: 1000,
        slideExpr: '.shopslidingimage',
        pager: '#nav'
        //continuous: 0
        //timeout: 0
    });

    $('.sliding_press_popup').cycle({
        fx: 'scrollHorz',
        prev: '.prev_arrow',
        next: '.nxt_arrow',
        //easing: 'easeInOutQuad',
        //nowrap:  1,
        speed: 1000,
        slideExpr: 'img'
        //pager: '#nav'
        //continuous: 0
        //timeout: 0
    });



    //pop up login BTN
    $(".popup_login_btn").click(function (e) {
        e.preventDefault();
        $(".login_section").fadeIn();
    });

    $(".login_section").mouseup(function () {
        return false
    });
    $(document).mouseup(function (e) {
        if ($(e.target).parent(".popup_login_btn").length == 0) {
            $(".login_section").hide();
        }
    });
    $(".login_section .close_btn").click(function () {
        //$(".about_popup").animate({ opacity: 0 }, "slow");
        $('.login_section').hide();
    });

    $(".login_section .close_btn_common").click(function () {
        //$(".about_popup").animate({ opacity: 0 }, "slow");
        $('.login_section').hide();
    });


    $(".login_top_btn").click(function (e) {
        e.preventDefault();
        $(".login_section").fadeIn();
    });

    $(".login_section").mouseup(function () {
        return false
    });
    $(document).mouseup(function (e) {
        if ($(e.target).parent(".login_top_btn").length == 0) {
            $(".login_section").hide();
        }
    });
    $(".login_section .close_btn").click(function () {
        //$(".about_popup").animate({ opacity: 0 }, "slow");
        $('.login_section').hide();
    });

    // email to friend popup
    $(".emailfriend_link").click(function () {
        $(".login_popup_press").fadeOut("fast");
        $(".email_friend_popup").fadeIn("slow");
        //$('.email_friend_popup').css({ visibility: "visible" }, "slow");
    });

    $(".email_friend_popup .close_btn").click(function () {
        $(".email_friend_popup").fadeOut("fast");
        //$('.email_friend_popup').css({ visibility: "hidden" }, "slow");
    });

    // Login popup in press page
    $(".loginpopup_link").click(function () {
        $(".email_friend_popup").fadeOut("fast");
        $(".login_popup_press").fadeIn("slow");
        //$('.email_friend_popup').css({ visibility: "visible" }, "slow");
    });

    $(".login_popup_press .close_btn").click(function () {
        $(".login_popup_press").fadeOut("fast");
        //$('.email_friend_popup').css({ visibility: "hidden" }, "slow");
    });

    // footer about popup
    $(".about_popup_btn").click(function () {
        //$(".about_popup").animate({ opacity: 1 }, "slow");
        //$('.about_popup').css({ opacity: 1, visibility: "visible" }, "slow");
        $('.about_popup').css({ visibility: "visible" }, "slow");
    });

    $(".about_popup .close_btn").click(function () {
        //$(".about_popup").animate({ opacity: 0 }, "slow");
        //$('.about_popup').css({ opacity: 0, visibility: "hidden" }, "slow");
        $('.about_popup').css({ visibility: "hidden" }, "slow");
    });

    $(".myaccount_menu").hover(function () {
        $('.myaccount_menu ul').fadeIn("slow");
        $('.myaccount_menu a').addClass("selected");
    }, function () {
        $('.myaccount_menu ul').fadeOut("fast");
        $('.myaccount_menu a').removeClass("selected");
    });

    //equal height function
    //equalHeight($(".product_page_height"));

    //Gallery Tab Function
    //Default Action
    $(".tab_content").hide(); //Hide all content
    $(".overview li:first").addClass("active").show(); //Activate first tab
    $(".tab_content:first").show("fast"); //Show first tab content

    //On Click Event
    $(".overview1 li").click(function () {
        $(".overview li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $(".tab_content").hide(); //Hide all tab content
        var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active content
        return false;
    });

    //accordation function with cookies store
    var checkCookie = $.cookie("nav-item");
    if (checkCookie != "") {
        $('.nav > li > a:eq(' + checkCookie + ')').addClass('active').next().show();
    }
    $('.nav > li > a').click(function () {
        var navIndex = $('.nav > li > a').index(this);
        $.cookie("nav-item", navIndex);
        $('.nav li ul').slideUp();
        if ($(this).next().is(":visible")) {
            $(this).next().slideUp();
        } else {
            $(this).next().slideToggle();
        }
        $('.nav li a').removeClass('active');
        $(this).addClass('active');
    });

    //Tiny Slider 1
    $('#slider1').tinycarousel({
        //pager: true,
        //animation: true,
        display: 1
    });

    //Tiny Slider 2
    $('#slider_product_main').tinycarousel({
        //pager: true,
        //animation: true,
        display: 1
    });

    //Tiny Slider 3
    $('#slider2').tinycarousel({
        //pager: true,
        //animation: true,
        display: 1
    });

    //Tiny Slider 4
    $('#slider3').tinycarousel({
        //pager: true,
        //animation: true,
        display: 1
    });

    //Tiny Slider 5
    $('#slider4').tinycarousel({
        //pager: true,
        //animation: true,
        display: 1
    });

    //Tiny Slider 6
    $('#marketing_template_slider').tinycarousel({
        //pager: true,
        //animation: true,
        display: 1
    });


    //Scrollbar
    $('.scrolling_content').scrollbar({
        //handleHeight:50,
        arrows: false
    });

    //jCarousel Slider
    //$('#mycarousel').jcarousel({
    //    visible: 4,
    //    scroll: 2
    //});



});
/*   End jquery Function  */


$(function () {

    //  jquery corner function
    $(".grey_btn, .grey_btn2").hover(function () {
        $(this).addClass("grey_btn_over");
    }, function () {
        $(this).removeClass("grey_btn_over");
    });

    $(".link").hover(function () {
        $(this).css({ opacity: 0.8 });
    }, function () {
        $(this).css({ opacity: 1 });
    });

    $('.grey_btn').wrap('<div class="grey_btn_outer"></div>');
    $('.grey_btn').corner("round 5px").parent().corner("round 6px");
    $('.grey_btn2.left').wrap('<div class="grey_btn_outer fl"></div>');
    $('.grey_btn2.right').wrap('<div class="grey_btn_outer fr"></div>');
    $('.grey_btn2').corner("round 5px").parent().corner("round 6px");

    $('.grey_btn.big').corner("round 5px").parent().corner("round 6px");
    $('.customizer_step a').corner("round 5px").parent().corner("round 6px");

    $('.my_desing_box').corner("round 6px");
    $('.my_desing_box .heading_title').corner("top 5px");
    $('.my_desing_box .design_box_content_area').corner("bottom 5px");

    $('.gradient_curve_box').corner("round 6px");
    $('.gradient_curve_box .heading_title').corner("top 5px");
    $('.gradient_curve_box .bottom_area').corner("bottom 5px");

    //$("#customizer_tabs").tabs();
    //$("#marketing_template_tabs").tabs();

    //  jquery UI Tab
    //$("#customizer_tabs, #customizer_tabs ul").removeClass("ui-corner-all");
    //$("#customizer_tabs ul li").removeClass("ui-corner-top");
    //$("#customizer_tabs .ui-tabs-nav li.ui-state-hover a").css({"opacity":0.9});
    //$(".grey_btn").button();
    $('.inactive').css({ opacity: 0.6 });
    //$(".grey_btn").button();


    //Marketing Materials Tab Function
    //Default Action
    $("#marketing_template_tabs .tab_content").hide(); //Hide all content
    $("#marketing_template_tabs .overview li:first").addClass("active").show(); //Activate first tab
    $("#marketing_template_tabs .tab_content:first").show(); //Show first tab content

    //On Click Event
    $("#marketing_template_tabs .overview li").click(function () {
        $("#marketing_template_tabs .overview li").removeClass("active"); //Remove any "active" class
        $(this).addClass("active"); //Add "active" class to selected tab
        $("#marketing_template_tabs .tab_content").hide(); //Hide all tab content
        var activeTab = $(this).find("a").attr("href"); //Find the rel attribute value to identify the active tab + content
        $(activeTab).fadeIn(); //Fade in the active content
        return false;
    });

    $("ul.subnav").parent().append("<span></span>"); //Only shows drop down trigger when js is enabled - Adds empty span tag after ul.subnav

    $("ul.topnav li a").hover(function () { //When trigger is clicked...

        //Following events are applied to the subnav itself (moving subnav up and down)
        $(this).parent().find("ul.subnav").slideDown('fast').show(); //Drop down the subnav on click

        $(this).parent().hover(function () {
        }, function () {
            $(this).parent().find("ul.subnav").slideUp('slow'); //When the mouse hovers out of the subnav, move it back up
        });

        //Following events are applied to the trigger (Hover events for the trigger)
    }).hover(function () {
        $(this).addClass("subhover"); //On hover over, add class "subhover"
    }, function () {	//On Hover Out
        $(this).removeClass("subhover"); //On hover out, remove class "subhover"
    });


});
/* end document.ready */


//function mCustomScrollbars(){
/* 
malihu custom scrollbar function parameters: 
1) scroll type (values: "vertical" or "horizontal")
2) scroll easing amount (0 for no easing) 
3) scroll easing type 
4) extra bottom scrolling space for vertical scroll type only (minimum value: 1)
5) scrollbar height/width adjustment (values: "auto" or "fixed")
6) mouse-wheel support (values: "yes" or "no")
7) scrolling via buttons support (values: "yes" or "no")
8) buttons scrolling speed (values: 1-20, 1 being the slowest)
*/
//$("#h_scroll_container").mCustomScrollbar("horizontal",500,"easeOutCirc",1,"fixed","yes","yes",20);
//$("#vscroll_container, #vscroll_container_2, #vscroll_container_3, #vscroll_container_4, #vscroll_container_5, #vscroll_container_6, #vscroll_container_7, #vscroll_container_8").mCustomScrollbar("vertical",400,"easeOutCirc",1.05,"fixed","yes","yes",10);
//}

/* function to load new content dynamically */
//function LoadNewContent(id,file){
//	$("#"+id+" .customScrollBox .content").load(file,function(){
//		mCustomScrollbars();
//	});
//}


//function createUploader(){            
//            var uploader = new qq.FileUploader({
//                element: document.getElementById('file-uploader'),
//                listElement: document.getElementById('separate-list'),
//                action: 'do-nothing.htm'
//            });           
//        }        
//        window.onload = createUploader;
