$(document).ready(function() {
  $("#textBox").hide();
  $("#clickMe").click(function() {
  $("#textBox").toggle();
  });
});

// Tabs für Detailseite
$(document).ready(function() {

        //When page loads...
        $(".tab_content").hide(); //Hide all content
        $("ul.tabs li:first").addClass("active").show(); //Activate first tab
        $(".tab_content:first").show(); //Show first tab content

        //On Click Event
        $("ul.tabs li").click(function() {

                $("ul.tabs li").removeClass("active"); //Remove any "active" class
                $(this).addClass("active"); //Add "active" class to selected tab
                $(".tab_content").hide(); //Hide all tab content

                var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
                $(activeTab).fadeIn(); //Fade in the active ID content
                return false;
        });

        $("ul.rattabs li").click(function() {

                $("ul.tabs li").removeClass("active"); //Remove any "active" class
                $(this).addClass("active"); //Add "active" class to selected tab
                $(".tab_content").hide(); //Hide all tab content

                var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
                $(activeTab).fadeIn(); //Fade in the active ID content
                return false;
        });

});

// Slider Karusell für Detailseite
$(document).ready(function() {
    // Initialise the first and second carousel by class selector.
        // Note that they use both the same configuration options (none in this case).
        jQuery('.first-and-second-carousel').jcarousel(
        {horizontal: true,
        scroll: 2
        });

        // If you want to use a caoursel with different configuration options,
        // you have to initialise it seperately.
        // We do it by an id selector here.
        jQuery('#third-carousel').jcarousel({
        vertical: true,
        scroll: 5
    });
});

/***********************************************
* Dynamic Countdown script- © Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

function cdtime(container, targetdate){
if (!document.getElementById || !document.getElementById(container)) return
this.container=document.getElementById(container)
this.currentTime=new Date()
this.targetdate=new Date(targetdate)
this.timesup=false
this.updateTime()
}

cdtime.prototype.updateTime=function(){
var thisobj=this
this.currentTime.setSeconds(this.currentTime.getSeconds()+1)
setTimeout(function(){thisobj.updateTime()}, 1000) //update time every second
}

cdtime.prototype.displaycountdown=function(baseunit, functionref){
this.baseunit=baseunit
this.formatresults=functionref
this.showresults()
}

cdtime.prototype.showresults=function(){
var thisobj=this


var timediff=(this.targetdate-this.currentTime)/1000 //difference btw target date and current date, in seconds
if (timediff<0){ //if time is up
this.timesup=true
this.container.innerHTML=this.formatresults()
return
}
var oneMinute=60 //minute unit in seconds
var oneHour=60*60 //hour unit in seconds
var oneDay=60*60*24 //day unit in seconds
var dayfield=Math.floor(timediff/oneDay)
var hourfield=Math.floor((timediff-dayfield*oneDay)/oneHour)
var minutefield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour)/oneMinute)
var secondfield=Math.floor((timediff-dayfield*oneDay-hourfield*oneHour-minutefield*oneMinute))
if (this.baseunit=="hours"){ //if base unit is hours, set "hourfield" to be topmost level
hourfield=dayfield*24+hourfield
dayfield="n/a"
}
else if (this.baseunit=="minutes"){ //if base unit is minutes, set "minutefield" to be topmost level
minutefield=dayfield*24*60+hourfield*60+minutefield
dayfield=hourfield="n/a"
}
else if (this.baseunit=="seconds"){ //if base unit is seconds, set "secondfield" to be topmost level
var secondfield=timediff
dayfield=hourfield=minutefield="n/a"
}
this.container.innerHTML=this.formatresults(dayfield, hourfield, minutefield, secondfield)
setTimeout(function(){thisobj.showresults()}, 1000) //update results every second
}

/////CUSTOM FORMAT OUTPUT FUNCTIONS BELOW//////////////////////////////

//Create your own custom format function to pass into cdtime.displaycountdown()
//Use arguments[0] to access "Days" left
//Use arguments[1] to access "Hours" left
//Use arguments[2] to access "Minutes" left
//Use arguments[3] to access "Seconds" left

//The values of these arguments may change depending on the "baseunit" parameter of cdtime.displaycountdown()
//For example, if "baseunit" is set to "hours", arguments[0] becomes meaningless and contains "n/a"
//For example, if "baseunit" is set to "minutes", arguments[0] and arguments[1] become meaningless etc


function formatresults(){
if (this.timesup==false){//if target date/time not yet met
var displaystring=arguments[0]+" days "+arguments[1]+" hours "+arguments[2]+" minutes "+arguments[3]+" seconds"
}
else{ //else if target date/time met
var displaystring="Future date is here!"
}
return displaystring
}

function formatresults2(){
if (this.timesup==false){ //if target date/time not yet met
var displaystring="<span class='lcdstyle'> "+arguments[1]+" <sup>Std.</sup> "+arguments[2]+" <sup>Min.</sup> "+arguments[3]+" <sup>Sek.</sup></span>"
}
else{ //else if target date/time met
var displaystring="abgelaufen" //Don't display any text
}
return displaystring
}

function formatresults3(){
if (this.timesup==false){//if target date/time not yet met
var displaystring=arguments[0]+" Tage "
}
else{ //else if target date/time met
var displaystring="Frohe Weihnachten w_5F25FCnscht ToyOne.de"
}
return displaystring
}

//Script für Dropdown bei den Filtern

$(document).ready(function(){
     $('.navi-point-filter').hover(
         function () {
             $('.sub-navi-filter',this).slideDown(300);
         },
         function () {
             $('.sub-navi-filter',this).slideUp(300);
         }
     );
 });

// Button Änderung auf Order.tpl
function submitForm(s) {
s.value = "Bestellung wird gesendet";
return true;
}

// Show und Hide für Warenkorbfunktion - alt
function showhide() {
  if (document.getElementById("mydiv").className = "mydivHide") {
    document.getElementById("mydiv").className = "mydivShow";
  } else {
    document.getElementById("mydiv").className = "mydivHide";
  }
}

function showhide2() {
  if (document.getElementById("mydiv2").className = "mydiv2Hide") {
    document.getElementById("mydiv2").className = "mydiv2Show";
  } else {
    document.getElementById("mydiv2").className = "mydiv2Hide";
  }
}

 function anzeigen(das){
 if(document.getElementById(das).style.display=='none')
 document.getElementById(das).style.display='block';
 else document.getElementById(das).style.display='none';}

 //Firma und UST-ID Felder ausblenden in user.tpl
  function ReloadAdress()
  {
    if( document.order.oxaddressid.value != -1){
      document.order.fnc.value    = "";
      document.order.cl.value     = "user";
      document.order.submit();
    }
    // clearing fields
    else
    {   oRoot = document.order.elements;

            // default inputs
            aFields = new Array("deladr[oxaddress__oxfname]",
                                                    "deladr[oxaddress__oxlname]",
                                                    "deladr[oxaddress__oxcompany]",
                                                    "deladr[oxaddress__oxstreet]",
                                                    "deladr[oxaddress__oxstreetnr]",
                                                    "deladr[oxaddress__oxzip]",
                                                    "deladr[oxaddress__oxcity]",
                                                    "deladr[oxaddress__oxaddinfo]",
                                                    "deladr[oxaddress__oxfon]",
                                                    "deladr[oxaddress__oxfax]"
                               );
                for (i=0;i<aFields.length;i++)
                {   if ( oRoot.namedItem(aFields[i]) != null)
                    oRoot.namedItem(aFields[i]).value = "";
            }

            // select lists
            aFields = new Array("deladr[oxaddress__oxcountryid]",
                                                    "deladr[oxaddress__oxsal]"
                               );
                for (i=0;i<aFields.length;i++)
                {   if ( oRoot.namedItem(aFields[i]) != null )
                    oRoot.namedItem(aFields[i]).options.item(0).selected = true;
            }
    }
}

function select_sal( val)
{
        obj = document.getElementById( 'company');

        if ( obj)
        {
                if ( val)
                {
                        obj.style.visibility = "";
                }
                else
                {
                        obj.style.visibility = "hidden";
                }
        }

        check_country();
}

function check_country()
{
        obj = document.getElementById( 'country_id');

        if ( obj)
        {
                if ( obj.value != 'a7c40f631fc920687.20179984')
                {
                        obj = document.getElementById( 'company');

                        if ( obj && obj.style.visibility == "")
                        {
                                obj = document.getElementById( 'ustid');

                                if ( obj)
                                {
                                        obj.style.display = '';

                                        return;
                                }
                        }
                }
        }

        obj = document.getElementById( 'ustid');

        if ( obj)
        {
                obj.style.display = 'none';
        }
}

// Superfisch Menü-Einstellungen
$(document).ready(function() {
        $('ul.sf-menu').superfish({
            delay:       600,                            // one second delay on mouseout
            animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation
            speed:       'fast',                          // faster animation speed
            autoArrows:  false,                           // disable generation of arrow mark-up
            dropShadows: true                            // disable drop shadows
        });
    });

    $(document).ready(function() {
        $('ul.sf-menu2').superfish({
            delay:       200,                            // one second delay on mouseout
            animation:   {opacity:'show',height:'show'},  // fade-in and slide-down animation
            speed:       'fast',                          // faster animation speed
            autoArrows:  false,                           // disable generation of arrow mark-up
            dropShadows: true                            // disable drop shadows
        });
    });

// Select-Boxen Einstellungen auf list.tpl
$(document).ready(function(){

                $('#my-dropdown1, #my-dropdown2, #my-dropdown3, #my-dropdown4, #my-dropdown5, #my-dropdown6').sSelect({ddMaxHeight: '300px'});

                //set max height
                $('#my-dropdownCountries').sSelect({ddMaxHeight: '300px'});

        });