function redir(loc){location.href=document.getElementsByTagName('base')[0].href+loc;}

function shs(n){
l=document.getElementById('ddes').style.left;if (l!=''){l=parseInt(document.getElementById('ddes').style.left)}
lw=document.getElementById('ddes').offsetWidth;r=l+n*30;
if (r<-lw){r=-lw;}else{if (r>0){r=0;}else{wd=setTimeout('shs('+n+')',50);}}document.getElementById('ddes').style.left=r;
}
function shd(){
if (document.getElementById('bdes').title=='ascunde'){document.getElementById('bdes').title='arată';document.getElementById('bdes').src='img/nrg.gif';shs(-1);}
else{document.getElementById('bdes').title='ascunde';document.getElementById('bdes').src='img/nle.gif';shs(+1);}
}


function createbookmark() {
title = document.title; 
url = location.href;
if(window.sidebar){window.sidebar.addPanel(title,url,"");}
 else if(window.external){window.external.AddFavorite(url,title);}
  else if(window.opera && window.print){return true;}
}

function share(fb){
url=escape(location.href);
tit=escape(document.title);
r='';
if(fb){r+='<iframe src="http://www.facebook.com/plugins/likebox.php?id=151331701568738&width=182&connections=6&stream=false&header=false&height=300" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:180px; height:275px; background-color:EEEEEE;" allowTransparency="true"></iframe>';}
r+='<a href="javascript:createbookmark()"><img src="img/tfav.png" title="Adaugă la favorite"></a>'+
'<a href="ymsgr:im?+&msg=+'+url+'"><img src="img/tmess.png" title="Trimite pe Yahoo! Messenger"></a>'+
'<a href="http://www.facebook.com/sharer.php?u='+url+'&t='+tit+'" target="blank"><img src="img/tface.png" title="Trimite pe Facebook"></a>'+
'<a href="https://www.google.ro/bookmarks/mark?op=edit&output=popup&bkmk='+url+'&title='+tit+'&labels=lenjerie+de+pat,+lenjerii+de+pat,+lenjerie,+textile,+deniz" target="_blank"><img src="img/tgoog.png" title="Google Bookmarks"></a><br>';
if(!fb){r+='<iframe src="http://www.facebook.com/plugins/like.php?href='+url+'&amp;layout=button_count&amp;show_faces=false&amp;width=100&amp;action=like&amp;font=arial&amp;colorscheme=light&amp;height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>';}
document.write(r);
}

a=new Array(6);
for (var i=1;i<a.length;i++){a[i]=new Array(6)};
a[1][1]='interzis spălare automată';
a[1][2]='spălare manuală';
a[1][3]='spălare la max. 30°C';
a[1][4]='spălare la max. 40°C';
a[1][5]='spălare la max. 60°C';
a[1][6]='spălare la max. 95°C';
a[2][1]='interzis utilizarea înălbitorului';
a[2][2]='poate fi folosit înălbitor';
a[3][1]='interzis curățarea chimică';
a[3][2]='poate fi curățit chimic';
a[3][3]='orice înălbitor înafară de tricloretilenă';
a[4][1]='interzis uscarea automată';
a[4][2]='poate fi uscat automat';
a[4][3]='uscător delicat';
a[4][4]='uscător delicat, fără căldură';
a[5][1]='interzis utilizarea fierului de călcat';
a[5][2]='fierul de călcat la temperatură mică';
a[5][3]='fierul de călcat la temperatură medie';
a[5][4]='fierul de călcat la temperatură ridicată';
a[5][5]='fierul de călcat la temperatură mică, fără abur';

function modintr(s){
var r='',c;s=s.split(';');
for (var i=0;i<s.length;i++){
if (s[i].indexOf(':')>0){c=s[i].split(':');r=r+'<img src="img/px.gif" style="width:50;height:50;background: transparent url(\'img/intretinere.png\') no-repeat scroll -'+(c[1]-1)*50+'px -'+(c[0]-1)*50+'px;" title="'+a[c[0]][c[1]]+'" onmouseover="intre(\'\')">';}}
document.getElementById('mi').innerHTML=r;
}

function intre(s){
if ((document.getElementById('mi').innerHTML=='')&&(s!='')){modintr(s)}
document.getElementById('mi').style.display='';
}
function hintre(){document.getElementById('mi').style.display='none';}

function openmess(){
mywindow=window.open(document.getElementsByTagName('base')[0].href+"mess.htm","sup","location=0,status=0,scrollbars=0,menubar=0,resizable=0,directories=0,width=240,height=420");
mywindow.moveTo(50,50);
}

// cdc
function cdcshs(n){
l=document.getElementById('dcdc').style.top;if (l!=''){l=parseInt(document.getElementById('dcdc').style.top)}
lw=document.getElementById('dcdc').offsetHeight;r=l+n*30;
if (r<-lw){r=-lw;}else{if (r>0){r=0;}else{wd=setTimeout('cdcshs('+n+')',50);}}document.getElementById('dcdc').style.top=r;
}
function cdcshd(){
if (document.getElementById('cdcb').title=='ascunde'){document.getElementById('cdcb').title='arată';document.getElementById('cdcb').src='img/ndw.gif';cdcshs(-1);}
else{document.getElementById('cdcb').title='ascunde';document.getElementById('cdcb').src='img/nup.gif';cdcshs(+1);}
}
function spliv(){
document.getElementById('cdcform').submit();
}

function res(e,s){var re=new RegExp(e);s=s.toString().toLowerCase();if(s.match(re)){return true}else{return false}}

function cdcvt(e){
n=e.name;v=e.value;
switch (n){
 case 'nume':{re='^[a-zăîșțâ\\-]{3,} [a-zăîșțâ\\- ]{3,}$';break}
 case 'telefon':{re='^[0-9\\.\\-\\+\\/ ]{10,}$';break}
 case 'email':{re='^[0-9a-z\\.\\-\\_]{1,}\\@[0-9a-z\\.\\-\\_]{2,}\\.[a-z]{2,5}$';break}
 case 'judet':{re='.{1,}';break}
 case 'localitate':{re='^[0-9a-zăîșțâ\\- ]{3,}$';break}
 case 'adresa':{re='^.{3,}[0-9]{1,}.*$';break}
 default:{re='';break}}
if (res(re,v)){i='ok';k=1;}else{i='cross';k=0}
document.getElementById('i_'+n).src='img/k_'+i+'.png';
return k;
}

function cdcvs(){
livr();
f='nume,telefon,email,judet,localitate,adresa'.split(',');n=0;
for(var i=0;i<f.length;i++){n+=cdcvt(document.getElementsByName(f[i])[0]);}
if (n==f.length){document.getElementById('vld').value=1;return true;}else{document.getElementById('vld').value=0;alert('nu ați completat corect formularul!');return false;}
}

function livr(){
var j=document.getElementById('judet').value;
var tot=parseInt(document.getElementById('cdcval').value);
var taxa=taxalivrare(j,tot);
var total=taxa+tot;
document.getElementById('taxa').innerHTML=topret(taxa);
document.getElementById('ctax').value=taxa;
document.getElementById('tot').innerHTML=topret(total);
}

function chreftxt(){
if(dge('reftxt').value=='Altul'){d=''}else{d='none'}
dge('reftxtaltul').style.display=d;
}

function topret(pret){
p=Math.floor(pret);d=((pret-p)*100)+"";
while(d.length<2){d+="0";}
pret=p+"<small>,"+d+"</small> Lei";
return pret;
}
function pcase(f){f.value=f.value.toLowerCase().replace(/^(.)|\s(.)|[\.]{1}([^ ])/g, function($1) {return $1.toUpperCase();});}

var lod;function loading(n){lodg='<img src="img/loading.gif">';e=document.getElementById(n);if(e.innerHTML.indexOf('loading.gif')>=0){e.innerHTML=lod;}else{lod=e.innerHTML;e.innerHTML=lodg;}}

//ajf
function ajf(m,s){var xmlHttp;try{xmlHttp=new XMLHttpRequest();}catch(e){try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}catch(e){return false;}}}
xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){procajf(m,xmlHttp.responseText);}}
xmlHttp.open("POST","ajf.asp",true);xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-2");xmlHttp.send("m="+m+"&s="+s.replace(/ /g,"+"));
}
function procajf(m,s){
switch(m){
 case "lp":{
  pz=s.substring(0,s.indexOf('|'))
  s=s.substring(s.indexOf('|')+1)
  document.getElementById('lprod').innerHTML=s;
  window.setTimeout(function(){document.getElementById('lprod').scrollTop=pz;},1000);
  break}
 case "add":{redir('cos.htm');break}
 case "addcal":{cdcmic();break}
 case "cdcmic":{
  if(s.indexOf('0 produse')==-1){
   s='<a href="cos.htm">'+s+'</a>';
   document.getElementById('cdci').innerHTML='<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=8,0,0,0" WIDTH=29 HEIGHT=25><PARAM NAME=movie VALUE="img/cdc1.swf"><PARAM NAME=quality VALUE=high><PARAM NAME="wmode" VALUE="transparent"><PARAM NAME=loop VALUE=true><EMBED src="img/cdc1.swf" wmode="transparent" loop=true quality=high WIDTH=29 HEIGHT=25 TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED></OBJECT>';
   }
  document.getElementById('cdcmic').innerHTML=s;
  break}
 case "cdcmare": case "cdcrecal":{cdcmare_fin(s);break}
 case 'comenzi_list':{comenzi_list_fin(s);break;}
 case 'comanda_upd':{comanda_upd_fin(s);break;}
 default: {break}
  }
}

function lp(c,id){
ajf("lp",c.toString()+'&id='+id.toString());
}
function cdcadd(id,cod){
loading('cdcmic');
ajf("add",id.toString()+'&cod='+cod.toString());
}
function cdcmic(){
loading('cdcmic');
ajf("cdcmic","");
}
function cdcmare(){
loading('trm');
ajf("cdcmare","");
}

function cdcmare_fin(r){
document.getElementById('cdcmare').innerHTML=r;
var tot=parseInt(document.getElementById('cdcval').value);
if(tot==0){document.getElementById('cdccom').innerHTML='Nu sunt produse în coș.';}
 else{livr();loading('trm');}
}

function cdcrecal(n,v){
loading('trm');
s=n.toString()+"&v="+v.toString();
ajf("cdcrecal",s);
}

function comenzi_list(){
loading('ld');
st=dge('st').value;
d1=dge('d1').value;
d2=dge('d2').value;
qs=dge('qs').value;
ajf("comenzi_list","&st="+st+"&d1="+d1+"&d2="+d2+"&qs="+qs);
}

function dge(n){return document.getElementById(n);}

function comenzi_list_fin(r){
dge('comenzilst').innerHTML=r;
loading('ld');
}

function comanda_upd(s){ajf('comanda_upd','&id='+cm+'&v='+s);comenzi_stah();}
function comanda_upd_fin(r){s=r.split('|');dge('c'+s[0]).innerHTML=s[1];}

function comenzi_stas(e){
var d=dge('sta');
if(e!=undefined){
 t=e.offsetTop;
 id=e.id.substring(1);
 cm=id;
 d.style.top=t;}
d.style.display='';
d=dge('comenzilst');
var cn=40;
d.style.opacity=cn/100;
d.style.filter='alpha(opacity='+cn+')';
}

function comenzi_stah(){
var d=dge('sta');
d.style.display='none';
d=dge('comenzilst');
var cn=100;
d.style.opacity=cn/100;
d.style.filter='alpha(opacity='+cn+')';
}

