/**
 * @author fred
 */

/* idTabs ~ Sean Catchpole - Version 2.2 - MIT/GPL */
(function(){var dep={"jQuery":"http://code.jquery.com/jquery-latest.min.js"};var init=function(){(function($){$.fn.idTabs=function(){var s={};for(var i=0;i<arguments.length;++i){var a=arguments[i];switch(a.constructor){case Object:$.extend(s,a);break;case Boolean:s.change=a;break;case Number:s.start=a;break;case Function:s.click=a;break;case String:if(a.charAt(0)=='.')s.selected=a;else if(a.charAt(0)=='!')s.event=a;else s.start=a;break;}}
if(typeof s['return']=="function")
s.change=s['return'];return this.each(function(){$.idTabs(this,s);});}
$.idTabs=function(tabs,options){var meta=($.metadata)?$(tabs).metadata():{};var s=$.extend({},$.idTabs.settings,meta,options);if(s.selected.charAt(0)=='.')s.selected=s.selected.substr(1);if(s.event.charAt(0)=='!')s.event=s.event.substr(1);if(s.start==null)s.start=-1;var showId=function(){if($(this).is('.'+s.selected))
return s.change;var id="#"+this.href.split('#')[1];var aList=[];var idList=[];$("a",tabs).each(function(){if(this.href.match(/#/)){aList.push(this);idList.push("#"+this.href.split('#')[1]);}});if(s.click&&!s.click.apply(this,[id,idList,tabs,s]))return s.change;for(i in aList)$(aList[i]).removeClass(s.selected);for(i in idList)$(idList[i]).hide();$(this).addClass(s.selected);$(id).show();return s.change;}
var list=$("a[href*='#']",tabs).unbind(s.event,showId).bind(s.event,showId);list.each(function(){$("#"+this.href.split('#')[1]).hide();});var test=false;if((test=list.filter('.'+s.selected)).length);else if(typeof s.start=="number"&&(test=list.eq(s.start)).length);else if(typeof s.start=="string"&&(test=list.filter("[href*='#"+s.start+"']")).length);if(test){test.removeClass(s.selected);test.trigger(s.event);}
return s;}
$.idTabs.settings={start:0,change:false,click:null,selected:".selected",event:"!click"};$.idTabs.version="2.2";$(function(){$(".idTabs").idTabs();});})(jQuery);}
var check=function(o,s){s=s.split('.');while(o&&s.length)o=o[s.shift()];return o;}
var head=document.getElementsByTagName("head")[0];var add=function(url){var s=document.createElement("script");s.type="text/javascript";s.src=url;head.appendChild(s);}
var s=document.getElementsByTagName('script');var src=s[s.length-1].src;var ok=true;for(d in dep){if(check(this,d))continue;ok=false;add(dep[d]);}if(ok)return init();add(src);})();


var navImgs = new Array();

var mouseOut = true;


function redirect(url) {
	window.location.replace(url); 
	
}


jQuery(document).ready(function(){
	
	doDaAnniversary();
	
  jQuery('#flashmovid309').replaceWith('<div style="background: url(fileadmin/assets/swf/video/CJSchmidt_exquisit.jpg) top left no-repeat;"><a id="player-onstage" href="http://www.cjschmidt.de/fileadmin/assets/swf/video/CJSC_1100_IP_069.flv" style="display:block;width:584px;height:340px;"><img src="fileadmin/assets/img/btnVideoAbspielen.png" alt="Video abspielen"></a></div> <script language="JavaScript">flowplayer("player-onstage", {src: "fileadmin/assets/swf/flowplayer-3.2.7.swf", wmode: "transparent"});</script>');

  jQuery(".teaserBlock .right .teaser").each(function(i){
      jQuery(this).addClass('teaserPos'+ (i + 1));
  });
  
  jQuery('#nlformname').val('Name');
  jQuery('#nlformemail').val('E-Mail-Adresse');
  
  jQuery('#nlformnamedk').val('Navn');
  jQuery('#nlformemaildk').val('e-mail-adresse');
  
  jQuery('#nlformname').focus(function(){
      if(jQuery('#nlformname').val() == 'Name') {
        jQuery('#nlformname').val('');
      }
    
    }).blur(function(){
    if(jQuery('#nlformname').val() == '')
    {
      jQuery('#nlformname').val('Name');
    }
  
  });
  
  jQuery('#nlformemail').focus(function(){
      if(jQuery('#nlformemail').val() == 'E-Mail-Adresse') {
        jQuery('#nlformemail').val('');
      }
    
    }).blur(function(){
    if(jQuery('#nlformemail').val() == '')
    {
      jQuery('#nlformemail').val('E-Mail-Adresse');
    }
  
  });
  
  jQuery('#nlformnamedk').focus(function(){
      if(jQuery('#nlformnamedk').val() == 'Navn') {
        jQuery('#nlformnamedk').val('');
      }
    
    }).blur(function(){
    if(jQuery('#nlformnamedk').val() == '')
    {
      jQuery('#nlformnamedk').val('Navn');
    }
  
  });
  
  jQuery('#nlformemaildk').focus(function(){
      if(jQuery('#nlformemaildk').val() == 'e-mail-adresse') {
        jQuery('#nlformemaildk').val('');
      }
    
    }).blur(function(){
    if(jQuery('#nlformemaildk').val() == '')
    {
      jQuery('#nlformemaildk').val('e-mail-adresse');
    }
  
  });
  
  
  jQuery("#videobtn").appendTo("#content .teaserBlock .left .big .hoch2teaser");
  
  
  
  // funktion zum öffnen einer fancybox
  
  
  
});


function openFancybox(url) 
  {
  
    var jetzt = new Date();
  var ts = jetzt.getTime();
  var id = 'facyboxOpener_' + ts;
  
    jQuery('body').append('<a href="' + url + '" id="' + id + '">.</a>');
    jQuery('#' + id).fancybox({
              "type":"iframe",
              "width": 700,
              "height":770,
              "scrolling": "auto",
              "padding": 0,
              "speedIn": 300,
              "speedOut": 300,
              "changeSpeed": 300,
              "transitionIn": "fade",
              "transitionOut": "fade",
              "titlePosition": "outside",
              "titleShow": false,
              "easingIn": "fade",
              "easingOut": "fade",
              "showCloseButton": true,
              "showNavArrows": true,
              "enableEscapeButton": true,
              "overlayShow": true,
              "overlayOpacity": 0.7,
              "overlayColor": "#000000",
              "centerOnScroll": false,
              "hideOnContentClick": false,
               "titleFormat": "formatTitle",
              "autoScale"     : true,
              "autoDimensions"    : true
              
        });
        
    jQuery('#' + id).trigger('click').remove();
  
  }
  

function over1(name,imgObj)	{	//
		if (version == "n3" && document[name]) {document[name].src = eval(name+"_h.src");}
		else if (document.getElementById && document.getElementById(name)) {document.getElementById(name).src = eval(name+"_h.src");}
		else if (imgObj)	{imgObj.src = eval(name+"_h.src");}
	}
		// JS function for mouse-out
	function out1(name,imgObj)	{	//
		
		if(mouseOut) {
			if (version == "n3" && document[name]) {document[name].src = eval(name+"_n.src");}
			else if (document.getElementById && document.getElementById(name)) {document.getElementById(name).src = eval(name+"_n.src");}
			else if (imgObj)	{imgObj.src = eval(name+"_n.src");}
		}
		
	}



function showNavImg(image, imgTag) {
	imgTag.src = image;
	alert();
}


function hideNav(id) {
	
	
}



function changeImg(index,tag,img,mode) {
	
	if (mode == 1) { // hover bild anzeigen
		navImgs[index + "Pass"] = tag.src;
		tag.src = img;
	} else if (mode == 0) { // normales Bild bild anzeigen
		navImgs[index + "Act"] = tag.src;
		tag.src = navImgs[index + "Pass"];
	}
	
}


function closeTab1() {
	jQuery("#tabsABC").tabs("select", 7);
}

 var  tabs;
 
jQuery(document).ready(function(){
 
 /*
  tabs = $("#tabsABC").tabs({
			event: 'mouseover',
			fxFade: true, fxSpeed: 'fast',
			select: '#fragment-7'
		});
$("#tabsABC").tabs("select", 7);


*/
jQuery(".mainNavPoint").bind("mouseenter",function(){
      
	  jQuery("#sub32").css('visibility', 'visible');
	  mouseOut = false;
	  
    });
jQuery("#head").bind("mouseenter",function(){
      
	  jQuery("#sub32").css('visibility', 'hidden');
	  mouseOut = false;
	  resetAll();
	  
    });	
jQuery("#frame").bind("mouseenter",function(){
      
	  jQuery("#sub32").css('visibility', 'hidden');
	  mouseOut = false;
	  resetAll();
	  
    });		
	
	
	
	/*
$(".fragments").bind("mouseleave",function(){
      $("#sub32").css('visibility', 'hidden');
	  mouseOut = true;
    });
*/

		jQuery("#tabsABC").idTabs("!mouseover"); 
		//$("#tabsABC").idTabs({ "!mouseover, fragment-8" });
		
		
  });
  
  
   //tabs.tabs('select', 99);
//$("#tabsABC").tabs("select", 2);

 
 function ajaxLoad(url,div,bg,img) {
 div ="menuCon";

//

 //$("#"+div).fadeTo("slow", 0.01);
	jQuery("#menu").css({'background' : "#ffffff"});
 jQuery("#"+div+"Out").addClass('ajaxLoader');

 jQuery.ajax({
 url: url,
 cache: true,
 success: function(html){
 jQuery("#"+div+"Out").removeClass('ajaxLoader');
 
 jQuery("#"+div).html(html);
//$("#"+div).fadeTo("slow", 1.0);

 }
 });


}





function menSlideIn(url,bg,img) {
		
		//$(".navImg").css('display','none');

//      	$("#menu").slideUp("fast");
		
		
  //      $("#menu").slideDown("fast");
      	ajaxLoad(url+"&bg="+bg.substring(1),bg,img);
    jQuery("#menu").css({'background' : bg+" url(uploads/tx_hoch2ajaxmenu/"+ img + ") repeat-x top left"});
		

	
}


function menSlideOut() {
	
	
    	if (open == true) {
			$("#menu").slideUp("fast");
			open = false;
		}
		else 
			open = true;

    

	
}

function doDaAnniversary() {
	jQuery('#cont').addClass('annivarsary');
	jQuery('#cont').append('<div id="annivarsary1"></div><div id="annivarsary2"></div>');
	jQuery('#cont').addClass('annivarsary');
}


jQuery("#menu").slideUp("fast");


(function($) {
  $.fn.fullBg = function(){
    var bgImg = $(this);
    
    bgImg.addClass('fullBg');
    
    function resizeImg() {
      var imgwidth = bgImg.width();
      var imgheight = bgImg.height();
      
      var winwidth = $(window).width();
      var winheight = $(window).height();
      
      var widthratio = winwidth / imgwidth;
      var heightratio = winheight / imgheight;
      
      var widthdiff = heightratio * imgwidth;
      var heightdiff = widthratio * imgheight;
    
      if(heightdiff>winheight) {
        bgImg.css({
          width: winwidth+'px',
          height: heightdiff+'px'
        });
      } else {
        bgImg.css({
          width: widthdiff+'px',
          height: winheight+'px'
        });   
      }
    } 
    resizeImg();
    $(window).resize(function() {
      resizeImg();
    }); 
  };
})(jQuery)

jQuery(function($) {
  jQuery("#bgmain").fullBg();
});

