function hideproduct (id, interval) {
	$("#"+id).fadeOut(interval);
}

function clearText(thefield){
 if (thefield.defaultValue==thefield.value)
 thefield.value = ""
}

function restoreText(thefield) {
 if (thefield.value=="")
 thefield.value = thefield.defaultValue;
}

function OpenWin(file,height,width) {
        var weite = 555, hoehe = 480;
        if (width) {weite = width;}
        if (height) {hoehe = height;}
        window.open(file, 'loc', 'width='+weite+',height='+hoehe+',resizable=0,channelmode=0,dependent=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=1,status=0,toolbar=0');
}

function pausesliding () {
	$scroll.trigger( 'stop');
	document.getElementById('playpause_pause').style.display = 'none';
	document.getElementById('playpause_play').style.display = 'inline';
}

function playsliding () {
	$scroll.trigger( 'start');
	document.getElementById('playpause_pause').style.display = 'inline';
	document.getElementById('playpause_play').style.display = 'none';
}

HTTP_GET_VARS=new Array();
strGET=document.location.search.substr(1,document.location.search.length);
if(strGET!='')
    {
    gArr=strGET.split('&');
    for(i=0;i<gArr.length;++i)
        {
        v='';vArr=gArr[i].split('=');
        if(vArr.length>1){v=vArr[1];}
        HTTP_GET_VARS[unescape(vArr[0])]=unescape(v);
        }
    }

function GET(v)
{
	if(!HTTP_GET_VARS[v]){return 'undefined';}
	return HTTP_GET_VARS[v];
}

/*

if(vpn == ""){
	vpn = GET('vpn');	
}

*/


function parseCounter(count){
	var tage = parseInt(count.slice(count.indexOf("countdown=")+10, count.indexOf("&anzahl")));
	var name = count.slice(count.indexOf("&anzahl=")+8);
	
	if (tage > 1 && tage < 9) {
		$(".countdown").css("background", "url(fileadmin/ideamano/090201/ideamano_images/counter/back_counter.png) 0 0 no-repeat");
		switch(tage){
		case 1: $(".countdown .tage").css("background", "url(fileadmin/ideamano/090201/ideamano_images/counter/1.png) 0 0 no-repeat");
		break;
		case 2: $(".countdown .tage").css("background", "url(fileadmin/ideamano/090201/ideamano_images/counter/2.png) 0 0 no-repeat");
		break;
		case 3: $(".countdown .tage").css("background", "url(fileadmin/ideamano/090201/ideamano_images/counter/3.png) 0 0 no-repeat");
		break;
		case 4: $(".countdown .tage").css("background", "url(fileadmin/ideamano/090201/ideamano_images/counter/4.png) 0 0 no-repeat");
		break;
		case 5: $(".countdown .tage").css("background", "url(fileadmin/ideamano/090201/ideamano_images/counter/5.png) 0 0 no-repeat");
		break;
		case 6: $(".countdown .tage").css("background", "url(fileadmin/ideamano/090201/ideamano_images/counter/6.png) 0 0 no-repeat");
		break;
		case 7: $(".countdown .tage").css("background", "url(fileadmin/ideamano/090201/ideamano_images/counter/7.png) 0 0 no-repeat");
		break;
		case 8: $(".countdown .tage").css("background", "url(fileadmin/ideamano/090201/ideamano_images/counter/8.png) 0 0 no-repeat");
		break;
		case 9: $(".countdown .tage").css("background", "url(fileadmin/ideamano/090201/ideamano_images/counter/9.png) 0 0 no-repeat");
		break;
	}
	}
	if(tage == 1){
		$(".countdown").css("background", "url(fileadmin/ideamano/090201/ideamano_images/counter/back_counter_letzter.png) 0 0 no-repeat");
	}
	
	
	$(".countdown").slideDown(500).fadeOut(100).fadeIn(100);
}


function checkforvpn(csv){
	basiscs = csv.slice(csv.indexOf("&basis=")+7, csv.length);
	basics_arr= basiscs.split(',');
	
	fritz=csv.slice(csv.indexOf("fritz=")+6, csv.indexOf("&basis=")-1);
	fritz_arr=fritz.split(',');
	
	if ((','+fritz_arr.toString()+',').indexOf(','+vpn+',')!==-1 || vpn == 'undefined') {
		document.getElementById('promotion_state_1').innerHTML = document.getElementById('promotion_state_1_aktion').innerHTML;
		document.getElementById('produktaktion_basis_fritzbox').style.display = 'inline';
		document.getElementById('produktaktion_einsteiger_fritzbox').style.display = 'inline';
		document.getElementById('produktaktion_experten_fritzbox').style.display = 'inline';
		document.getElementById('pakete').style.background="url('fileadmin/ideamano/090201/ideamano_images/startseite/pakete_background_fritzaktion.png') no-repeat";
	}
	
	else if ((','+basics_arr.toString()+',').indexOf(','+vpn+',')!==-1){
		document.getElementById('promotion_state_1').innerHTML = document.getElementById('promotion_state_1_keineaktion').innerHTML;
		document.getElementById('produktaktion_basis_keineaktion').style.display = 'inline';
		document.getElementById('produktaktion_einsteiger_keineaktion').style.display = 'inline';
		document.getElementById('produktaktion_experten_keineaktion').style.display = 'inline';		
	}

	else {
		document.getElementById('promotion_state_1').innerHTML = document.getElementById('promotion_state_1_keineaktion').innerHTML;
		document.getElementById('produktaktion_basis_keineaktion').style.display = 'inline';
		document.getElementById('produktaktion_einsteiger_keineaktion').style.display = 'inline';
		document.getElementById('produktaktion_experten_keineaktion').style.display = 'inline';		
	}
}

// when the DOM is ready...
$(document).ready(function () {

$.get('/scripts/ice/vpns.txt', function(txt){
 checkforvpn(txt);
});

$.get('/scripts/ice/countdown.php', function(count){
	parseCounter(count);
});



$("#infobutton_basis img").hoverIntent( function () { $("#basisdetails").fadeIn("100") }, function () { $("#basisdetails").fadeOut("100") }); 
$("#infobutton_einsteiger img").hoverIntent( function () { $("#einsteigerdetails").fadeIn("100") }, function () { $("#einsteigerdetails").fadeOut("100") }); 
$("#infobutton_experten img").hoverIntent( function () { $("#expertendetails").fadeIn("100") }, function () { $("#expertendetails").fadeOut("100") }); 
$("#infobutton_kwk img").hoverIntent( function () { $("#kwkdetails").fadeIn("100") }, function () { $("#kwkdetails").fadeOut("100") }); 
$("#infobuttonlarge_basis img").hoverIntent( function () { $("#basisdetails").fadeIn("100") }, function () { $("#basisdetails").fadeOut("100") }); 
$("#infobuttonlarge_einsteiger img").hoverIntent( function () { $("#einsteigerdetails").fadeIn("100") }, function () { $("#einsteigerdetails").fadeOut("100") }); 
$("#infobuttonlarge_experten img").hoverIntent( function () { $("#expertendetails").fadeIn("100") }, function () { $("#expertendetails").fadeOut("100") }); 
$("#infobuttonlarge_kwk img").hoverIntent( function () { $("#kwkdetails").fadeIn("100") }, function () { $("#kwkdetails").fadeOut("100") }); 

hideproduct('basisdetails', 10);
hideproduct('einsteigerdetails', 10);
hideproduct('expertendetails', 10);
hideproduct('kwkdetails', 10);
hideproduct('overlaywhite', 2000);

var $panels = $('#slider .scrollContainer > div');
var $container = $('#slider .scrollContainer');

// if false, we'll float all the panels left and fix the width 
// of the container
var horizontal = true;

// float the panels left if we're going horizontal
if (horizontal) {
  $panels.css({
    'float' : 'left',
    'position' : 'relative' // IE fix to ensure overflow is hidden
  });
  
  // calculate a new width for the container (so it holds all panels)
  $container.css('width', $panels[0].offsetWidth * $panels.length);
}

// collect the scroll object, at the same time apply the hidden overflow
// to remove the default scrollbars that will appear
$scroll = $('#slider .scroll').css('overflow', 'hidden');

// apply our left + right buttons
$scroll
//  .before('<img class="scrollButtons left" src="images/startseite/teaser_pfeil_links.png" />')
//  .after('<img class="scrollButtons right" src="images/startseite/teaser_pfeil_rechts.png" />');

// handle nav selection
function selectNav() {
  $(this)
    .parents('table:first')
      .find('a')
        .removeClass('selected')
      .end()
    .end()
    .addClass('selected');
}

$('#slider .navigation').find('a').click(selectNav);

// go find the navigation link that has this target and select the nav
function trigger(data) {
  var el = $('#slider .navigation').find('a[href$="' + data.id + '"]').get(0);
  selectNav.call(el);
}

if (window.location.hash) {
  trigger({ id : window.location.hash.substr(1) });
} else {
  $('table.navigation a:first').click();
}

// offset is used to move to *exactly* the right place, since I'm using
// padding on my example, I need to subtract the amount of padding to
// the offset.  Try removing this to get a good idea of the effect
var offset = parseInt((horizontal ? 
  $container.css('paddingTop') : 
  $container.css('paddingLeft')) 
  || 0) * -1;


var scrollOptions = {
  target: $scroll, // the element that has the overflow
  
  // can be a selector which will be relative to the target
  items: $panels,
  
  navigation: '.navigation a',
  
  // selectors are NOT relative to document, i.e. make sure they're unique
  prev: 'img.left', 
  next: 'img.right',
  
  // allow the scroll effect to run both directions
  axis: 'x',
  
  onAfter: trigger, // our final callback
  offset: offset,
  
  // duration of the sliding effect
  duration: 500,
  interval: 20000,
	force: true,
	
  // easing - can be used with the easing plugin: 
  // http://gsgd.co.uk/sandbox/jquery/easing/
  easing: 'swing'

};

// apply serialScroll to the slider - we chose this plugin because it 
// supports// the indexed next and previous scroll along with hooking 
// in to our navigation.
$('#slider').serialScroll(scrollOptions);

// now apply localScroll to hook any other arbitrary links to trigger 
// the effect
$.localScroll(scrollOptions);

// finally, if the URL has a hash, move the slider in to position, 
// setting the duration to 1 because I don't want it to scroll in the
// very first page load.  We don't always need this, but it ensures
// the positioning is absolutely spot on when the pages loads.
scrollOptions.duration = 1;
$.localScroll.hash(scrollOptions);

});


/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);




