 function show_row(sursa){
    // Make sure the element exists before calling it's properties
    if (document.getElementById(sursa) != null)
      // Toggle visibility between none and inline
      if (document.getElementById(sursa).style.display == 'none')
      {
        document.getElementById(sursa).style.display = 'block';
      } else {
        document.getElementById(sursa).style.display = 'none';
      }
  }
   function show_row2(sursa){
   var nr_grupate = document.getElementById('grupate').value;
   var i=0;
   var id=0;
   var contor=0;
   var text="test:";
   if (nr_grupate>0){
   		for (i=1;i<=nr_grupate;i++)
		{
		 	if (document.getElementById('grupate'+i) != null){
				text=text+" id:"+id;
		 		id=document.getElementById('grupate'+i).value*1;
				if (document.getElementById('afisare_tr_'+id) != null){
		 			if (id==sursa) {
						document.getElementById('afisare_tr_'+id).style.display = 'table-row'
						contor=document.getElementById('apartine'+id).value*1;
						document.getElementById('optiune'+contor).checked=true;
					} else {
						document.getElementById('afisare_tr_'+id).style.display = 'none'
					}
		 		}
		 	}
		}
   }
  }  
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
function swich_background(sursa){
    // Make sure the element exists before calling it's properties
    if (document.getElementById(sursa) != null)
      // Toggle visibility between none and inline
      if (document.getElementById(sursa).style.display== 'none')
      {
        document.getElementById(sursa + "_buton").style.backgroundImage= "url(images/comprima.jpg)";
      } else {
        document.getElementById(sursa + "_buton").style.backgroundImage = "url(images/extinde.jpg)";
      }
  } 
/*--------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------*/
function swich_background_footer(sursa){
    // Make sure the element exists before calling it's properties
    if (document.getElementById(sursa) != null)
      // Toggle visibility between none and inline
      if (document.getElementById(sursa).style.display== 'none')
      {
        document.getElementById(sursa + "_buton").style.backgroundImage= "url(images/footer_extinde_ro.png)";
      } else {
        document.getElementById(sursa + "_buton").style.backgroundImage = "url(images/footer_comprima_ro.png)";
      }
  } 
  
var badBrowser = (/MSIE ((5\.5)|6)/.test(navigator.userAgent) && navigator.platform == "Win32");
var Zoomer = {
 effectPending: false,
 imageRatio: null,
 largeWidth: null,
 largeHeight: null,
 targetPos: null,
 widthPad: null,
 heightPad: null,
 zoomActive: false,
 outsideBoxCount: 0,
 windowMouseMoveObserver: null,
 imgThumbBoxMouseOverObserver: null,
 isQuickView: false,
 imgThumbBoxWidth: null,
 imgThumbBoxHeight: null,
 zoomIndicatorWidth: null,
 zoomIndicatorHeight: null,
 zoomIndicator: null,
 zoomIndThumbImg: null,
 zoomBox: null,
 zoomImage: null,
 zoomImagePreloader: null,
 isSafari2: null,
 hideQtySelector: null,
 ieVer: 0,
 initZoom: function() {
   var appVer = navigator.appVersion.toLowerCase();
   var iePos = appVer.indexOf('msie');
   if(iePos != -1) {
     this.ieVer = parseInt(appVer.substring(iePos + 5, appVer.indexOf(';',iePos)));
   }
   var safariSearchIndex = navigator.userAgent.indexOf("Safari");
   if(safariSearchIndex > -1) {
     var safariVersion = parseFloat(navigator.userAgent.substring(safariSearchIndex+"Safari".length+1));
     if(safariVersion < 500 && safariVersion > 0) {
       this.isSafari2 = true;
     }
   } else {
     this.isSafari2 = false;
   }
   this.effectPending = false;
   this.imageRatio = null;
   this.largeWidth = null;
   this.largeHeight = null;
   this.targetPos = null;
   this.widthPad = null;
   this.heightPad = null;
   this.zoomImage = null;
   this.zoomImagePreloader = null;
   this.zoomActive = false;
   this.outsideBoxCount = 0;
   this.windowMouseMoveObserver = null;
   this.imgThumbBoxWidth = null;
   this.imgThumbBoxHeight = null;
   this.zoomIndicatorWidth = null;
   this.zoomIndicatorHeight = null;
   this.hideQtySelector = null;
   this.zoomBox = $('zoomBox');
   this.zoomImagePreloader = document.createElement("img");
   this.zoomImage = document.createElement("img");
   this.zoomImage.style.position = "absolute";
   var zoomImagePreloaderContainer = document.createElement("div");
   zoomImagePreloaderContainer.style.overflow = "hidden";
   zoomImagePreloaderContainer.style.height = "0px";
   zoomImagePreloaderContainer.style.width = "0px";
   zoomImagePreloaderContainer.appendChild(this.zoomImagePreloader);
   document.body.appendChild(zoomImagePreloaderContainer);
   this.zoomBox.appendChild(this.zoomImage);
   this.targetPos = this.findPos($('imgThumbBox'));
   this.widthPad = this.zoomBox.getDimensions().width/2;
   this.heightPad = this.zoomBox.getDimensions().height/2;
   Event.observe(this.zoomImagePreloader,'load',function(){Zoomer.calculateRatios();});
   this.zoomImagePreloader.src = $('imgThumbBox').name;
   $('imgThumbBox').parentNode.style.width = $('imgThumbBox').getDimensions().width + "px";
   $('imgThumbBox').parentNode.style.height = $('imgThumbBox').getDimensions().height + "px";
   var zoomTintLayer = document.createElement("div");
   zoomTintLayer.id = "zoomTintLayer";
   zoomTintLayer.style.position = "absolute";
   zoomTintLayer.style.background = "#FFF";
   zoomTintLayer.style.width = $('imgThumbBox').getDimensions().width + "px";
   zoomTintLayer.style.height = $('imgThumbBox').getDimensions().height + "px";
   zoomTintLayer.style.zIndex = 1001;
   this.imgThumbBoxMouseOverObserver = this.startZoom.bindAsEventListener(this);
   Event.observe(zoomTintLayer,'mouseover',this.imgThumbBoxMouseOverObserver);
   this.zoomIndicator = document.createElement("div");
   this.zoomIndicator.id = "zoomIndicator";
   try{
     this.zoomIndicator.style.position = "absolute";
     this.zoomIndicator.style.overflow = "hidden";
   }catch(eroare) {}
   this.zoomIndThumbImg = document.createElement("img");
   this.zoomIndThumbImg.id = "zoomIndThumbImg";
   this.zoomIndThumbImg.src = $('imgThumbBox').src;
   this.zoomIndThumbImg.width = $('imgThumbBox').width;
   this.zoomIndThumbImg.height = $('imgThumbBox').height;
   this.zoomIndThumbImg.style.position = "absolute";
   // For IE
   this.zoomIndThumbImg.galleryimg = "no";
   this.zoomIndicator.appendChild(this.zoomIndThumbImg);
   zoomTintLayer.appendChild(this.zoomIndicator);
   $('thumbBox').appendChild(zoomTintLayer);
   // For IE
   $('zoomTintLayer').setOpacity(0);
   $('imgThumbBox').style.left = $('zoomTintLayer').offsetLeft + 'px';
   $('imgThumbBox').style.position = 'absolute';
   $('zoomBox').style.top = $('imgThumbBox').offsetTop + 'px';
   $('zoomBox').style.right = 0 + 'px';
 },
 calculateRatios: function() {
 this.zoomImage.src = this.zoomImagePreloader.src;
 this.largeWidth = this.zoomImagePreloader.width;
 this.largeHeight = this.zoomImagePreloader.height;
 this.imageRatio = this.largeWidth / $('imgThumbBox').getDimensions().width;
 var zoomIndW = $('imgThumbBox').getDimensions().width * (this.zoomBox.getDimensions().width/this.largeWidth) + "px";
 var zoomIndH = $('imgThumbBox').getDimensions().height * (this.zoomBox.getDimensions().height/this.largeHeight) + "px";
 try {
   this.zoomIndicator.style.width = zoomIndW;
   this.zoomIndicator.style.height = zoomIndH;
 }catch(eroare) {}
   this.imgThumbBoxWidth = $('imgThumbBox').getDimensions().width;
   this.imgThumbBoxHeight = $('imgThumbBox').getDimensions().height;
   this.zoomIndicatorWidth = $('zoomIndicator').getDimensions().width;
   this.zoomIndicatorHeight = $('zoomIndicator').getDimensions().height;
 },
 refreshImage: function() {
   this.zoomImagePreloader.src = $('imgThumbBox').name;
   this.zoomIndThumbImg.src = $('imgThumbBox').src;
 },
 startZoom: function(event) {
   this.targetPos = this.findPos($('imgThumbBox'));
   if (badBrowser) { 
     jQuery('#size-selector').children('select').hide(); 
	 jQuery('#qty').hide(); 
   }
   if(!this.effectPending && !this.zoomBox.visible()) {
     $('zoomTintLayer').setOpacity(0.3);
     if(this.hideQtySelector) {
       $('qtySelector').hide();
     }
     this.zoomBox.show();
     this.moveZoom(event);
     this.windowMouseMoveObserver = this.moveZoom.bindAsEventListener(this);
     Event.observe(document,'mousemove',this.windowMouseMoveObserver);
     Event.stopObserving('zoomTintLayer','mouseover',this.imgThumbBoxMouseOverObserver);
   }
 },
 endZoom: function() {
   if(!this.effectPending && this.zoomBox.visible() && !this.zoomActive) {
     Event.stopObserving(document,'mousemove',this.windowMouseMoveObserver);
     if(!this.isQuickView || $('thumbBox')) {
       this.effectPending = true;
	   $('zoomBox').hide();
	   Zoomer.effectPending = false;
           if(Zoomer.hideQtySelector) {
             $('qtySelector').show();
           }
       Event.observe('zoomTintLayer','mouseover',Zoomer.imgThumbBoxMouseOverObserver);	   
       $('zoomTintLayer').setOpacity(0);
     }
     this.outsideBoxCount = 0; 
     if (badBrowser) { 
       jQuery('#size-selector').children('select').show(); 
	   jQuery('#qty').show(); 
     }
   }
 },
 moveZoom: function(event) {
   var targX = this.targetPos[0] - (document.documentElement.scrollLeft + document.body.scrollLeft);
   var ieOffset = 0;
   if(this.ieVer == 7) {
     ieOffset = 67;
   }
   if(this.isQuickView) {
     var targY = this.targetPos[1];
   } else {
     var targY = this.targetPos[1] - (document.documentElement.scrollTop + document.body.scrollTop);
   }
   if(this.isSafari2) {
     argY += document.body.scrollTop;
   }
   var desX = event.clientX - targX;
   var desY = event.clientY - targY;

   if(desX >= 0 && desX <= this.imgThumbBoxWidth &&desY >= 0 && desY <= this.imgThumbBoxHeight) {
     this.outsideBoxCount = 0;
     desX = desX * this.imageRatio;
     desY = desY * this.imageRatio;
     if(desX < this.widthPad) {
	   desX = this.widthPad;
     } else 

	   if(desX > (this.largeWidth-this.widthPad)) {
       desX = this.largeWidth - this.widthPad;
       }
     if(desY < this.heightPad) {
       desY = this.heightPad;
     } else 
	   if(desY > (this.largeHeight-this.heightPad)) {
         desY = this.largeHeight - this.heightPad;
       }
     var bgX = (0 - desX) + this.widthPad;
     var bgY = (0 - desY) + this.heightPad;
     if(this.DEBUG) {
       $('debugBox').update(
         "Target X: " + targX + "<br/>" +
         "Target Y: " + targY + "<br/>" +
         "Client X: " + event.clientX + "<br/>" +
         "Client Y: " + event.clientY + "<br/>" +
         "Desired X: " + desX + "<br/>" +
         "Desired Y: " + desY + "<br/>" +
         "imgThumbBoxWidth: " + this.imgThumbBoxWidth + "<br/>" +
         "imgThumbBoxHeight: " + this.imgThumbBoxHeight + "<br/>" +
         "Background X: " + bgX + "<br/>" +
         "Background Y: " + bgY + "<br/>" +
         "Imageratio: " + this.imageRatio + "<br/>" +
         "Element scrolltop: " + document.documentElement.scrollTop + "<br/>" +
         "Body scrolltop: " + document.body.scrollTop + "<br/>" +
         "ZoomHeight: " + this.zoomBox.getDimensions().width
       );
     }
     this.zoomImage.style.left = bgX + "px";
     this.zoomImage.style.top = bgY + "px";
     var zoomIndY = (event.clientY - targY) - this.zoomIndicatorHeight/2;
     var zoomIndX = (event.clientX - targX) - this.zoomIndicatorWidth/2;
     if(zoomIndY >= -1) {
       if(zoomIndY > this.imgThumbBoxHeight - this.zoomIndicatorHeight) {
         zoomIndY = this.imgThumbBoxHeight - this.zoomIndicatorHeight;
       }
     } else {
       zoomIndY = -1;
     }
     if(zoomIndX >= -1) {
       if(zoomIndX > this.imgThumbBoxWidth - this.zoomIndicatorWidth) {
         zoomIndX = this.imgThumbBoxWidth - this.zoomIndicatorWidth;
       }
     } else {
       zoomIndX = -1;
     }
     try {
       this.zoomIndicator.style.top = (zoomIndY + ieOffset) + "px";
       this.zoomIndicator.style.left = (zoomIndX + ieOffset) + "px";
     } catch(eroare) {}

     this.zoomIndThumbImg.style.top = (-zoomIndY - 1 - ieOffset) + "px";
     this.zoomIndThumbImg.style.left = (-zoomIndX - 1 - ieOffset) + "px";
   } else {
     this.outsideBoxCount++;

     if(this.outsideBoxCount > 10) {
       this.endZoom();
     }
   }
 },

 findPos: function(obj) {
   var curleft = curtop = 0;
   if (obj.offsetParent) {
     curleft = obj.offsetLeft;
     curtop = obj.offsetTop;
     while (obj = obj.offsetParent) {
       curleft += obj.offsetLeft;
       curtop += obj.offsetTop;
     }
   }
   return [curleft,curtop];
 }
}




		  function portavoce_marime_click(care){
		  	control_ascuns='portavoce_hidden_'+care;
			control_atins='portavoce_marime_'+care;
			control_litera='portavoce_marime_litera_'+care;
		  	//alert($(control_ascuns).value);
		  	if($(control_ascuns).value==0){
			  
			  $(control_atins).className='portavoce_marimi_selectat';
			  $(control_litera).className='portavoce_marimi_litera_selectat';
			  $(control_ascuns).value=1;
			}else{
			  $(control_atins).className='portavoce_marimi';
			  $(control_litera).className='portavoce_marimi_litera';
			  $(control_ascuns).value=0;
			}
		  }

		  function portavoce_marime_over(care){
		    marime='marime_'+care;
		    if(care!=litera_default){
			  $(marime).className='marimi marimi_hover';
		    }
		  }

		  function portavoce_marime_out(care){
		    marime='marime_'+care;
			if(care!=litera_default){ 
			  $(marime).className='marimi marimi_neselectat';
			} 
		  }
		function pict_click(care,aratatab,info){
			if(tab_default!=aratatab){
			  $(care).className=$(care).className+' ind_select';
			  $(ind_default).className=$(ind_default).className.replace('ind_select','');
			  ind_default=care;
			  $(tab_default).style.display='none';
			  $(aratatab).style.display='inline';
			  tab_default=aratatab;
			}
			if(info=='none'){
			  if(info_default!='none'){
			    $(info_default).style.display='none';
				info_default='none';
			  }
			}else{
			  if(info_default!=info){
			    if(info_default!='none'){
			      $(info_default).style.display='none';
			    }
			    info_default=info;
			    $(info).style.display='inline';
			  }else{
			     $(info).style.display='none';
				 info_default='none';
			  }
			}
		  
		}	  

		  function marime_over(care){
		    marime='marime_'+care;
		    if(care!=litera_default){
			  $(marime).className='marimi marimi_hover';
		    }
		  }

		  function marime_out(care){
		    marime='marime_'+care;
			if(care!=litera_default){ 
			  $(marime).className='marimi marimi_neselectat';
			} 
		  }
   function out(){
	   if(salvat==0){
		for (i=1;i<=rating*2;i++){
		   document.getElementById("jumate_stea_"+i).style.background = "url(images/starbox/stea3-galben-"+(2-i%2)+".jpg)";
		 }
		 if(rating*2<10){
		   for (i=rating*2+1;i<=10;i++){
			 document.getElementById("jumate_stea_"+i).style.background = "url(images/starbox/stea3-gri-"+(2-i%2)+".jpg)";
		   }
		 }	   
	   
	   }
   }

   function salveaza(){
   	if(salvat==0){
		salvat=1;
		//alert("ok");
		
		new Ajax.Request('/ajax/_salveaza_rating.php?r='+ratingNou+'&p='+iP+'&c='+iC+'&i='+iU, {
          onComplete: function() {
		  	document.getElementById("steledeasupra").style.cursor='default';
		  	rating=Math.round((iS+ratingNou)/(iV+1)*2,0)/2;
			document.getElementById("voturi").innerHTML='('+(iV+1)+')';
			for (i=1;i<=rating*2;i++){
			   document.getElementById("jumate_stea_"+i).style.background = "url(images/starbox/stea3-galben-"+(2-i%2)+".jpg)";
			 }
			 if(rating*2<10){
			   for (i=rating*2+1;i<=10;i++){
				 document.getElementById("jumate_stea_"+i).style.background = "url(images/starbox/stea3-gri-"+(2-i%2)+".jpg)";
			   }
			 }				
          }
        });
		
	    }
   }


function AttachEvent(obj,evt,fnc,useCapture){
	if (!useCapture) useCapture=false;
	if (obj.addEventListener){
		obj.addEventListener(evt,fnc,useCapture);
		return true;
	} else if (obj.attachEvent) return obj.attachEvent("on"+evt,fnc);
	else{
		MyAttachEvent(obj,evt,fnc);
		obj['on'+evt]=function(){ MyFireEvent(obj,evt) };
	}
} 

//The following are for browsers like NS4 or IE5Mac which don't support either
//attachEvent or addEventListener
function MyAttachEvent(obj,evt,fnc){
	if (!obj.myEvents) obj.myEvents={};
	if (!obj.myEvents[evt]) obj.myEvents[evt]=[];
	var evts = obj.myEvents[evt];
	evts[evts.length]=fnc;
}
function MyFireEvent(obj,evt){
	if (!obj || !obj.myEvents || !obj.myEvents[evt]) return;
	var evts = obj.myEvents[evt];
	for (var i=0,len=evts.length;i<len;i++) evts[i]();
}


    function functie_stele(event) {
      if(salvat==0){
	    posX = event.clientX - document.getElementById("stele").offsetLeft-document.getElementById("blob_produs").offsetLeft;
		k=Math.floor(posX/29)+1;
		ratingNou=k;
		for (i=1;i<=k*2;i++){
		  document.getElementById("jumate_stea_"+i).style.background = "url(images/starbox/stea3-select-"+(2-i%2)+".jpg)";
		}
		if(k*2<10){
		  for (i=k*2+1;i<=10;i++){
		    document.getElementById("jumate_stea_"+i).style.background = "url(images/starbox/stea3-gri-"+(2-i%2)+".jpg)";
		  }
		}
      }
	} 

		  
