
$(document).ready(function(){

//bottom decorator - scroll up
$("#top").click(function(){
   $("html, body").animate({scrollTop:0}, "fast"); 
});

//images with fading opacity
$(".fading").css("opacity",0);
$(".fading").fadeTo("slow",1);

// Error animation
$(".status").css("opacity",0).fadeTo("slow",1).animate( { borderLeftWidth:"20px" }, 800).animate;


// Fade images: class="fade"
$(".fade").css("opacity",0.4).mouseover(function(){
	$(this).fadeTo("fast",1);
    }).mouseout(function(){
   	$(this).fadeTo("fast",0.4);
    });

//Fade buttons
$(".button").css("opacity",0.70).mouseover(function(){
	$(this).fadeTo("fast",1);
    }).mouseout(function(){
   	$(this).fadeTo("fast",0.70);
    });

// Catalog ODD, table background-color:
$("div.every-product-wrap:odd").addClass("odd-row-style");

// Catalog ODD, table background-color:
$(".rowBg:even").addClass("rowBgColor");

// User invoices ODD, table background-color:
$("table#table-style tr:odd").addClass("odd-row-bg");


// Round corners class
$(".round6").corner("6px");
$(".round7").corner("7px");
$(".round8").corner("8px");
$(".round9").corner("9px");
$(".round10").corner("10px");
$(".roundTip").corner("round tl bl br 10px");


// User Login forms effect.
$(".user_login2").addClass("user_login").focus(function(){
	$(".user_login2").toggleClass("user_login_focus");
    }).blur(function(){
   	$(".user_login2").removeClass("user_login_focus");
    });

$(".user_pass2").addClass("user_pass").focus(function(){
	$(".user_pass2").toggleClass("user_pass_focus");
    }).blur(function(){
   	$(".user_pass2").removeClass("user_pass_focus");
    });


}); //on document ready


//jquery functions
function updateGalleryPicture(idd,pic_numm,pic_path){

var result = '<img style="cursor:pointer;" src="' + pic_path + '" width="200" height="150" />';

$("#picture_medium").html(result).show();

}

function getAttributes(id_val,lang_val,class_val,k_val,v_val){

var url = "index.php?lang=" + lang_val + "&class=" + class_val + "&action=showAttributes&id=" + id_val;

$.post(url, {k : k_val, v : v_val}, function(result){
    
       $("#attributes").html(result).show();
       
});

}

function getGallery(status,lang_val){

var url = "index.php?lang=" + lang_val + "&class=gallery&action=getPicture&sid=" + Math.random();

$.post(url, {"status" : status}, function(result){

       $("#gallery").html(result).show();

});

}

//library functions
function print(url){
  var load = window.open("index.php?" + url,"","scrollbars=no,menubar=yes,height=0,width=0,resizable=yes,toolbar=no,location=0,status=0");
}

  
function printPage() {

if(window.print)
 window.print();
   
}

function setCookie(c_name,value,expiredays){

var exdate = new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name + "=" + escape(value) +
((expiredays==null) ? "" : ";expires=" + exdate.toGMTString());

}

function textCounter(field,cntfield,maxlimit){

if (field.value.length > maxlimit)
 field.value = field.value.substring(0, maxlimit);
else
 cntfield.value = maxlimit - field.value.length;

}


/* CODA BUBLE */
 $(function () {
        $('.bubbleInfo-tooltip').each(function () {
            var distance = 10;
            var time = 250;
            var hideDelay = 500;

            var hideDelayTimer = null;

            var beingShown = false;
            var shown = false;
            var trigger = $('.trigger-tooltip', this);
            var info = $('.popup-tooltip', this).css('opacity', 0);


            $([trigger.get(0), info.get(0)]).mouseover(function () {
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                if (beingShown || shown) {
                    // don't trigger the animation again
                    return;
                } else {
                    // reset position of info box
                    beingShown = true;

                    info.css({
                        top: -100,
                        left: -100,
                        display: 'block'
                    }).animate({
                        top: '-=' + distance + 'px',
                        opacity: 1
                    }, time, 'swing', function() {
                        beingShown = false;
                        shown = true;
                    });
                }

                return false;
            }).mouseout(function () {
                if (hideDelayTimer) clearTimeout(hideDelayTimer);
                hideDelayTimer = setTimeout(function () {
                    hideDelayTimer = null;
                    info.animate({
                        top: '-=' + distance + 'px',
                        opacity: 0
                    }, time, 'swing', function () {
                        shown = false;
                        info.css('display', 'none');
                    });

                }, hideDelay);

                return false;
            });
        });
    });
