/*
 * Zung Tung Le jQuery functions
 *
 * written by Hendrik Meyer | MEDIA DSIGN websolutions
 * www.media-dsign.de
 *
 */

$(function(){
	$('#header').click(function(){	top.location='/'; });
	$('#header').bind("contextmenu",function(){ return false; })
	$('#siegel').bind("contextmenu",function(){ return false; })
	$('#chi_ming').bind("contextmenu",function(){ return false; })

	// Tabs
    // setup ul.tabs to work as tabs for each div directly under div.panes
    $("ul.tabs").tabs("div.panes > div",{effect: 'fade'});

	if($('a[rel]').length){
		// if the function argument is given to overlay,
	    // it is assumed to be the onBeforeLoad event listener
	    var ovl = $("a[rel]").overlay({
	        expose: 'darkred',
	        effect: 'apple',
	        oneInstance: false,
	        closeOnClick: false,
	        onBeforeLoad: function() {
	            // grab wrapper element inside content
	            var wrap = this.getContent().find(".contentWrap");
	            // load the page specified in the trigger
	            wrap.load(this.getTrigger().attr("href"));
	            return false;
	            /*wrap.load("http://www.chow-chows.net/" + this.getTrigger().attr("href") + " ");*/
	    		/*$("#overlay .contentWrap").load("http://www.chow-chows.net/" + this.getTrigger().attr("href") + " ","",function(){});
	    		$("#overlay .contentWrap").show();*/
	        },
	    	onLoad: function(){
	        	if($('td.img a').length){
		        	 $('td.img a').overlay({
		        	        target: '#gallery',
		        	        effect: 'apple',
		        	        oneInstance: false,
		        	        closeOnClick: false
		        	    }).gallery();
	        	}
	        	if($('td.berichte a').length){
		        	 $('td.berichte a').each(function(){
		        		  $(this).live('click',function(){
		        			  $(".contentWrap").load($(this).attr("href"));
		        	          return false;
		        		  });
		        	 });
	        	}
	        }
	    });
	    /*$('#overlay .close').click(function(){
			ovl.close();
		});*/
	    if($('div.img a[rel]').length){
	    	$('div.img a[rel]').overlay({ effect: 'apple'  });
	    }
	    if($('div.img_left a[rel]').length){
	    	$('div.img_left a[rel]').overlay({ effect: 'apple'});
	    }
	    if($('.more_pics a').length){
		    $('.more_pics a').overlay({
		        target: '#gallery',
		        effect: 'apple',
		        oneInstance: false,
		        closeOnClick: false
		    }).gallery();
	    }
	}
	if($('.bilder div a').length){
	    $('.bilder div a').overlay({
	        target: '#gallery',
	        effect: 'apple',
	        oneInstance: false,
	        closeOnClick: false
	    }).gallery();
    }
	if($('.images a').length){
	    $('.images a').overlay({
	        target: '#gallery',
	        effect: 'apple',
	        oneInstance: false,
	        closeOnClick: false
	    }).gallery();
    }
	if($('.albumpic a').length){
	    $('.albumpic a').overlay({
	        target: '#gallery',
	        effect: 'apple',
	        oneInstance: false,
	        closeOnClick: false
	    }).gallery();
    }

	if($('p.nachkommen a').length){
	    $('p.nachkommen a').overlay({
	        target: '#gallery',
	        effect: 'apple',
	        oneInstance: false,
	        closeOnClick: false
	    }).gallery();
    }

/*    if($('div.nachzucht').length){
	    $('div.nachzucht').each(function(){
	    	var divW = $(this).width();
	    	$(this).children().filter('div').each(function(){
	    		var spanW = $(this).width();
	    		$(this).css('marginLeft', divW - spanW );
	    	});
	    });
    }*/
});