var fQuery = jQuery.noConflict();
fQuery(document).ready(function(){
	swapValue = [];
	fQuery("input.inp_prov").each(function(i){
	   swapValue[i] = fQuery(this).val();
   		fQuery(this).focus(function(){
      	if (fQuery(this).val() == swapValue[i]) {
         	fQuery(this).val("");
      	}
    fQuery(this).addClass("focus");
    }).blur(function(){
     	if (fQuery.trim(fQuery(this).val()) == "") {
       		fQuery(this).val(swapValue[i]);
	 		fQuery(this).removeClass("focus");
      	}
 	});
    });
  
	// nav sub
	fQuery("#nav-sub ul li a").hover(function() {
	  fQuery(this).animate({ backgroundColor: "#DFEAF3" }, 600);
	},function() {
	  fQuery(this).animate({ backgroundColor: "#f1f1f1" }, 400);
	});

	
	fQuery('.iframe-dialog,').click(function(e) {       
      e.preventDefault();
      var $this = fQuery(this);
      var config = (this.rel.length) ? eval('(' + fQuery(this).attr("rel") +	')') : {};
      var params = (config.params) ? config.params : {};
      var w = parseInt(config.width) || 460;
	  var h = parseInt(config.height) || 400;
	  //var d = fQuery('<div class="ui-dialog"><img src="img/layout/loader.gif" alt="Load..." /></div>').appendTo("body");

      fQuery('<iframe id="externalSite" frameborder="0" marginheight="0" marginwidth="0" scrolling="no" style="style="filter: Chroma(color=#ffffff)" class="externalSite" src="' + this.href + '" />').dialog({
                title: ($this.attr('title')) ? $this.attr('title') : 'External Site',
                autoOpen: true,
                width: w,
                height: h,
                modal: true,
                resizable: false,
                autoResize: false,
                zIndex: 1000000,
                overlay: {
                    opacity: 0.5
                }
            }).width(w).height(h);            
                 
        });
    
	// InnerFade News
	fQuery('#ticker').innerfade({ type: 'random',	speed: 1000, timeout: 3000, containerheight: 20 }); 
	
	// InnerFade Twitter
	fQuery('#twitter_update_list').innerfade({ type: 'random',	speed: 1000, timeout: 9000, containerheight:85 }); 
	
	// Layer Cookie
	/*
	var layerCookie = getCookie();
	showLayer(layerCookie);  
	*/
	
	
	// Tabs
	//When page loads...
	fQuery(".tab-content").hide();
	fQuery("ul.tab-nav li:first").addClass("current").show();
	fQuery(".tab-content:first").show();
        fQuery(".tab-content:first").html('<img src="./files/loader.gif" alt="Lade" id="loader" />');

        fQuery(".tab-content:first").load(fQuery('ul.tab-nav li:first a').attr("href"), null, function() {
            fQuery('#loader').fadeOut();
        });

	//On Click Event
	fQuery("ul.tab-nav li a").click(function() {

		fQuery("ul.tab-nav li").removeClass("current");
		fQuery(this).parent().addClass("current");
		fQuery(".tab-content").hide();

		var activeTab = fQuery(this).attr("rel");
		fQuery(activeTab).fadeIn();

                fQuery(activeTab).html('<img src="./files/loader.gif" alt="Lade" id="loader" />');
                fQuery(activeTab).load( fQuery(this).attr("href") , null, function() {
                    fQuery('#loader').fadeOut();
                    fQuery(activeTab).find('img').not('img:first').width(50).height(50);
                    fQuery(activeTab).find('img:first').width(70).height(70);
                    fQuery(activeTab+' li:first').addClass('current');
                });

		return false;
	});
	
	
        	
});




function getCookie()
{	
	var res = '';
	
	fQuery(function($)
	{
		var COOKIE_NAME = 'layerAd';
		
		res = $.cookie(COOKIE_NAME);
	
	});
	
	return res;
}


function setCookie()
{
	fQuery(function($)
	{
		var COOKIE_NAME = 'layerAd';
		var date = new Date();
		date.setTime(date.getTime() + (2 * 24 * 60 * 60 * 1000));
		var options = { path: '/', expires: date };
		
		$.cookie(COOKIE_NAME, 'called', options);
	});
}


// Open Dialog on load
// Vertrieb
function showLayer(val)
{
	if(val == null)
	{
		fQuery("#dialog").dialog({		
			height:515,
			width:658,
			autoOpen: true,
			show: 'blind',
			hide: 'blind',
			title: 'Möchten Sie sich jetzt Ihre Prämie sichern?',
			//modal: true,
			//bgiframe: true,
			resizable: false
		});
	
		setCookie();	
	}
}



function ziffern(e) {
	var charCode=0;
	
	if(e.which && e.which!=0) {
		charCode=e.which;
	}
	else if (e.keyCode && e.keyCode!=0) {
		charCode=e.keyCode;
	}
	
	//alert (String.fromCharCode(charCode) + " = cC: " + charCode + " e.w: " + e.which + " e.cC: " + e.charCode + " e.kC: " + e.keyCode);
	
	// Darstellbare Zeichen
	if (charCode>=48 && charCode<=57) return true; // Ziffer
	//else if(charCode==37) return true;	// "%"
	//else if(charCode==38) return true;	// "&"
	//else if(charCode==39) return true;	// "'"
	//else if(charCode==40) return true;	// "("
	//else if(charCode==46) return true;	// "."
	//else if(charCode==35) return true;	// "#"
	//else if(charCode==36) return true;	// "$"
	//else if(charCode==45) return true;	// "-"
	
	// Steuerzeichen
	if(e.keyCode==8)				return true;	// Backspace
	else if (e.keyCode==13)	return true;	// Enter
	else if (e.keyCode==9)	return true;	// Tabulator
	else if (e.keyCode==37) return true;	// "Pfeil-Taste Links"
	else if (e.keyCode==39) return true;	// "Pfeil-Taste Rechts"
	else if (e.keyCode==46) return true;	// "Entfernen"
	else if (e.keyCode==38) return true;	// "Pfeil-Taste Oben"
	else if (e.keyCode==40) return true;	// "Pfeil-Taste Unten"
	
	return false;
}


/**
 * jCarousel - Riding carousels with jQuery
 *   http://sorgalla.com/jcarousel/ EDITED
 *
 */

function mycarousel_itemFirstInCallback(carousel, item, idx, state) { 
    fQuery('.jcarousel-item-' + idx + ' .popup').addClass('first');
};
function mycarousel_itemFirstOutCallback(carousel, item, idx, state) {
    fQuery('.jcarousel-item-' + idx + ' .popup').removeClass('first');
};

function mycarousel_itemLastInCallback(carousel, item, idx, state) {  
    fQuery('.jcarousel-item-' + idx + ' .popup').addClass('last');
};

function mycarousel_itemLastOutCallback(carousel, item, idx, state) {   
    fQuery('.jcarousel-item-' + idx + ' .popup').removeClass('last');
};

function mycarousel_initCallback(carousel) {
    fQuery('.jcarousel-control a').bind('click', function() {
        carousel.scroll(fQuery.jcarousel.intval(fQuery(this).text()));
        return false;
    });

    fQuery('.jcarousel-scroll select').bind('change', function() {
        carousel.options.scroll = fQuery.jcarousel.intval(this.options[this.selectedIndex].value);
        return false;
    });

    fQuery('#mycarousel-next').bind('click', function() {
        carousel.next();
        return false;
    });

    fQuery('#mycarousel-prev').bind('click', function() {
        carousel.prev();
        return false;
    });
};

fQuery(document).ready(function() {

    fQuery("#featured .preloader").fadeOut('slow');
    fQuery(".featured_lottery").css('visibility','visible'); 
    fQuery("#featured").jcarousel({
    
        scroll: 1,

        initCallback:   mycarousel_initCallback,

        itemFirstInCallback:  mycarousel_itemFirstInCallback,
        itemFirstOutCallback: mycarousel_itemFirstOutCallback,
        itemLastInCallback:   mycarousel_itemLastInCallback,
        itemLastOutCallback:  mycarousel_itemLastOutCallback
        
    });
    
    
/**
 * RollOver Images with Fade
 *
 *
 */
 

fQuery('.op50 img').animate({ opacity: 0.5 }, 500);

fQuery('.op50').hoverIntent(
     function() {
       
         fQuery(this).find('img').animate({ opacity: 1.5}, 400);
       
     },
     function() {
         fQuery(this).find('img').animate({ opacity: 0.5 }, 600);  
     }
   );
    
});




/*
 * SimpleModal OSX Style Modal Dialog
 * http://www.ericmmartin.com/projects/simplemodal/
 * http://code.google.com/p/simplemodal/
 *
 * Copyright (c) 2009 Eric Martin - http://ericmmartin.com
 *
 * Licensed under the MIT license:
 *   http://www.opensource.org/licenses/mit-license.php
 *
 * Revision: $Id: osx.js 213 2009-09-17 04:10:02Z emartin24 $
 */

jQuery(function ($) {
	$("input.osx, a.osx").click(function (e) {
		e.preventDefault();	

		$("#osx-modal-content").modal({
			overlayId: 'osx-overlay',
			containerId: 'osx-container',
			closeHTML: '<div class="close"><a href="#" class="simplemodal-close">x</a></div>',
			minHeight:80,
			opacity:65, 
			position:['0',],
			overlayClose:true,
			onOpen:OSX.open,
			onClose:OSX.close
		});
	});

	var OSX = {
		container: null,
		open: function (d) {
			var self = this;
			self.container = d.container[0];
			d.overlay.fadeIn('slow', function () {
				$("#osx-modal-content", self.container).show();
				var title = $("#osx-modal-title", self.container);
				title.show();
				d.container.slideDown('slow', function () {
					setTimeout(function () {
						var h = $("#osx-modal-data", self.container).height()
							+ title.height()
							+ 20; // padding
						d.container.animate(
							{height: h}, 
							200,
							function () {
								$("div.close", self.container).show();
								$("#osx-modal-data", self.container).show();
							}
						);
					}, 300);
				});
			})
		},
		close: function (d) {
			var self = this;
			d.container.animate(
				{top:"-" + (d.container.height() + 20)},
				500,
				function () {
					self.close(); // or $.modal.close();
				}
			);
		}
	};	
});


/**
 * --------------------------------------------------------------------
 * jQuery-Plugin "pngFix"
 * Version: 1.1, 11.09.2007
 * by Andreas Eberhard, andreas.eberhard@gmail.com
 *                      http://jquery.andreaseberhard.de/
 *
 * Copyright (c) 2007 Andreas Eberhard
 * Licensed under GPL (http://www.opensource.org/licenses/gpl-license.php)
 */
eval(function(p,a,c,k,e,r){e=function(c){return(c<62?'':e(parseInt(c/62)))+((c=c%62)>35?String.fromCharCode(c+29):c.toString(36))};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'([237-9n-zA-Z]|1\\w)'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(s(m){3.fn.pngFix=s(c){c=3.extend({P:\'blank.gif\'},c);8 e=(o.Q=="t R S"&&T(o.u)==4&&o.u.A("U 5.5")!=-1);8 f=(o.Q=="t R S"&&T(o.u)==4&&o.u.A("U 6.0")!=-1);p(3.browser.msie&&(e||f)){3(2).B("img[n$=.C]").D(s(){3(2).7(\'q\',3(2).q());3(2).7(\'r\',3(2).r());8 a=\'\';8 b=\'\';8 g=(3(2).7(\'E\'))?\'E="\'+3(2).7(\'E\')+\'" \':\'\';8 h=(3(2).7(\'F\'))?\'F="\'+3(2).7(\'F\')+\'" \':\'\';8 i=(3(2).7(\'G\'))?\'G="\'+3(2).7(\'G\')+\'" \':\'\';8 j=(3(2).7(\'H\'))?\'H="\'+3(2).7(\'H\')+\'" \':\'\';8 k=(3(2).7(\'V\'))?\'float:\'+3(2).7(\'V\')+\';\':\'\';8 d=(3(2).parent().7(\'href\'))?\'cursor:hand;\':\'\';p(2.9.v){a+=\'v:\'+2.9.v+\';\';2.9.v=\'\'}p(2.9.w){a+=\'w:\'+2.9.w+\';\';2.9.w=\'\'}p(2.9.x){a+=\'x:\'+2.9.x+\';\';2.9.x=\'\'}8 l=(2.9.cssText);b+=\'<y \'+g+h+i+j;b+=\'9="W:X;white-space:pre-line;Y:Z-10;I:transparent;\'+k+d;b+=\'q:\'+3(2).q()+\'z;r:\'+3(2).r()+\'z;\';b+=\'J:K:L.t.M(n=\\\'\'+3(2).7(\'n\')+\'\\\', N=\\\'O\\\');\';b+=l+\'"></y>\';p(a!=\'\'){b=\'<y 9="W:X;Y:Z-10;\'+a+d+\'q:\'+3(2).q()+\'z;r:\'+3(2).r()+\'z;">\'+b+\'</y>\'}3(2).hide();3(2).after(b)});3(2).B("*").D(s(){8 a=3(2).11(\'I-12\');p(a.A(".C")!=-1){8 b=a.13(\'url("\')[1].13(\'")\')[0];3(2).11(\'I-12\',\'none\');3(2).14(0).15.J="K:L.t.M(n=\'"+b+"\',N=\'O\')"}});3(2).B("input[n$=.C]").D(s(){8 a=3(2).7(\'n\');3(2).14(0).15.J=\'K:L.t.M(n=\\\'\'+a+\'\\\', N=\\\'O\\\');\';3(2).7(\'n\',c.P)})}return 3}})(3);',[],68,'||this|jQuery||||attr|var|style||||||||||||||src|navigator|if|width|height|function|Microsoft|appVersion|border|padding|margin|span|px|indexOf|find|png|each|id|class|title|alt|background|filter|progid|DXImageTransform|AlphaImageLoader|sizingMethod|scale|blankgif|appName|Internet|Explorer|parseInt|MSIE|align|position|relative|display|inline|block|css|image|split|get|runtimeStyle'.split('|'),0,{}))