﻿var hiberd;
var productsInfo;
_hiberd = function(){}
_hiberd.setVar=function(key,value){
    var v = this.getVars();
    var sVals='';
    v[key] = value;
    var s;
    for (s in v)
        sVals += '~|~' + s + '~!~' + v[s];
    var p=0;
    if(sVals.length>0) p=3;
    $('#ctl00_CPHContent___hiVars').val(sVals.substr(p));
}
_hiberd.getVar=function(key){
   if (this.getVars()[key] != null)
   {
	 return this.getVars()[key];
   }
}
_hiberd.getVars=function(){
    if($('#ctl00_CPHContent___hiVars').length>0){
        var vars = new Array();
        temp = $('#ctl00_CPHContent___hiVars').val().split('~|~');
        for(i=0;i<temp.length;i++){
            aryItem=temp[i].split('~!~');
            if (aryItem.length == 2)
                vars[aryItem[0]] = aryItem[1];
        }  
        return vars;
    }
}

showMessage = function(container,type,title,text){
    o=$('#'+container); 
    o.css('display','block');
    if(o.length>0){
       if(text!=undefined){
         o.find('.icon').attr('class','icon t'+type);
         o.find('.title .text').text(title);
         o.find('.message').html(text);
       } 
       //$('#doc_disable').show();    
       o.fadeIn(500);
    }
}
hideMessage = function(container){
    o=$('#'+container);   
    if(o.length>0){
       o.fadeOut();
       //$('#doc_disable').hide();
    }
    o.fadeOut(500);
    o.css('display','none');
}
function displayImage(cid,img){
    $('#'+cid).attr('src',img).hide().fadeIn(500);
}
function ajaxCallFailed(res, error) {
    //alert(error);
}
/****************************************************/
function checkEnter(e,ctr){var k;if(window.event){k = e.keyCode;}else if(e.which){k = e.which;};if (k=='13'){$("#"+ctr).click();return false;}}
tooltip=function(){var id = 'tt';var top = 3;var left = 3;var maxw = 300;var speed = 10;var timer = 20;var endalpha = 95;var alpha = 0;var tt,t,c,b,h;var ie = document.all ? true : false;return{show:function(title,help,w){if(tt == null){tt = document.createElement('div');$(tt).attr('id',id);$(tt).css('visibility','hidden');t = document.createElement('div');$(t).attr('id',id + 'top');c = document.createElement('div');$(c).attr('id',id + 'cont');if(title!='') $(tt).append(t);$(tt).append(c);$(document.body).append(tt);$(tt).css('opacity','0');$(tt).css('filter','alpha(opacity=0)');document.onmousemove = this.pos;};$(tt).css('display','block');t.innerHTML = title;c.innerHTML = help;$(tt).css('width',w ? w + 'px' : 'auto');if(!w && ie){$(t).css('display','none');$(tt).css('width',$(tt).innerWidth());$(t).css('display','block');};if($(tt).innerWidth() > maxw){$(tt).css('width',maxw + 'px')};h = parseInt($(tt).innerHeight()) + top;clearInterval(tt.timer);tt.timer = setInterval(function(){tooltip.fade(1)},timer);},showAlt:function(text){this.show('',text);},pos:function(e){var u = ie ? event.clientY + document.documentElement.scrollTop:e.pageY;var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;$(tt).css('top',(u - h) + 'px');$(tt).css('left',(l + left) + 'px');},fade:function(d){var a = alpha;if((a != endalpha && d == 1) || (a != 0 && d == -1)){var i = speed;if(endalpha - a < speed && d == 1){i = endalpha - a;}else if(alpha < speed && d == -1){i = a;};alpha = a + (i * d);$(tt).css('visibility','visible');$(tt).css('opacity',alpha * .01);$(tt).css('filter','alpha(opacity=' + alpha + ')');}else{clearInterval(tt.timer);if(d == -1){$(tt).css('display','none')}}},hide:function(){if(tt != undefined){clearInterval(tt.timer);tt.timer = setInterval(function(){tooltip.fade(-1)},timer);}}};}();
function checkImage(O){
    if(O.attr("src")=="" || O.attr("src")=="../../"){O.attr("src","../../images/noimage.gif")}
    else{
        var img=new Image();
        img.src=O[0].src;
        img.onerror=function(){O.attr("src","../../images/noimage.gif")};
    }
}
$(document).ready(function()
{
    $('#hi_message .min').click(function(){
        hideMessage('hi_message');
    })
    
    $(".tmb_item img").each(function(){
        checkImage($(this));
    });
    if($('#gallery a').length>0){$('#gallery a').lightBox({});}
});
