$(function(){
    
    $('#submit_search').mouseover(function(){
       $(this).css({'background':"url('"+STATIC_IMG_DIR+"oursawe_submit.gif') no-repeat 0px -26px"}) ;
    })
    $('#submit_search').mouseout(function(){
       $(this).css({'background':"url('"+STATIC_IMG_DIR+"oursawe_submit.gif') no-repeat 0px 0px"}) ;
    })
    
});

var this_faceboxit=null;

function faceboxit(divId) {
    if($.browser.msie){
			$("select").each(function (){                            
				var width=$(this).width()+2;
				var height=$(this).height()+2;
                $(this).css({'display':'none'}).after('<div style="border:solid 1px #cacccd;background:#fff;width:'+width+'px;height:'+height+'px;" class="hiddediv"></div>');
			});
		}
	
              
		$("#dark").css({'height':$(document).height()+'px','opacity':'0.6','visibility':'visible'});
		var width=parseInt($(document).width()/2)-225;
        $("#"+divId).css({'top':'150px','left':width+'px','visibility':'visible'});
        this_faceboxit=divId;
}

function removeFacebox(divId){		
		if($.browser.msie){
			$('.hiddediv').remove();
			$('select').css({'display':'block'});
		}
		$("#"+divId+",#dark").css({'top':'0px','left':'0px','visibility':'hidden'});
        $("#dark").css({'height':'0px'})
}

var start_width=0;

function resize(){		
        var width=parseInt($('body').width()/2)-225;
		$("#"+this_faceboxit).css({'left':width+'px'});

              
        if(document.getElementById('topcontainer')!=null){

            if($('body').height()<($('#topcontainer').height()))
                var height=$('#topcontainer').height();
            else
                var height=$('body').height();           
             
            if($('body').width()<986){
                start_width=986;                
            }
            else{
                if(start_width!=0)
                start_width=$('body').width();
            }           
            if(start_width!=0)
            $("#dark").css({'width':start_width+'px'});  
            
            
        }        
        else if(document.getElementById('resize_window')!=null){
            if($('body').height()<$('#resize_window').height())
                var height=$('#resize_window').height()+20;
            else
                var height=$('body').height()+20;
               
            if($('body').width()<758){
                start_width=758;                
            }
            else{
                if(start_width!=0)
                start_width=$('body').width();
            }           
            if(start_width!=0)
            $("#dark").css({'width':start_width+'px'}); 
        }
        else{
            
            var height=$('body').height()+20;
        }
        
        
        if(!$.browser.msie)
            var height=height+15;

		$("#dark").css({'height':height+'px'});
}

/**
 * Loads in a URL into a specified divName, and applies the function to
 * all the links inside the pagination div of that page (to preserve the ajax-request)
 * @param string href The URL of the page to load
 * @param string divName The name of the DOM-element to load the data into
 * @return boolean False To prevent the links from doing anything on their own.
 */
function loadPiece(href,divName) {
    $(divName).load(href).fadeIn();
} 