$(function(){

    var mail_text=0;
    $("#mail_text").click(function(){
        if(mail_text==0){
            $(this).val('');
            mail_text=1;
        }
    });

    var old='';
    $('.center_faqs2 a, .center_faqs a').click(function(){
        
        var tab=$(this).attr('name');
        if(old!=tab){                
            if(old!=''){
                $('#'+old).animate({'height':'0px'},500);    
            }else{
                $('.center_faqs2 div:first, .center_faqs div:first').animate({'height':'0px'},500);  
            }               
            $('#'+tab).animate({'height':$('#'+tab+' div').height()+'px'},500);
        }else{                
        }
        old=tab;
    })
    
    $('.center_faqs2 div:first').animate({'height':$('.center_faqs2 div:first div').height()+'px'},500);
    $('.center_faqs div:first').animate({'height':$('.center_faqs div:first div').height()+'px'},500);
    
});




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','display':'block','width':$(document).width()+'px','position':'absolute','top':'0px','left':'0px'});
		var width=parseInt($(document).width()/2)-225;
        $("#"+divId).css({'top':'150px','left':width+'px','visibility':'visible','display':'block'});
        this_faceboxit=divId;
}

function removeFacebox(divId){		
		if($.browser.msie){
			$('.hiddediv').remove();
			$('select').css({'display':'block'});
		}
		$("#"+divId+",#dark").css({'top':'0px','left':'0px','display':'none'});
        $("#dark").css({'height':'0px'})
}

var start_width=0;

function resize(){
        //$('#aaaa').html($('body').height() +'----------'+ $('#resize_window').height());
		
        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, {}, function(){
        var divPaginationLinks = divName+" .mcpaginationstock a";
        $(divPaginationLinks).click(function() {     
            var thisHref = $(this).attr("href");
            loadPiece(thisHref,divName);
            return false;
        });
    });
} 