// Modus Vivendi Javascript core Functions
/* -------------------------------------------------
START:: EXTERNAL LINKS

------------------------------------------------- */
function linksExternal(){

   if (document.getElementsByTagName){
     var anchors = document.getElementsByTagName("a");
     for (var i=0; i<anchors.length; i++){
           var anchor = anchors[i];
           if (anchor.getAttribute("rel") == "_external"){
               anchor.target = "_blank";
           }
      }
    }
}
/* -------------------------------------------------

END:: EXTERNAL LINKS

------------------------------------------------- */

    $(window).load(function() {
        $('#slider').nivoSlider({
        effect: "random",
        directionNavHide: false,
        controlNavThumbs: true,
        controlNavThumbsFromRel:true    
        });
    });



// add to bookMark Function
function addBookmark() {    
    var title = document.title;            
    var url = document.location.href;
    if (window.sidebar)    window.sidebar.addPanel(title, url,"");
     else if( document.all )   window.external.AddFavorite( url, title);
    else return true;
}

$(window).unload(function() {
    $.unblockUI();   
})

// initialize Jquery Dom
$(document).ready(function(){

    
     $("#mc-embedded-subscribe-form").validate({
   rules: {
     EMAIL: {
       required: true,
       email: true
     }
   },     
     debug: false
 
 });

        $.unblockUI(); // Unblockui Bug;
//Set Currency Change
        $(function () {
            $("#currency--show_currency").live("change keyup", function () {
                $("#currency").submit();
            });
        });        
        
        // Set External Links
        linksExternal();
        
        $("#mainCategories ul").superfish({
        
        autoArrows:    false,    
        dropShadows:   false
            
            
        });


                                                      
if (self != top){
   top.location.href = self.location;href;
}
   
$.preloadCssImages();


$('#leftColumn * a,#logo a, #mainCategories * a, #loginUser * a,#miniCart * a, #footerLinks * a,#leftImage a, #rightImage a, #centerImage a').click(function() { 

        if ($(this).attr("href") != "javascript:void(0)" && $(this).attr("rel") != "_external"){
            
            $.blockUI({ message: '<div class="waitMsg"><h1 class="waitMsgText">Please Wait ...</h1><div class="waitMsgLoader"></div></div>', 
                      css: { 
        padding:        0, 
        margin:         0, 
        width:          '380px',
        height:            '60px',
        top:            '40%',  
        left:           '40%',  
        textAlign:      'center',  
        color:          '#000',  
        border:         '', 
        backgroundColor:'', 
        cursor:         'wait' 
                    
                    
                         } 
                         
                 });  

        }

    }); 
    
    //bind miniSearch Field with Value
    $('#gbu0--minisearch--gbu0--prodsearch--string').clearingInput({text: 'Search'});
    $('#mce-EMAIL').clearingInput({text: 'Your e-mail'});
    // bind favorites Btn Action
    $("#bookMark a").click(function(){
    addBookmark();                              
    });

// faceBook
$("#facebookBtn a").mouseover(function(){


        var $holder = $('#facebookBtn');
        if ($.browser.msie){
            $holder[0].style.removeAttribute('filter');
        }                                         
                                                                                                          
    
    $("#facebookBtn").animate({ 
        top: "10px"
      }, 1 ).fadeOut(200).fadeIn(200);
    })


// myspace
$("#myspaceBtn a").mouseover(function(){


        var $holder = $('#myspaceBtn');
        if ($.browser.msie){
            $holder[0].style.removeAttribute('filter');
        }                                         
                                                                                                          
    
    $("#myspaceBtn").animate({ 
        top: "6px"
      }, 1 ).fadeOut(200).fadeIn(200);
    })


// bookMark
$("#bookMark a").mouseover(function(){


        var $holder = $('#bookMark');
        if ($.browser.msie){
            $holder[0].style.removeAttribute('filter');
        }                                         
                                                                                                          
    
    $("#bookMark a").animate({ 
        top: "10px"
      }, 1 ).fadeOut(200).fadeIn(200);
    })
    
});





