
/* jquery scope */
$.noConflict();


jQuery(document).ready(function($){
  $("#outer_layout").append("<div id='stageid' style=';position:absolute;top:-20px;left:20px;background:url(/_kk_skizze.png) no-repeat 0 0;width:173px;height:150px;z-index:0'>S T A GE</div>");

  /*  
  if(BrowserDetect.browser == 'Explorer'){
    $('#stageid').css('left', '100px');
  };
  */

  /* *********************** */
	/* popup FB */
  $('a#fbLogin').click( function(){
      url = $(this).attr('href');
      openBlankPopup(url, 410, 300)
      return false;  
  });

  /* *********************** */
	/* popup WL */
  $('a#wlLogin').click( function(){
      url = $(this).attr('href');
      openBlankPopup(url, 980, 500)
      return false;  
  });

   
  /* *********************** */
	/* tesareboxingg */ 
	$('#flipBox1').mouseover( function(){
		 $('#flipBox1 .boxFront').hide();
		 $('#flipBox1 .boxBack').show();   
	}).mouseout(function(){
		 $('#flipBox1 .boxFront').show();
		 $('#flipBox1 .boxBack').hide();
  });

	$('#flipBox2').mouseover( function(){
		 $('#flipBox2 .boxFront').hide();
		 $('#flipBox2 .boxBack').show();      
	}).mouseout(function(){
		 $('#flipBox2 .boxFront').show();
		 $('#flipBox2 .boxBack').hide();
  });

	$('#flipBox3').mouseover( function(){
		 $('#flipBox3 .boxFront').hide();
		 $('#flipBox3 .boxBack').show();  
	}).mouseout(function(){
		 $('#flipBox3 .boxFront').show();
		 $('#flipBox3 .boxBack').hide();
  });

	$('#flipBox4').mouseover( function(){
		 $('#flipBox4 .boxFront').hide();
		 $('#flipBox4 .boxBack').show();     
	}).mouseout(function(){
		 $('#flipBox4 .boxFront').show();
		 $('#flipBox4 .boxBack').hide();
  });

	$('#flipBox5').mouseover( function(){
		 $('#flipBox5 .boxFront').hide();
		 $('#flipBox5 .boxBack').show();   
	}).mouseout(function(){
		 $('#flipBox5 .boxFront').show();
		 $('#flipBox5 .boxBack').hide();
  });

	$('#flipBoxProfile').mouseover( function(){
		 $('#flipBoxProfile .boxFront').hide();
		 $('#flipBoxProfile .boxBack').show();    
	}).mouseout(function(){
		 $('#flipBoxProfile .boxFront').show();
		 $('#flipBoxProfile .boxBack').hide();
  });


  /* *********************** */
  // menu 
  $("ul.sf-menu").superfish();
  
  $("ul.sf-menu").superfish().find('ul').bgIframe({
    opacity: false
  });
  
  $("#menuindex38 a").css("background", "url(/fileadmin/templates/images/headerBigBtnLilac.png) no-repeat 0 0");
  $("#menuindex38 a.active").css("background", "url(/fileadmin/templates/images/headerBigBtnOrange.png) no-repeat 0 0");
  
  $("#menuindex38").mouseover(function () {
    $("#menuindex38 a").css("background","url(/fileadmin/templates/images/headerBigBtnGreen.png) no-repeat 0 0");
  }).mouseout(function(){
		  if ( $("#menuindex38 a.active").length > 0 ) {
				//setTimeout(function(){
		    	$("#menuindex38 a.active").css("background", "url(/fileadmin/templates/images/headerBigBtnOrange.png) no-repeat 0 0");
				
				//},1200);
		  } 
		  else {
				//setTimeout(function(){
		    $("#menuindex38 a").css("background", "url(/fileadmin/templates/images/headerBigBtnLilac.png) no-repeat 0 0");
				//},1200);
		  }
  });

  $("#menuindex260").mouseover(function () {
    $("#menuindex260 a").css("background","url(/fileadmin/templates/images/headerBigBtnGreen.png) no-repeat 0 0");
  }).mouseout(function(){
		  if ( $("#menuindex260 a.active").length > 0 ) {
				//setTimeout(function(){
		    $("#menuindex260 a.active").css("background", "url(/fileadmin/templates/images/headerBigBtnOrange.png) no-repeat 0 0");
				//},1200);
		  } 
		  else {
				//setTimeout(function(){
		    $("#menuindex260 a").css("background", "url(/fileadmin/templates/images/headerBigBtnLilac.png) no-repeat 0 0");
				//},1200);
		  }

  });


  /* *********************** */
  // forms, valid 
  $('form.cmxform').jqTransform({
    imgPath: '/fileadmin/templates/css/img/'
  });
  $("#validateForm").validationEngine();

  
  
  
  

  /* *********************** */
  /* FAQ */
  
  $(' ul#faqTeaserItems li').hover(function(){
    $(this).css({
      backgroundColor: "#eeeeee",
      cursor: "pointer"
    });
    $(this).css('cursor', 'hand');
  }, function(){
    $(this).css("background-color", "white");
  });
  
  $(' ul#faqTeaserItems li').click(function(){
    var link = $('a:first', this);
    xhref = link.attr("href");
    window.location = xhref;
    //alert (xhref);
  });

  /* *********************** */
  /* Nutrition Guide  */
  $(' ul#nutritionGuideList li .description').hover(function(){
    $(this).css({
      backgroundColor: "#eeeeee",
      cursor: "pointer"
    });
    $(this).css('cursor', 'hand');
  }, function(){
    $(this).css("background-color", "white");
  });
  
  $(' ul#nutritionGuideList li').click(function(){
    var link = $('a:first', this);
    xhref = link.attr("href");
    window.location = xhref;
    //alert (xhref);
  });

  /* *********************** */
  /* Produkte (Tabs-Box) */
  
  $('#hippTabsBox li .description').hover(function(){
    $(this).css({
      backgroundColor: "#f0f0f0",
      cursor: "pointer"
    });
    $(this).css('cursor', 'hand');
  }, function(){
    $(this).css("background-color", "white");
  });

  
  
});



function submitenter(myfield,e){
  var keycode;
  if (window.event) keycode = window.event.keyCode;
  else if (e) keycode = e.which;
  else return true;
  
  if (keycode == 13)
     {
     myfield.form.submit();
     return false;
     }
  else
     return true;
}



function include(file){
  var script = document.createElement('script');
  var type = document.createAttribute('type');
  type.nodeValue = 'text/javascript';
  script.setAttributeNode(type);
  var source = document.createAttribute('src');
  source.nodeValue = file;
  script.setAttributeNode(source);
  var head = document.getElementsByTagName('head')[0];
  head.appendChild(script);
}


function ReadCookie(cookieName){
  var theCookie = "" + document.cookie;
  var ind = theCookie.indexOf(cookieName);
  if (ind == -1 || cookieName == "") 
    return "";
  var ind1 = theCookie.indexOf(';', ind);
  if (ind1 == -1) 
    ind1 = theCookie.length;
  return unescape(theCookie.substring(ind + cookieName.length + 1, ind1));
}

      
function SetCookie(cookieName, cookieValue, nDays){
  var today = new Date();
  var expire = new Date();
  if (nDays == null || nDays == 0) 
    nDays = 1;
  expire.setTime(today.getTime() + 3600000 * 24 * nDays);
  document.cookie = cookieName + "=" + escape(cookieValue) +
  ";expires=" +
  expire.toGMTString();
}



function validateEmail(elementValue){  
    var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;  
    return emailPattern.test(elementValue);  
}


function openBlankPopup(url, width, height){
  Navigation = window.open(url, "BlankWIn", "height=" + height + ",width=" + width + ",scrollbars=no,fullscreen=no,location=no,menubar=no,status=no");
  return false;
}


function getParameter ( queryString, parameterName ) {
   // Add "=" to the parameter name (i.e. parameterName=value)
   var parameterName = parameterName + "=";
   if ( queryString.length > 0 ) {
      // Find the beginning of the string
      begin = queryString.indexOf ( parameterName );
      // If the parameter name is not found, skip it, otherwise return the value
      if ( begin != -1 ) {
         // Add the length (integer) to the beginning
         begin += parameterName.length;
         // Multiple parameters are separated by the "&" sign
         end = queryString.indexOf ( "&" , begin );
      if ( end == -1 ) {
         end = queryString.length
      }
      // Return the string
      return unescape ( queryString.substring ( begin, end ) );
   }
   // Return "null" if no parameter has been found
   return "null";
   }
}
