var descriptions;

window.addEvent("domready", function(){
    evolis.init();

//
//    $(".showPerPageLink").click(function() {
//
//        $.cookie("perPage", $(this).attr("href"), {
//            path: '/'
//        });
//        $(".search").submit();
//
//        return false;
//    });
//
//    if ((typeof(searchText) != "undefined") && searchText) {
//        $(".searchResults").highlight(searchText);
//    }


   

});

window.addEvent("resize", function(){
    evolis.resize();
});

function validateEmail(email){
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    if(reg.test(email) == false || email == "") {
        jQuery("#invalid_email").css("display", "block");
	jQuery(".last_newsletter").css("display", "none");
        return false;
    }
    return true;
}

var evolis = {
    init: function(){
        if( $chk($("menu")) ) evolis.menu();
        if( $chk($("lng")) ) evolis.lng();
        //if( $chk($("navigation")) ) evolis.navigation();
        if( $chk($("homepage")) ) evolis.homepage();
        evolis.resize();
    },
    menu: function(){
        $("menu").getElements("li.hover").each(function(item, index){
            item.addEvents({
                "mouseover": function(e){
                    $(item).className = "on";
                    $(item).getElements("ul").setStyle("display", "block");
                }.bind(this),
                "mouseout": function(e){
                    $(item).className = "";
                    $(item).getElements("ul").setStyle("display", "none");
                }.bind(this)
            });
        });
    },
    lng: function(){
        $("lng").addEvents({
            "mouseover": function(e){
                $("lng").getElements("ul").setStyle("display", "block");
            }.bind(this),
            "mouseout": function(e){
                $("lng").getElements("ul").setStyle("display", "none");
            }.bind(this)
        });
    },
    navigation: function(){
        $("navigation").getElements("li.sub").each(function(item, index){
            var oldClassName = "";
            item.addEvents({
                "click": function(e){
                    if( $(item).className.indexOf("on") > -1 ){
                        $(item).className = oldClassName;
                        $(item).getElements("ul").setStyle("display", "none");
                    } else {
                        oldClassName = $(item).className;
                        $(item).className = oldClassName + " on";
                        $(item).getElements("ul").setStyle("display", "block");
                    }
                    return false;
                }.bind(this)
            });
        });
    },
    homepage: function(){
        $("scroll-pane-content").setStyles({
            "position": "relative",
            "left": 0,
            "width": $("scroll-pane-content").offsetWidth + "px"
        });
		
        var mf = new MooFlow($("MooFlow"), {
            startIndex: 2,
            factor: 185,
            offsetY: -193,
            heightRatio: 0.355,
            reflection: 0.3,
            bgColor: "#cdcdcd",
            useAutoPlay: true,
            interval: 5000
        });
        descriptions = $("descriptions").getElements("div");
		
        var scr = new ScrollBar("scroll-pane", "scroll-pane-block");
    },
    resize: function(){
        if(document.documentElement.clientWidth){ // bug background position
            if($('main')){
                width = Math.floor((document.documentElement.clientWidth - $("main").offsetWidth)/2);
                $("main").setStyle("marginLeft", width + "px");
            }
        }
        if(document.documentElement.clientHeight){
            //alert(document.documentElement.clientHeight);
            height = Math.floor(document.documentElement.clientHeight - 240);
            if($('wrap1')){
                $("wrap1").setStyle("minHeight", height + "px")
                };
        }
    }
};


window.addEvent('domready',function()
{
    if($('printerfor')){
        var  processChange = function(){
		
            block = $('printerfor').getChildren();
            select = block.getChildren();
			
            if( select[0][0].value == "1"){
                $('usualdistributorblock').setStyle('display', 'block');
                $('enduserblock').setStyle('display', 'none');
            }
            else if(select[0][0].value == "0"){
                $('usualdistributorblock').setStyle('display', 'none');
                $('enduserblock').setStyle('display', 'block');
            }
            else{
                $('usualdistributorblock').setStyle('display', 'none');
                $('enduserblock').setStyle('display', 'none');
            }
        }
		
        block = $('printerfor').getChildren();
        select = block.getChildren();
		
        if( select[0][0]){
            select[0][0].addEvent('change', processChange)
			


            processChange();
        }
    }
});

