function evendogo(Sd,Sh)
{
        if (top.frames.lenght > 0)
        {
                if (top.frameset_load != Sd ) top.location.href = "e-vendo.php?shop=" + Sh ;
        }
}
function evendoStart(SessionId, Shop)
{
        if (top == window)
        {
                top.location.href = "e-vendo.php?shop=" + Shop + "&SessionId=" + SessionId + "&url=" + encodeURIComponent(location.href);
        }
}
function separatWindow(windowurl, w, h)
{
        newWindow = window.open(windowurl, "", "resizable=yes,scrollbars=yes,status=no,toolbar=no,menubar=no,left=0,right=0,top=0,width=" + w + ",height=" + h );
}
function helpFenster(x)
{
        FensterHilfe=window.open(x,"Hilfe","width=500,height=500,screenX=100,screenY=100,scrollbars");
        FensterHilfe.focus();
}
function DoNo()
{
}
function SubmitOk(txt)
{
        Check = confirm(txt);
        if (Check)
                document.eingabe.submit();
}
function istzahl(s)
{
        for (i=0; i < s.length; i++)
        {
                c=s.charAt(i);
                if (!(c >='0' && c <='9'))
                        return false;
        }
        return true;
}
altindex=1;
altwert=1;
function check_eingabe(item,max)
{
        var returnwert = false
        if (parseInt(item.value) < 0)
                alert("Please enter a positive integer" )
        else if (parseInt(item.value) > max)
                alert("Please enter a figure which isn't higher than " + max + ".")
        else if (!istzahl(item.value))
                alert("Please enter only numerals in the boxes for the item quantity.\n (Your entry was '" + item.value + "'.)")
        else
                returnwert = true

        if (!returnwert)
        {
                item.value=altwert;
                item.focus();
        }
        return returnwert
}
function check_eingabe_k1(item, max)
{
        var bReturn;
        var fNumber;
        var fNewNumber;
        var sValue;

        bReturn = true;

        sValue = item.value;
        item.value = sValue.replace(/,/, ".");
        fNumber = parseFloat(item.value);
        if (fNumber == NaN)
        {
                alert("Please enter only numerals in the box for stating the quantity.\nTo input a quantity as a non-integer use a dot as decimal separator.\n(Your entry was '"+item.value+"'.)");
                item.value = '';
                item.focus();
                bReturn = false;
        }
        else
        {
                if (fNumber < 0)
                        fNumber = (-1) * fNumber;
                if (fNumber > max)
                {
                        alert("Please enter a figure which isn't higher than " + max + ".");
                        item.focus();
                        bReturn = false;
                }
                else
                {
                        fNewNumber = fNumber * 10;
                        fNumber = Math.round(fNewNumber);
                        fNewNumber = fNumber / 10;
                        item.value = String(fNewNumber);
                }
        }
        return bReturn;
}
function emailCheck (emailStr)
{
        var emailPat=/^(.+)@(.+)$/
        var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
        var validChars="\[^\\s" + specialChars + "\]"
        var quotedUser="(\"[^\"]*\")"
        var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
        var atom=validChars + '+'
        var word="(" + atom + "|" + quotedUser + ")"
        var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
        var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
        var matchArray=emailStr.match(emailPat)
        var errStr='Enter a valid email address!'
        if (matchArray==null)
        {
                alert(errStr)
                return false
        }
        var user=matchArray[1]
        var domain=matchArray[2]
        if (user.match(userPat)==null)
        {
                alert(errStr)
                return false
        }
        var IPArray=domain.match(ipDomainPat)
        if (IPArray!=null)
        {
                for (var i=1;i<=4;i++)
                {
                        if (IPArray[i]>255)
                        {
                                alert(errStr)
                                return false
                        }
                }
                return true
        }
        var domainArray=domain.match(domainPat)
        if (domainArray==null)
        {
                alert(errStr)
                return false
        }
        var atomPat=new RegExp(atom,"g")
        var domArr=domain.match(atomPat)
        var len=domArr.length
        if (domArr[domArr.length-1].length<2 || domArr[domArr.length-1].length>4)
        {
                alert(errStr)
                return false
        }
        if (len<2)
        {
                alert(errStr)
                return false
        }
        return true;
}
function such_nosql(str)
{
        /* var nosql = /[\x7F]/g; */
        /* var nosql = /[\x7F]/g; */
        var nosql7f, nosql7;

        nosql = /[\x7F]/g;
        nosql7f = nosql.exec(str);
        nosql = /[7]/g;
        nosql7 = nosql.exec(str);

        if (nosql7f > nosql7)
                return true;
        else
                return false;

        /* return nosql.test(str); */
}
function check_feld(feld)
{
        index = altindex;
        if (such_nosql(feld))
        {
                alert("Value is not allowed. Please re-enter value.");
                document.eingabe[index].focus();
                document.eingabe[index].value = "";
                return false;
        }
        else
        {
                return true;
        }
        alert("Missing value!");
        return false;
}
function check_fastorder(feld)
{
        index = altindex;
        if (such_nosql(feld))
        {
                alert("Entry contains an error. Please re-enter value.");
                document.fastorder[index].focus();
                document.fastorder[index].value = "";
                return false;
        }
        else
        {
                return true;
        }
        alert("Data missing");
}
function evendoload(So)
{
        if (navigator.appName.indexOf("Netscape") != -1)
                document.writeln('<link rel="stylesheet" type ="text/css" href="'+ So +'/ablage/formate_ns.css">')
        else
                document.writeln('<link rel="stylesheet" type="text/css" href="'+ So +'/ablage/formate.css">');
}
function oWin(url,title,sizeH,sizeV)
{
        winHandle = top.open(url,title,'toolbar=no,directories=no,status=yes,scrollbars=yes,menubar=no,resizable=no,width='+sizeH+',height='+sizeV);
        if(navigator.appVersion.indexOf("MSIE 3",0)==-1) id = setTimeout('winHandle.focus()',1000);
}
function goTo(location)
{
        if (location != "")
                document.location.href = location;
}

function highlightRecentTheme() {
  var content = '';
  var ids = array('t34t3','t35t3','t36t3','t37t3','t38t3','t39t3','t40t3','t41t3','t42t3','t43t3','t44t3','t45t3','t46t3','t48t3','t49t3','t50t3','t51t3','t52t3','t53t3','t75t3','t77t3','t78t3','t79t3','t80t3','t82t3','t29855t3','t29856t3');

    for ( var i = 0; i < ids.length; i++ ) {
      content = document.getElementsByTagName ('td')[ids[i]];
      alert(content.data);
        if ( content.data.strpos('<span') != -1 ) {
          content.style.backgroundImage.src = '../nav/fabfab/navi/content_3_over.gif';
          alert(content.data);
        }
    }


}

function mnuHighLow(mnuItem, Highlight)
{

        var zelle = 0;
        var zelleItem = '';
        var image = '';
        var image_name = '';
        var image_appendix = '';

        if ( mnuItem == 't30' || mnuItem == 't31' || mnuItem == 't32' )
          image_name = 'head';
        else
          image_name = 'content';

        if ( Highlight )
          image_appendix = '_over';
        else
          image_appendix = '';

        image = 'url(fabfab_e/nav/fabfab/navi/'+image_name+'_3'+image_appendix+'.gif)';
//        alert(image);

        // Head von Kästen und aktuelle Markierung nicht ersetzen
        if ( mnuItem != 't30' && mnuItem != 't31' && mnuItem != 't32' && document.getElementById(mnuItem+"t3").parentNode.style.textAlign != 'left' ) {
          document.getElementById(mnuItem+"t3").style.backgroundImage = image;
//          alert(image);
        }


//          document.getElementById(mnuItem+'t3').style.backgroundImage = image;

//          var bgi = document.getElementsByTagName("td")[mnuItem+'t3'].style.getAttribute('backgroundImage','true');
//          alert(bgi);
//          alert('OK');

//          document.all.mnuItem+'t3'+..style.backgroundImage = image;
//       alert(document.getElementById(mnuItem+'t3').style);

/*
        if (document.all)
        {

                while ( (zelleItem = eval ('document.all.' + mnuItem + 't' + zelle) )  )
                {
                    if ( zelle > 0 ) {
                        image = 'nav/fabfab/navi/'+image_name+'_'+zelle+image_appendix+'.gif';
                        zelleItem.style.backgroundImage = image;
                    }
                        zelle++;
                }
        }
        else
                if (document.body)
                {
                        zelleItem = document.getElementsByTagName ('td')[mnuItem + 't' + zelle];
                        while ( zelleItem  )
                        {
                            if ( zelle > 0 ) {
                                image = 'nav/fabfab/navi/'+image_name+'_'+zelle+image_appendix+'.gif';
                                zelleItem.style.backgroundImage = image;
                            }
                                zelle++;
                                zelleItem = document.getElementsByTagName ('td')[mnuItem + 't' + zelle];
                        }
                }
*/
}


function checkAnmeldenS()
{
        if (document.anmeldenFormS.NewCustLoginname.value == "")
        {
                alert("Enter your login name!");
                document.anmeldenFormS.NewCustLoginname.focus();
                return false;
        }
        if (document.anmeldenFormS.kennwort.value == "")
        {
                alert("Enter your password!");
                document.anmeldenForm.kennwort.focus();
                return false;
        }
        check_feld(document.anmeldenFormS.NewCustLoginname.value);
        check_feld(document.anmeldenFormS.kennwort.value);
        if (document.anmeldenFormS.kennwort.value != "")
                return true;
        else
                return false;
}
function ShowAktiv(tabpath, bildid)
{
  var imgobj;

  imgobj = document.getElementById(bildid);
  if (((typeof imgobj) == 'object') && (imgobj != null))
    imgobj.src = tabpath + imgobj.id + '_a.gif';
}
function ChangeAktiv(bildid)
{
  ShowAktivInDoc(bildid);
}
function checkSuche_Klein()
{
        check_feld(document.suche_klein.SearchStr.value);
        if (document.suche_klein.SearchStr.value.length < 3)
        {
                alert("Please enter first a search term consisting of at least three characters!");
                return false;
        }
        return true;
}

function showCart(shop, SessionId, cart_pos, cart_sum, cart_sumwkz)
{

        if (cart_pos != '')
        {
                document.write(cart_pos + ' m/Piece(s)<br /><img src="' + shop + '/nav/pixel.gif" width="1" height="4" alt="" border="0" /><br />');
                document.write(cart_sum + ' ' + cart_sumwkz);
        }
        else
        {
                document.write('Your shopping cart<br />contains nothing yet.');
        }

}

function completeURLSession(url, SessionId)
{
  var gourl, lastSessionId, matchResult, startSessionId, restSessionId, startAmpersand, lastChar;

  gourl = '';
  // haben wir eine verwertbare SessionId jetzt?
  // und haben wir eine verwertbare letzte URL?
  if ((SessionId != '') && url.length)
  {
    bReady = false;
    lastSessionId = '';

    // ist in der letzten URL irgendwas von SessionId?
    startSessionId = url.search('SessionId=');
    if (startSessionId != -1)
    {
      // kommt nach der SessionId noch ein weiterer Parameter?
      restSessionId = url.substr(startSessionId);
      startAmpersand = restSessionId.search('&');
      if (startAmpersand != -1)
      {
        if (startAmpersand != 1)
        {
          // die SessionId ist leer
        }
        else
        {
          // da kommt noch einer oder noch weitere Parameter hinzu
          matchResult = restSessionId.match(/=(.+)&/);
          if (matchResult != '')
          {
            lastSessionId = RegExp.$1;
          }
        }
      }
      else
      {
        // also, die SessionId ist der letzte Parameter

        // welchen Wert hat denn die bisherige SessionId?
        matchResult = restSessionId.match(/=(.+)/);
        if (matchResult != '')
        {
          lastSessionId = RegExp.$1;
        }
      }
      // unterscheidet sich die bisherige von der neuen SessionId?
      if (lastSessionId != SessionId)
      {
        urlpart1 = url.substring(0, startSessionId);
        urlpart2 = 'SessionId=' + SessionId;
        urlpart3 = '';

        if (startAmpersand != -1)
        {
          urlpart3 = restSessionId.substring(startAmpersand);
        }

        gourl = urlpart1 + urlpart2 + urlpart3;
      }
    }
    else
    {
      // in der letzten URL steht nix von irgendeiner SessionId
      // also muessen wir da eine anhaengen
      alert(url);
      lastChar = url.charAt(url.length);
      if (lastChar == '/')
      {
        // es endet mit /, also sollten wir irgendwas gescheites mit anhaengen
        gourl = url + 'e-vendo.php?SessionId=' + SessionId;
      }
      else
      {
        if ((lastChar == '?') || (lastChar == '&'))
        {
          gourl = url + 'SessionId=' + SessionId;
        }
        else
        {
            // also, es endet nicht mit /, nicht mit ? und nicht mit &

            // gibt es irgendwo ein Fragezeichen?
            if (url.search(/\?/) != -1)
            {
              // also ein Fragezeichen gibt es schon
              gourl = url + '&';
            }
            else
            {
              // es gibt noch kein Fragezeichen im String
              gourl = url + '?';
            }

            // dann haengen wir einfach die SessionId mit ran
            gourl = gourl + 'SessionId=' + SessionId;
        }
      }
    }
  }
  return gourl;
}
function goback(SessionId)
{
  history.back();
  /*
  var lasturl, gourl;

  lasturl = document.referrer;

  // haben wir eine verwertbare SessionId jetzt?
  // und haben wir eine verwertbare letzte URL?
  if ((SessionId != '') && lasturl.length)
  {
    gourl = completeURLSession(lasturl, SessionId);
    if (gourl != '')
      location.replace(gourl);
    else
      history.back();
  }
  else
  {
    // keine SessionId oder keine verwertbare letzte URL, also einfach nur ein Zurueck in der History
    history.back();
  }
  */
}
function gobackreload(SessionId)
{
  history.back();
  /*
  var lasturl, gourl;

  lasturl = document.referrer;

  // haben wir eine verwertbare SessionId jetzt?
  // und haben wir eine verwertbare letzte URL?
  if ((SessionId != '') && lasturl.length)
  {
    gourl = completeURLSession(lasturl, SessionId);
    if (gourl != '')
      location.replace(gourl);
    else
      location.replace(lasturl);
  }
  else
  {
    // keine SessionId oder keine verwertbare letzte URL, also einfach nur ein Zurueck in der History
    history.back();
  }
  */
}
function topreload(SessionId)
{
}
function oframesreload(SessionId)
{
  otopreload(SessionId);
}
function otopreload(SessionId)
{
  var lasturl, newurl;

  lasturl = opener.location.href;
  newurl = completeURLSession(lasturl, SessionId);
  if (newurl != '')
    opener.location.replace(newurl);
  else
    opener.location.reload();
}

// Schnellsuche leeren
function emptyQuickSearchField() {
//  document.search_word_inc.query.value = '';
//  document.search_word_inc.query.focus();
  document.suche_klein.SearchStr.value = '';
  document.suche_klein.SearchStr.focus();
}

// Suche initiieren, da direkt über FACT Finder nicht möglich
function startSearch() {
  document.suche_klein.SearchStr.value = document.search_word_inc.query.value;
  document.suche_klein.submit();
}

// Hilfe
function openHelp(){
  var seite=(screen.availWidth-650)/2;
  var oben=(screen.availHeight-600)/2;
  fenster=window.open('http://shops.fabfab.net/apps/help.php?lang=en','Help','width=650,height=600,toolbar=no,scrollbars=yes,menubar=no,left='+seite+',top='+oben+'');
}

// Legende für Pflegehinweise
function openCareDetails(){
  var seite=0;
  var oben=0;
  fenster=window.open('http://shops.fabfab.net/apps/care_pointers_legend.php?lang=en','CarePointersLegend','width=540,height=600,toolbar=no,menubar=no,left='+seite+',top='+oben+'');
}

// Popup Images
function openPopup(image,name,size){
  var seite=(screen.availWidth-700)/2;
  var oben=(screen.availHeight-750)/2;
  fenster=window.open('http://shops.fabfab.net/apps/popup_images.php?image='+image+'&name='+name+'&size='+size+'&lang=en','DetailedView','width=700,height=750,toolbar=no,menubar=no,left='+seite+',top='+oben+'');
}

// Maßtabellen Schnittmuster
function openSizeTablePopup(table,name){
  var seite=(screen.availWidth-800)/2;
  var oben=(screen.availHeight-600)/2;
  fenster=window.open('http://shops.fabfab.net/apps/size_measurement_tables.php?table='+table+'&name='+name+'&lang=en','MassTabelle','width=800,height=600,toolbar=no,menubar=no,left='+seite+',top='+oben+'');
}

// Schnitmuster-Popups
function openPatternPopup(model,name,dump){
  var seite=(screen.availWidth-800)/2;
  var oben=(screen.availHeight-670)/2;
  fenster=window.open('http://shops.fabfab.net/apps/pattern_popups.php?model='+model+'&name='+name+'&lang=en','DetailedPatternView','width=800,height=670,toolbar=no,menubar=no,left='+seite+',top='+oben+'');
}

// Deco-Popups
function openDecoImage(image,name){
  var seite=(screen.availWidth-800)/2;
  var oben=(screen.availHeight-550)/2;
  fenster=window.open('http://shops.fabfab.net/apps/deco_image.php?image='+image+'&name='+name+'&lang=en','DecoExample','width=800,height=550,toolbar=no,menubar=no,left='+seite+',top='+oben+'');
}

// Video Popups
function openVideoPopup(video,name){
  var seite=(screen.availWidth-660)/2;
  var oben=(screen.availHeight-430)/2;
  fenster=window.open('http://shops.fabfab.net/apps/popup_video.php?video='+video+'&name='+name+'&lang=en','Video','width=660,height=430,toolbar=no,menubar=no,left='+seite+',top='+oben+'');
}

// Partnerprogramm
function openAffiliateApplication(){
  var seite=(screen.availWidth-650)/2;
  var oben=(screen.availHeight-600)/2;
  fenster=window.open('http://shops.fabfab.net/apps/affiliate_application.php?lang=en','AffiliateProgram','width=650,height=600,toolbar=no,scrollbars=yes,menubar=no,left='+seite+',top='+oben+'');
}

// Popups Bilder Lagerverkauf
function openFabricOutletStorePictures(image){
  var seite=(screen.availWidth-700)/2;
  var oben=(screen.availHeight-750)/2;
  fenster=window.open('http://shops.fabfab.net/apps/fabric_outlet_store_popup.php?lang=en&image='+image+'','FabricOutletStore','width=700,height=750,toolbar=no,menubar=no,left='+seite+',top='+oben+'');
}

// Anmeldung Lagerverkauf
function openFabricOutletStoreTimetable(){
  var seite=(screen.availWidth-650)/2;
  var oben=(screen.availHeight-600)/2;
  fenster=window.open('http://shops.fabfab.net/apps/fabric_outlet_store_timetable.php?lang=en','FabricOutletStoreTimetable','width=650,height=600,toolbar=no,scrollbars=yes,menubar=no,left='+seite+',top='+oben+'');
}

// Popup Versanddetails
function openShippingDetails(country){
  var seite=(screen.availWidth-500)/2;
  var oben=(screen.availHeight-600)/2;
  fenster=window.open('http://shops.fabfab.net/apps/shipping_details.php?lang=en&country='+country+'','ShippingDetails','width=500,height=600,toolbar=no,scrollbars=yes,menubar=no,left='+seite+',top='+oben+'');
}

// Social Bookmarking
function bookmark(provider){

  var urls = new Array();
  urls['mister_wong'] = 'http://www.mister-wong.com/index.php?action=addurl&bm_url='+encodeURIComponent(location.href)+'&bm_notice=&bm_description='+encodeURIComponent(document.title)+'&bm_tags=fabric, fabrics, online shop';
  urls['del.icio.us'] = 'http://del.icio.us/post?v=4&noui&jump=close&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title);
  urls['reddit']      = 'http://reddit.com/submit?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title);
  urls['slashdot']    = 'http://slashdot.org/bookmark.pl?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title);
  urls['google']      = 'http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title);
  urls['stumbleupon'] = 'http://www.stumbleupon.com/submit?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title);
  urls['windowslive'] = 'https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title)+'&top=1';
  urls['netscape']    = 'http://www.netscape.com/submit/?U='+encodeURIComponent(location.href)+'&T='+encodeURIComponent(document.title);
  urls['yahoo']       = 'http://myweb2.search.yahoo.com/myresults/bookmarklet?u='+encodeURIComponent(location.href)+'&t='+encodeURIComponent(document.title);
  urls['blinklist']   = 'http://blinklist.com/index.php?Action=Blink/addblink.php&Url='+encodeURIComponent(location.href)+'&Title='+encodeURIComponent(document.title);
  urls['feedmelinks'] = 'http://feedmelinks.com/categorize?from=toolbar&op=submit&name='+encodeURIComponent(document.title)+'&url='+encodeURIComponent(location.href)+'&version=0.7';
  urls['ask']         = 'http://mystuff.ask.com/mysearch/QuickWebSave?v=1.2&t=webpages&title='+encodeURIComponent(document.title)+'%21&url='+encodeURIComponent(location.href);

  fenster=window.open(urls[provider],'Bookmark','width=700,height=400,toolbar=no,scrollbars=yes,menubar=no,left=0,top=0');
}