
jQuery(function($) {
    var cache = [];
    // Arguments are image paths relative to the current page.
    $.preLoadImages = function() {
        var args_len = arguments.length;
        for (var i = args_len; i--;) {
            var cacheImage = document.createElement('img');
            cacheImage.src = arguments[i];
            cache.push(cacheImage);
        }
    }
	
    // menu
    //$("#MenuMoishes a[href] img").hover(
   // $("#MenuMoishes a[class='hover'] img").hover(
     $("#MenuMoishes a.hover img").hover(
        function(e){
            $(this).attr("src", $(this).attr("src").replace("_0.png", "_1.png"));
        },
        function(e){
            $(this).attr("src", $(this).attr("src").replace("_1.png", "_0.png"));
        }
    ).mousedown(
        function(e){
            if ( $(this).attr("id") != "menu_09" ){
                $(this).attr("src", $(this).attr("src").replace("_1.png", "_2.png"));
            }
        }
    );
    
    
    // pop contact
    $("#contact_popup_rangeBas img").hover(
        function(e){
            $(this).attr("src", base_url + $(this).attr("id")+"_1.png");
        },
        function(e){
            $(this).attr("src", base_url + $(this).attr("id")+"_0.png");
        }
    ).mousedown(function(e){
        $(this).attr("src", base_url + $(this).attr("id")+"_2.png");
    });
    
    // IE is a wast of time
    // hide cotact
    $("#contact_close").click(function(){
        if ($.browser.msie)
            $("#contact_popup").hide();
        else
            $("#contact_popup").fadeOut();
    });
    
    
    
     
    $('.contactWindow').click(function(){ 
        $.openDOMWindow({ 
            windowSourceID:'#contact_popup', 
            height:339,  
            width:472, 
            overlay:1, 
            overlayOpacity: 15,
            modal:1, 
            positionType:'centered',  
            windowPadding:20,  
            windowBGImage: '../img/contact_canva.png',
            windowBGColor:'transparent',  
            borderSize:'0', 
            anchoredSelector:'contactWindow' 
            /*positionLeft:120, 
            positionTop:-150*/ 
        }); 
        return false; 
    }); 
    
    
    // IE is a wast of time
    $("#menu-22").hover(        
        function(e){             
           if ($.browser.msie) 
               $("#menu_22").show();
           else
               $("#menu_22").fadeIn("slow");
        },
        function(e){
           if ($.browser.msie) 
               $("#menu_22").hide();
           else
               $("#menu_22").fadeOut("slow");
        }
    );
    
});

function preload_menu()
{
    // menu
    jQuery.preLoadImages(
        base_url+"menu/menu_03_1.png", 
        base_url+"menu/menu_05_1.png",
        base_url+"menu/menu_07_1.png",
        base_url+"menu/menu_09_1.png",
        base_url+"menu/menu_03_2.png", 
        base_url+"menu/menu_05_2.png",
        base_url+"menu/menu_07_2.png",
        base_url+"menu/menu_09_2.png");
}

function preload_contact()
{
    // contact pop up
    jQuery.preLoadImages(
        base_url+"contact_close_1.png",
        base_url+"contact_close_2.png",
        base_url+"contact_link_1.png",
        base_url+"contact_link_2.png"
    );
}


function makeURL(key, action) {
	var str_url = document.location.href;
	str_url = str_url.substr(0, str_url.indexOf("/"+key)) + "/" + action;
	return str_url;
}


function baseName() {
	var str_url = document.location.href;
	arr_url = str_url.split("/");
	return arr_url[arr_url.length-1];
}
function dirName() {
	var arr_url = document.location.href.split("/");
	arr_url.pop();
	return arr_url.join("/")+"/"  ;
}
