//var quickSearch = 'Suchbegriff z.B. klassik';

function clearQuicki() {
 if (document.search.name.value==document.search.name.defaultValue) document.search.name.value='';
}

function disclaimer() { //v2.0
  window.open('/Html/disclaimer.html','','width=730,height=440, scrollbars=yes');
}

function checkQuicki() {
	with (document.search)
	{
       if (rubriken.options.selectedIndex==0)
       {
        alert ("Bitte wählen Sie eine Rubrik aus,\nin welcher gesucht werden soll.");
        rubriken.focus();
        document.returnValue = false;
        return;
       }

       prescribe.value = name.defaultValue;
	}

 document.returnValue = true;
 return;
}

function checkOrder()
{
    with (document.order)
    {
        if (lastname.value=='')
        {
            alert ("Tragen Sie bitte Ihren Nachnamen ein.");
            lastname.focus();
            document.returnValue = false;
	        return;
        }

       if (street.value=='')
       {
            alert ("Tragen Sie bitte die Straße ein.");
            street.focus();
            document.returnValue = false;
            return;
       }
       
       if (zip.value=='')
       {
            alert ("Tragen Sie bitte die PLZ ein.");
            zip.focus();
            document.returnValue = false;
            return;
       }
       
       if (city.value=='')
       {
            alert ("Tragen Sie bitte den Ort ein.");
            city.focus();
            document.returnValue = false;
            return;
       }


       if (mail.value=='')
       {
            alert ("Tragen Sie bitte Ihre E-Mail-Adresse ein.");
            mail.focus();
            document.returnValue = false;
            return;
       }

       if (mail.value.search(/\@.+\./) <= 1)
       {
            alert("Die E-Mail Adresse ist nicht korrekt!")
            mail.select();
            document.returnValue = false;
            return;
       }

       document.returnValue = true;
       return;
    }
}

function setStyle(cssFile)
{
    document.getElementById("elydiastyle").removeAttribute("href");
    document.getElementById("elydiastyle").setAttribute("href", '/Styles/' +  cssFile);
}

function getStyle() {
  var cssPath = document.getElementById("elydiastyle").getAttribute("href");
  return cssPath.substring(cssPath.lastIndexOf('/') + 1);
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  
  return null;
}

function initSwitch()
{
  var cookie = readCookie("elydia-style");
  var cssFile = document.cookie ? cookie : 'portal2.css';
  setStyle(cssFile);
}

 window.onunload = function(e) {
  var cssFile = getStyle();
  createCookie("elydia-style", cssFile, 365);
}

