function language_switcher_dropdown()
{	
	$value = $('#language').val();
	$('.switchsubmit').remove();
	$('#language').css({opacity:"0", position:"relative"});
	$('#language').before("<span class='dropdown'>"+$value+"</span>");


	var current_domain = (window.location.href).match(/^http:\/\/.+\.toolani\.(de|com)/);
	$("#language").bind("change",function()
	{	
		var goto = $("#language").val();
		$("#head .dropdown").html($("#language option:selected").html());
		
		if(current_domain[1] != goto && goto != "Language" && goto != "Sprache" )
		{
			
			goto = current_domain[0].match(/^http:\/\/.+\.toolani\./) + goto  + "/";
			window.location.href = goto;
		}
	})
}
	
	
function site_improvements(){
	$(".error_msg").bind("mouseover",function(){$(this).fadeOut(400);});
	
	$("body").append("<span class='preload'></span>");

	if($(".breadcrumb_heading").length > 0){
		 var replace_breadcrumb = $(".breadcrumb_heading").html();
		 $(".current_crumb").html(replace_breadcrumb);
		 
		}
		
	$(".flatscreen").removeClass('changescreen');
	$image = $(".flatscreen").css("backgroundImage");
	$(".flatscreen a").css({opacity:0,backgroundImage: $image, backgroundPosition:"left bottom"}).hover(function(){
				$(this).animate({opacity: 1},400);
		},function(){
				$(this).animate({opacity: 0},600);
		});	
	
	}



function teaser_tabs(){
	var pause;
	var tabs_links = $('#teaser .tabs li a');
	tabs_links.each(function(i){
				var j = 1 + i ;
				$(this).bind ("click",function(){
								if (!($(this).hasClass("active_tab"))){
								tabs_links.removeClass("active_tab");
								 $(this).addClass("active_tab");
								 $(".single_tab_content").css({display: "none", visibility:"visible"});
								 $("#single_tab"+j).fadeIn(600);
								}
								 return false;

								});
				});
	
	
	}
function java_login(){
	var language_switch = jQuery("meta[name=languageswitch]").attr('content').split("%");

	
	var js_login="<div class='java_login'><div class='js_content'><form class='js_login_form_new' method='post' action=''><fieldset><p><label><input type='text' size='20' id='Login' class='text_input_small' name='Login'/>"+language_switch[0]+"</label></p><p><label><input type='password' size='20' id='password' class='text_input_small' name='Password'/>"+language_switch[1]+"</label><input name='loginnew' type='hidden' value='true'/></p><p><input type='submit' size='16' id='send_js' value='"+language_switch[2]+"' name='Send'/></p></fieldset></form><a class='passwort_vergessen' href='"+language_switch[6]+"'>"+language_switch[3]+"</a></div></div>";
	
	if($(".login_js_error").length >= 1){
	$(".login_js_error").append('<span class="error_msg_js_panel">'+language_switch[4]+'</span>'+js_login);	
	$('.login_link a, .member_login a').addClass("login_link_remove");
	$('.error_msg_js_panel').fadeIn(1200);
		}else{
	$("#head").append(js_login);
		}	
	$('.login_link a, .member_login a').bind("click",function(){
															  
							if($(this).hasClass("login_link_remove")){
									$(".java_login").animate({height: "0px"},500,"easeOutQuart");
									$(".error_msg_js_panel, .sqlerror").fadeOut();
									$('.login_link a, .member_login a').removeClass("login_link_remove"); 
							}else{				  
									$(".java_login").animate({height: "130px"},1200,"easeOutBounce");
									$('.login_link a, .member_login a').addClass("login_link_remove");
									$(".js_login_form_new #Login").focus();
							}
							 return false;
					});
	}	
	
	


function my_smothscroll(){
jQuery('div:not(.reply)>a[href*=#], span a[href*=#]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
    && location.hostname == this.hostname) {
      var $target = jQuery(this.hash);
      $target = $target.length && $target
      || jQuery('[name=' + this.hash.slice(1) +']');
      if ($target.length) {
        var targetOffset = $target.offset().top;
        jQuery('html,body')
        .animate({scrollTop: targetOffset}, 1200, "easeOutQuart");
       return false;
      }
    }
  });
}


function topup_fade(){
	$('.input_topup_ec, .input_topup_cc, .input_topup_paypal, .input_topup_uw, .button_currency_euro, .button_currency_dollar, .input_topup_code, .button_tax_include, .button_tax_exclude').each(function(i){
            //.input_topup_paypal  -> aus der oberen liste rausgenommen solang paypal down ist
			$(this).hover(function(){
				$(this).animate({opacity: 0},400);
		},function(){
				$(this).animate({opacity: 1},400);
		});	
	});
}
    
	
/*  SMS Counter  for MA  */

// when textarea is filled with text, a counter runs down from 160 to indicate the end of the sms
function SMS_counter()
{
    // handler is saved into variable to prevent DOM search every call
    textarea = $('#sms_textarea');
    var max = $('#sms_counter').val();
	
    // textarea is bound to the following events
    textarea.bind("click keydown keyup focus change", change_number);
	
	function change_number()
        {
            // defining variables  max = count of maximum characters in one sms 
            // wert = amount of characters currently in textarea
            var wert;            
            
            // wert is defined by the maximum characters minus the characters in the textarea
            wert = max-textarea.val().length;
            
            // if wert below zero, prohibit any further input
            if (wert < 0)
            {
                textarea.val(textarea.val().substring(0,max));
                wert = max-textarea.val().length;
                $('#sms_counter').val(wert);
            }
            else
            {
                // if counter is above zero, allow input
                $('#sms_counter').val(wert);
            }
        }
}


/*  SMS Number adapt   */

function SMS_Number_adapt()
{

// when number is selected from select box, it is automatically written to the number field

// first hide the div containing the submit button
    $('#number_entry').html('');
    
// take the variable from the select box and on change write it to the number field
    //store the select box in variable "sms_select"
    sms_select = $('#sms_receiver_phonebook');
    
    // store the number field in variable "number_field"
    number_field = $('#sms_receiver_number');
    
    // bind event and action to sms_select
    sms_select.bind("change", function(){
            
            // store the value of the selected number in the select box into variable "number"
            number = sms_select.val();
            
            // write the number in the number field
            number_field.val(number);
    });
}


/*  Register Country Switch   */

function Country_number_adapt()
{
    // hide the hint text
    $("#noscript_hint").addClass("p_invisible");
    
    //save SELECT BOX into var
    country_select = $('.country_select');
    
    //save PREFIX_display and HIDDEN INPUT 'Prefix' into var (where number shut be written)
    phone_prefix_display = $('.prefix_display');
    phone_prefix = $('.Prefix');
    
    
    // binding change event to select box
    country_select.bind("change", function()
        {
            //get value of country_select
            country_select_value = $('.country_select option:selected').attr('title');
            //change value of PREFIX_display and HIDDEN INPUT 'Prefix'
            phone_prefix.val(country_select_value);
            phone_prefix_display.val(country_select_value);
            
        });
}


function free_sms_numberchange()
{
	var country_select = $('#free_sms_country');	
	var changevalueof = $('.sms_form_dialcode, .subtext span');
	
	country_select.bind("change", function()
        {
		
		country_select_value = $('#free_sms_country option:selected').attr('value');
		country_select_value = country_select_value.replace(/^00/, "+");
		changevalueof.html(country_select_value);
		});
}


		
		
function newsticker($interval)
{
	$newsticker = $('#newsticker');
	
	if($newsticker.length > 0)
	{
	$ticker = 0;
	
	 $('.tickerentry').not(':eq(0)').css({opacity:0})
	$rotate = setInterval('tickerchange()',$interval);
	
	
	
	}
}

function tickerchange()
{
	if($('.tickerentry').length > $ticker+1)
	{
		$ticker++;
	}
	else
	{
		$ticker = 0;	
	}
	
	
	$('.tickerentry').animate({opacity:0},400,function()
		 {
		 $(this).css({display:"none"});
		 $('.tickerentry:eq('+$ticker+')').css({display:"block"}).animate({opacity:1},100);
		 });
};


$(document).ready(function(){
		language_switcher_dropdown();
		topup_fade();
		my_smothscroll();
		java_login();
		teaser_tabs();
		site_improvements();
        SMS_counter();
        SMS_Number_adapt();
        Country_number_adapt();
		free_sms_numberchange();
		newsticker(5000);
});



















































/*
 * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/
 *
 * Uses the built in easing capabilities added In jQuery 1.1
 * to offer multiple easing options
 *
 * TERMS OF USE - jQuery Easing
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2008 George McGinley Smith
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
*/

// t: current time, b: begInnIng value, c: change In value, d: duration
jQuery.easing['jswing'] = jQuery.easing['swing'];

jQuery.extend( jQuery.easing,
{
	def: 'easeOutQuad',
	swing: function (x, t, b, c, d) {
		//alert(jQuery.easing.default);
		return jQuery.easing[jQuery.easing.def](x, t, b, c, d);
	},
	easeInQuad: function (x, t, b, c, d) {
		return c*(t/=d)*t + b;
	},
	easeOutQuad: function (x, t, b, c, d) {
		return -c *(t/=d)*(t-2) + b;
	},
	easeInOutQuad: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t + b;
		return -c/2 * ((--t)*(t-2) - 1) + b;
	},
	easeInCubic: function (x, t, b, c, d) {
		return c*(t/=d)*t*t + b;
	},
	easeOutCubic: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t + 1) + b;
	},
	easeInOutCubic: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t + b;
		return c/2*((t-=2)*t*t + 2) + b;
	},
	easeInQuart: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t + b;
	},
	easeOutQuart: function (x, t, b, c, d) {
		return -c * ((t=t/d-1)*t*t*t - 1) + b;
	},
	easeInOutQuart: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
		return -c/2 * ((t-=2)*t*t*t - 2) + b;
	},
	easeInQuint: function (x, t, b, c, d) {
		return c*(t/=d)*t*t*t*t + b;
	},
	easeOutQuint: function (x, t, b, c, d) {
		return c*((t=t/d-1)*t*t*t*t + 1) + b;
	},
	easeInOutQuint: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	},
	easeInSine: function (x, t, b, c, d) {
		return -c * Math.cos(t/d * (Math.PI/2)) + c + b;
	},
	easeOutSine: function (x, t, b, c, d) {
		return c * Math.sin(t/d * (Math.PI/2)) + b;
	},
	easeInOutSine: function (x, t, b, c, d) {
		return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b;
	},
	easeInExpo: function (x, t, b, c, d) {
		return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
	},
	easeOutExpo: function (x, t, b, c, d) {
		return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
	},
	easeInOutExpo: function (x, t, b, c, d) {
		if (t==0) return b;
		if (t==d) return b+c;
		if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b;
		return c/2 * (-Math.pow(2, -10 * --t) + 2) + b;
	},
	easeInCirc: function (x, t, b, c, d) {
		return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b;
	},
	easeOutCirc: function (x, t, b, c, d) {
		return c * Math.sqrt(1 - (t=t/d-1)*t) + b;
	},
	easeInOutCirc: function (x, t, b, c, d) {
		if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b;
		return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b;
	},
	easeInElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
	},
	easeOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d)==1) return b+c;  if (!p) p=d*.3;
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
	},
	easeInOutElastic: function (x, t, b, c, d) {
		var s=1.70158;var p=0;var a=c;
		if (t==0) return b;  if ((t/=d/2)==2) return b+c;  if (!p) p=d*(.3*1.5);
		if (a < Math.abs(c)) { a=c; var s=p/4; }
		else var s = p/(2*Math.PI) * Math.asin (c/a);
		if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
		return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
	},
	easeInBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*(t/=d)*t*((s+1)*t - s) + b;
	},
	easeOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158;
		return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
	},
	easeInOutBack: function (x, t, b, c, d, s) {
		if (s == undefined) s = 1.70158; 
		if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
		return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
	},
	easeInBounce: function (x, t, b, c, d) {
		return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b;
	},
	easeOutBounce: function (x, t, b, c, d) {
		if ((t/=d) < (1/2.75)) {
			return c*(7.5625*t*t) + b;
		} else if (t < (2/2.75)) {
			return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
		} else if (t < (2.5/2.75)) {
			return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
		} else {
			return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
		}
	},
	easeInOutBounce: function (x, t, b, c, d) {
		if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b;
		return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b;
	}
});

/*
 *
 * TERMS OF USE - EASING EQUATIONS
 * 
 * Open source under the BSD License. 
 * 
 * Copyright © 2001 Robert Penner
 * All rights reserved.
 * 
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 * 
 * Redistributions of source code must retain the above copyright notice, this list of 
 * conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright notice, this list 
 * of conditions and the following disclaimer in the documentation and/or other materials 
 * provided with the distribution.
 * 
 * Neither the name of the author nor the names of contributors may be used to endorse 
 * or promote products derived from this software without specific prior written permission.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
 *  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 *  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 
 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
 *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
 * OF THE POSSIBILITY OF SUCH DAMAGE. 
 *
 */