﻿var selprid=0; seldetid=0;

function CMS_OpenGalWin(url) {
  var wxc=screen.width/2; var wyc=screen.height/2;
  var galwin=window.open(url,'cms_galwin','scrollbars=yes,width='+winw+',height='+winh+',left='+(wxc-Math.round(winw/2))+',top='+(wyc-Math.round(winh/2))+',resizable=no'); galwin.focus();
}
function AddBasket(id,did) {
  var cnt=eval('document.cms_shop.cms_shopprod_id'+id).value;
  if(isNaN(cnt)) alert('Anzahl '+cnt+' ist keine Zahl!'); else if(cnt<1) alert('Anzahl muss größer 0 sein!'); else {
    document.location.href='default.php?'+querydat+'&shopcmd=addbasket&prid='+id+'&cnt='+cnt+'&detail='+did+'#listcontentID'+did; }
}
function AddBasketSel(id) {
  CMS_SelProduct(id);
  var cnt=eval('document.cms_shop.cms_shopprod_id'+id).value;
  if(isNaN(cnt)) alert('Anzahl '+cnt+' ist keine Zahl!'); else if(cnt<1) alert('Anzahl muss größer 0 sein!'); else {
    document.location.href='default.php?'+querydat+'&shopcmd=addbasket&prid='+selprid+'&cnt='+cnt+'&detail='+seldetid+'#listcontentID'+seldetid; }
}
function CMS_SelProduct(id) {
  var obj=eval('document.cms_shop.cms_shopprod_sel'+id);
  var selarr=obj.options[obj.selectedIndex].value; selarr=selarr.split('|');
  selprid=selarr[0];
  seldetid=selarr[1];
  document.getElementById('cms_shopprice'+id).firstChild.data=selarr[2];
  document.getElementById('cms_shopartnum'+id).firstChild.data=selarr[3];
}
function ShowBasket() {
//  document.location.href='default.php?'+querydat+'&shopcmd=showbasket&detail='+detid+'#listcontentID'+detid;
  document.cms_shop.action='default.php?'+querydat+'&shopcmd=showbasket&detail='+detid+'#listcontentID'+detid;
  document.cms_shop.submit();
}
function UpdtBasket() {
  document.cms_shop.action='default.php?'+querydat+'&shopcmd=updtbasket&detail='+detid+'#listcontentID'+detid;
  document.cms_shop.submit();
}
function RemProduct(id) {
  eval('document.cms_shop.cms_shopprod_id'+id).value=0;
  UpdtBasket();
}
function CheckOut(id) {
  if(id==undefined) id='';
//  document.location.href='default.php?'+querydat+'&shopcmd=checkout'+id+'&detail='+detid+'#listcontentID'+detid;
  document.cms_shop.action='default.php?'+querydat+'&shopcmd=checkout'+id+'&detail='+detid+'#listcontentID'+detid;
  document.cms_shop.submit();
}
function CheckOutSelect() {
 var obj=eval('document.cms_shop'); var cmd='';
// alert(obj.cms_logontype[0].checked+','+obj.cms_logontype[1].checked+','+obj.cms_logontype[2].checked+','+obj.cms_logontype[3].checked);
 if(obj.cms_logontype[0].checked) cmd='drawquickbuy';
 else if(obj.cms_logontype[1].checked) cmd='logon';
 else if(obj.cms_logontype[3].checked) cmd='drawregister';
 if(cmd=='logon') DoLogon('logon');
 else {
  obj.action='default.php?'+querydat+'&shopcmd='+cmd;
  obj.submit();
 }
}
function SendPwdForm() {
 var obj=eval('document.cms_shop');
 obj.cms_logontype[2].checked=true;
 obj.action='default.php?'+querydat+'&shopcmd=drawsendpassword';
 obj.submit();
}
function ConfirmOrder() {
 var obj=eval('document.cms_shop');
 //if(obj.AGB.checked) {
  obj.action='default.php?'+querydat+'&shopcmd=confirmorder';
  obj.submit();
 //} else alert('Sie müssen unseren AGBs zustimmen!');
}
function ConfirmOrder1(outside) {
 var obj=eval('document.cms_shop'); var payment=0;
// if(obj.cms_payment[0].checked) payment=1; else if(obj.cms_payment[1].checked) payment=2; else if(obj.cms_payment[2].checked) payment=3; else if(obj.cms_payment[3].checked) payment=5;
 payment=1;
 if(payment>0 || outside==true) {
  if(obj.AGB.checked) {
   obj.action='default.php?'+querydat+'&shopcmd=confirmorder1';
   obj.submit();
  } else alert("Sie müssen unseren AGB's zustimmen!");
 } else alert('Bitte wählen Sie eine Zahlweise aus!');
}
function SetAdr2() {
  var vis='none'; if(document.cms_shop.cms_adr2.checked) vis='block';
  document.getElementById('regopt01').style.display=vis;
  document.getElementById('regopt02').style.display=vis;
  document.getElementById('regopt03').style.display=vis;
  document.getElementById('regopt04').style.display=vis;
  document.getElementById('regopt05').style.display=vis;
  document.getElementById('regopt06').style.display=vis;
  document.getElementById('regopt07').style.display=vis;
  document.getElementById('regopt08').style.display=vis;
  document.getElementById('regopt09').style.display=vis;
}
function SetAdrBill() {
  var obj=eval('document.cms_shop.shopadrbill');
  var addrid=obj.options[obj.selectedIndex].value; addrid=addrid.split(',');
  if(addrid[0]==-1) cmdurl='default.php?'+querydat+'&shopcmd=edaddrb&addrid=0&detail='+detid+'#listcontentID'+detid;
               else cmdurl='default.php?'+querydat+'&shopcmd=setbilladr&addrid='+addrid[0]+'&detail='+detid+'#listcontentID'+detid;
//  document.location.href=cmdurl;
  obj=eval('document.cms_shop');
  obj.action=cmdurl;
  obj.submit();
}
function SetAdrSend(id) {
 var obj=eval('document.cms_shop.shopadrsend');
 if(id>0) cmdurl='default.php?'+querydat+'&shopcmd=setsendadr&addrid='+id+'&detail='+detid+'#listcontentID'+detid;
 else if(obj) {
  var addrid=obj.options[obj.selectedIndex].value; addrid=addrid.split(',');
  if(addrid[0]=='-1') cmdurl='default.php?'+querydat+'&shopcmd=edaddrs&addrid=0&detail='+detid+'#listcontentID'+detid;
                 else cmdurl='default.php?'+querydat+'&shopcmd=setsendadr&addrid='+addrid[0]+'&detail='+detid+'#listcontentID'+detid;
 } else cmdurl='default.php?'+querydat+'&shopcmd=edaddrs&addrid=0&detail='+detid+'#listcontentID'+detid;
 var obj=eval('document.cms_shop');
 obj.action=cmdurl;
 obj.submit();
}
function SetAdrType() {
  //var vis='none'; if(document.cms_shop.cms_type.value>1) vis='block';
  //document.getElementById('regopt00').style.display=vis;
}
function ShowAddress() {
  obj=eval('document.cms_shop');
  obj.action='default.php?'+querydat+'&shopcmd=showaddress&detail='+detid+'#listcontentID'+detid;
  obj.submit();
}
function EditAddress(id) {
  document.location.href='default.php?'+querydat+'&shopcmd=edaddr&addrid='+id+'&detail='+detid+'#listcontentID'+detid;
}
function DelAddress(id) {
  if(confirm('Wollen Sie diese Adresse loeschen?')) {
    document.location.href='default.php?'+querydat+'&shopcmd=deladdr&addrid='+id+'&detail='+detid+'#listcontentID'+detid; }
}
function DoRegister(cmd) {
 var obj=eval('document.cms_shop'); var parent=obj.cms_parent.value;
 obj.action='default.php?'+querydat+'&shopcmd='+cmd+'&detail='+detid+'#listcontentID'+detid;
 if(obj.cms_gender.value>0)
  if(obj.cms_vname.value!='')
   if(obj.cms_nname.value!='')
    if(obj.cms_street.value!='')
     if(obj.cms_zip.value!='')
      if(obj.cms_city.value!='')
       if(obj.cms_cc.value!='')
        if(obj.cms_phone.value!='')
         if(obj.cms_email.value!='')
          obj.submit();
         else alert('Bitte geben Sie Ihre E-Mail Adresse an!');
        else alert('Bitte geben Sie Ihre Telefonnummer an!');
       else alert('Bitte geben Sie Ihre Adresse an (Staat/Land fehlt)!');
      else alert('Bitte geben Sie Ihre Adresse an (Ort fehlt)!');
     else alert('Bitte geben Sie Ihre Adresse an (Postleitzahl fehlt)!');
    else alert('Bitte geben Sie Ihre Adresse an (Straße fehlt)!');
   else alert('Bitte geben Sie Ihren vollständigen Namen an! (Nachname fehlt)');
  else alert('Bitte geben Sie Ihren vollständigen Namen an! (Vorname fehlt)');
 else alert('Bitte geben Sie Ihren vollständigen Namen an! (Anrede fehlt)');
}
function DoLogon(cmd) {
 var obj=eval('document.cms_shop');
 obj.action='default.php?'+querydat+'&shopcmd='+cmd+'&detail='+detid+'#listcontentID'+detid;
 if(obj.cms_logon.value!='')
  if(obj.cms_pwd.value!='')
   obj.submit();
  else alert('Bitte geben Sie Ihr Passwort ein!');
 else alert('Bitte geben Sie Ihre E-Mail Adresse an!');
}
function DoResend() {
 var obj=eval('document.cms_shop');
 obj.action='default.php?'+querydat+'&shopcmd=resendpassword&detail='+detid+'#listcontentID'+detid;
 if(obj.cms_rsemail.value!='')
  obj.submit();
 else alert('Bitte geben Sie Ihre E-Mail Adresse an!');
}
function SubmitUserCode() {
 var obj=eval('document.cms_shop');
 obj.action='default.php?'+querydat+'&shopcmd=sendusercode&detail='+detid+'#listcontentID'+detid;
 if(obj.cms_shop_usercode.value!='') obj.submit();
 else alert('Bitte geben Sie Ihren Code ein!');
}
function goPage() {
 var obj=eval('document.cms_shop');
 if(obj.page) var p=obj.page.options[obj.page.selectedIndex].value; else var p=0;
 if(obj.pagesize) {
  var plen=obj.pagesize.options[obj.pagesize.selectedIndex].value;
  document.location.href='default.php?'+querydat+'&p='+p+'&plen='+plen;
 }
}
function ShowTab(i) {
	if(typeof tabidx=='number' && tabidx!=i) {
		if(tabidx>0) {
			var tablnk=document.getElementById('tablnk'+tabidx);
			if(tablnk) {
//alert(tablnk.className);
				tablnk.className='Hmenu2';
//alert(tablnk.parentNode.nextSibling.nextSibling.nodeType);
				tablnk.parentNode.nextSibling.className='mbutdiv2';
				if(tabidx>1) tablnk.parentNode.previousSibling.className='mbutdiv2';
				var tab=document.getElementById('tab'+tabidx);
				if(tab) tab.style.display='none';
				tabidx=0;
			}
		}
		var tablnk=document.getElementById('tablnk'+i);
		if(tablnk) {
			tablnk.className='Hmenu2 mact2';
			if(i>1) tablnk.parentNode.previousSibling.className='mbutdiv2up';
			tablnk.parentNode.nextSibling.className='mbutdiv2dn';
			var tab=document.getElementById('tab'+i);
			if(tab) tab.style.display='block';
			tabidx=i;
		}
	}
}

