/**
* Centryl - centralize your business
* http://www.centryl.bg
* Copyright (c) 2011 Centryl Ltd
*
* License
*/
function initMenu() {
    var options = document.getElementById('top_menu').getElementsByTagName('li');
    for(var i=0;i<options.length;i++) {
        options[i].onmouseover = function(e) {
            this.firstChild.firstChild.className = 'current';
            var childs = this.childNodes;
            for(var i=0;i<childs.length;i++)
                if(childs[i].nodeName=='UL') {
                    this.current = childs[i];
                    childs[i].style.display = 'block';
                    
            }
        }
        options[i].onmouseout = function() {
            this.firstChild.firstChild.className = '';
            if(this.current)
                this.current.style.display = 'none';
        }
    }
    initMenu = function(){};
}
function message(message) {
    alert(message);
}
function addToWishList(id,el) {
    cl.ajax.send(BASELINK+'auth/wishadd','id='+id,function(transport){
        var data = transport.responseText;
        if(data=='NO_CUSTOMER') {
            message('Трябва да влезете в системата за да ползвате функцията');
            return;
        }
        if(data=='ADDED') {
            message('Продуктът е вече добавен в любими');
            return
        }
        var wish_el = document.getElementById('wishlist_count');
        wish_el.innerHTML = parseInt(wish_el.innerHTML)+1;
        message('Продуктът е добавен в любими');
    });
}
function removeFromWishList(id,el) {
    cl.ajax.send(BASELINK+'auth/wishremove','id='+id,function(transport){
        var data = transport.responseText;
        var wish_el = document.getElementById('wishlist_count');
        wish_el.innerHTML = parseInt(wish_el.innerHTML)-1;
        message('Продуктът е премахнат от любими');
        window.location.href = ''; 
    });
}
