/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

jQuery.fn.extend
({
    removeCss: function(cssName) {
        return this.each(function() {
            var curDom = $(this);
            jQuery.grep(cssName.split(","),
                    function(cssToBeRemoved) {
                        curDom.css(cssToBeRemoved, '');
                    });
            return curDom;
        });
    }
});


$(document).ready(
function(){
    $("#tip").css({height:($("#tip").height()+10)+"px"});
    //Pro detail
    $(".product").click(function(event){
        window.location = $(this).find('a').attr('href');
    });
    $(".producttop").click(function(event){
        window.location = $(this).find('a').attr('href');
    });
    if(typeof($("#tippluscontact").height())=='number'&&typeof($("#fboxcat").height())=='number'&&$("#fboxcat").height()<$("#tippluscontact").height()) {
        $("#fboxcat").height($("#tippluscontact").height()-7);
    }
    var scrollpanel = $("div#content div.box #scroller span");
    var inscrollpanelwidth = scrollpanel.width()+"px";
    function scrolling(){
        scrollpanel.animate( { left:"-"+inscrollpanelwidth },30000 ,function(){
            scrollpanel.css({left:""+$("div#content div.box #scroller").width()+"px",width:inscrollpanelwidth});
            scrolling();
        } )}
    var actual_tip = 1;
    $("#tip").everyTime(6000,"10s",function(){    if (!stoptipscroller) nextTip();})
    var stoptipscroller = false
    $("#tip").mouseover(function(){stoptipscroller=true})
    $("#tip").mouseout(function(){stoptipscroller=false})
    function nextTip() {
        myHide($("#tip"+actual_tip));
        if ($("#tip"+(actual_tip+1)).size()==1) {
            myShow($("#tip"+(actual_tip+1)));
            actual_tip ++;
        } else {
            actual_tip = 1;
            firstTip();
        }
    }
    $(".tipscroller").css({opacity:0,position:"absolute",left:"8px",top:"8px",height:$("#tippluscontact").height()+"px",width:($("#tip").width()-20)+"px",display: "block"});

   firstTip();
   function myHide(tar) {
        tar.animate({ opacity: 0}, 500, function() {tar.css({"z-index":1})});
    }
    function myShow(tar) {
        tar.animate({ opacity: 1}, 500, function() {tar.css({opacity:null,"z-index":10})});
    }
    function firstTip() {
        myShow($("#tip1"));
    }
    function lastTip() {
        actual_tip = $("#tip div.tipscroller:last").attr('id').substring(3,99);
        myShow($("#tip"+(actual_tip)));
    }
    function prevTip() {
        myHide($("#tip"+actual_tip));
        if ($("#tip"+(actual_tip-1)).size()==1) {
            myShow($("#tip"+(actual_tip-1)));
            actual_tip --;
        } else {
            actual_tip = 1;
            lastTip();
        }
    }
    $("#nexttip").click(function(){prevTip()})
    $("#prevtip").click(function(){nextTip()})

    $(".productrow").css({cursor:"pointer"});


    $(".productrow").click(function(event){
        window.location = $(this).find('a:first').attr('href');
    });
    
    $("#headerrightblank").append($("#basket"));

    if($("#navbarr").height() > $("#content").height()) {

        $("#content").height($("#navbarr").height())

    }


});
