		function disableCheck(myval) {
			var boxes = document.getElementsByTagName("input");
			for (var i = 0; i < boxes.length; i++) {
			myType = boxes[i].getAttribute("type");
				if ( myType == "checkbox") {
					if (boxes[i].checked==false){
						boxes[i].disabled=myval
					}
				}
			}
		}

		function arataComparatie() {
			var valori="";
			var boxes = document.getElementsByTagName("input");
			for (var i = 0; i < boxes.length; i++) {
				myType = boxes[i].getAttribute("type");
				if ( myType == "checkbox") {
					if (boxes[i].checked==true){
						valori=valori+boxes[i].value+",";
					}
				}
			}
			window.location="http://ikeadev.webtailors.ro/ComparaProduse/"+valori+".htm";
		}
	
		function comparaProduse() {
			var nrBifate=0
		 	var boxes = document.getElementsByTagName("input");
			for (var i = 0; i < boxes.length; i++) {
				myType = boxes[i].getAttribute("type");
				if ( myType == "checkbox") {
					if (boxes[i].checked==true){
						nrBifate++;
					}
 				}
			}
	
			if (nrBifate>=2) {
				document.getElementById('compara_on').style.display='block';
				document.getElementById('compara_off').style.display='none';
				document.getElementById('compara_on2').style.display='block';
				document.getElementById('compara_off2').style.display='none';
			} else {
				document.getElementById('compara_on').style.display='none';
				document.getElementById('compara_off').style.display='block';
				document.getElementById('compara_on2').style.display='none';
				document.getElementById('compara_off2').style.display='block';
			}
	
			if (nrBifate>=4) {
				disableCheck(1)
				//alert('da'+nrBifate);
			} else {
				disableCheck(0)
			}
	
		}


		
         $(function() {
                var sSlideStatus = "hidden";
                var bInMenu = false;
				var bHideLaunched = false;

                function runToggle(){
				//console.log("runToggle()::start");
                sSlideStatus = (sSlideStatus == "hidden" ? "visible" : "visible");
				$("#icar").toggle('slide', 300);
				//console.log("runToggle()::end");
          		};

                function runHide(){
					//console.log("runHide()::start");
                    if(sSlideStatus != "hidden") {
                    	sSlideStatus = "hidden";
                    	$("#icar").hide('slide', 300);
					}
					//console.log("runHide()::end");
                };

                function runShow(){
                    //console.log("runshow()::start");
                    if(sSlideStatus != "visible") {
                    	sSlideStatus = "visible";
                    	$("#icar").show('slide', 300);
                    }
				//console.log("runshow()::end");
                };

                $("#drop").click(function(){
                    //console.log("drop.onclick::start");
                    runToggle();
                    //console.log("drop.onclick::end");
                    return false;
                });

                $("#drop").mouseover(function(){
                    //console.log("drop.mouseover::start");
                    runToggle();
                   // console.log("drop.mouseover::end");
                    return false;
                });

                function hideIfNotInMenu(){
                    if (!bInMenu) {
                        runHide();
                    }
                }
				
                $("#drop").mouseleave(function(event) {
					if (!bHideLaunched) {
     					bHideLaunched = true;
						setTimeout(function() {
							//console.log($('#icar').css("display"));
							bHideLaunched = false;
							if (!bInMenu) {
								$("#icar").hide();
							}
						}, 100);
					}
                    return false;
                });

                $("#icar").mouseleave(function(){
                    bInMenu = false;
                    runHide();
					$("#icar").hide();
                    return false;
                });

                $("#icar").mouseover(function(){
                    bInMenu = true;
                    return false;
                });

                $("#icar").hide();
            });
            
            $( document ).ready( function () {
            	$('#total_produse_reduse').height($('#cat_right_reduceri').height());
   				$( '#scroller' ).scrollFollow( {
   				});
   			});
		 
function initJumpMenus() {
				var selectElements = document.getElementsByTagName("select");
				for( i = 0; i < selectElements.length; i++ ) {
					if( selectElements[i].className == "select_small" && document.getElementById(selectElements[i].id) != "" ) {
						jumpmenu = document.getElementById(selectElements[i].id);
						jumpmenu.onchange = function() {
						if( this.options[this.selectedIndex].value != '' ) {
						location.href=this.options[this.selectedIndex].value;
						}
					}
				}
			}
		}
		
		
		prods = new Array; //array cu toate produselor adaugate
		
		
		//functie cautare id in array-ul cu produse
		function arr_find_id(k){
			found = -1;
			for (var i in prods){
				if (parseInt(prods[i].id) == parseInt(k)){
					found = i;
				}
			}
			return found;
		}
		
		//functie creare cookie
		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 var expires = "";
			document.cookie = name+"="+value+expires+"; path=/";
		}

		//functie stergere cookie
		function eraseCookie(name) {
			createCookie(name,"",-1);
		}
		
		//functie afisare produse
		function print_prods(start){
			prod_visible = document.getElementById('ap_prods_visible');
			prod_more = document.getElementById('ap_prods_more');
			total_vechi = document.getElementById('ap_total_vechi');
			total_nou = document.getElementById('ap_total_nou');
			economie = document.getElementById('ap_economie');
			nr_prod = document.getElementById('prod_sel');
			pv = '';
			pm = '';
			tn = 0;
			tv = 0;
			e = 0;
			if((prods.length-start-3)>0){
				end = start+3;
			} else {
				end = prods.length;
			}
			ids = new Array;
			for(i=0;i<prods.length;i++){
				if(i>=start && (i-start)<3){
					pv += '<div class="catalldisplay_modif"><a href="javascript://" onClick="addProductDis(\''+prods[i].id+'\', \'\', \'\', \'\', \'\', \'\', \'\', document.getElementById(\'add_'+prods[i].id+'\'));" style="display: table; width: 5px; float: right; text-decoration: none; color: red; margin-left: 5px;">x</a><a href="'+prods[i].link+'" src="'+prods[i].img+'" style="text-decoration:none;"><span style="color: #3399FD;"><b>'+prods[i].titlu+'</b></span></a><a href="'+prods[i].link+'" src="'+prods[i].img+'" style="text-decoration:none;"><span style="color: #3399FD;"> '+prods[i].desc+'</span></a><br><table cellpadding="0" cellspacing="0" width="100%"><tr><td><span style="text-decoration: line-through;"><b>'+prods[i].p_vechi.replace('.',',')+' RON</b></span></td><td align="right" style="color: red;"><b>'+prods[i].p_nou.replace('.',',')+' RON</b></td></tr></table></div>';
				}
				tn += parseFloat(prods[i].p_nou.replace(',','.'));
				tv += parseFloat(prods[i].p_vechi.replace(',','.'));
				ids[i] = prods[i].id;
			}
			if(prods.length>0){
				ids.join(',');
				createCookie('ikea_reduceri', ids, 100);
			} else {
				eraseCookie('ikea_reduceri');
			}
			if(prods.length>3){
				pm = '<div class="catalldisplay_modif"><table cellpadding="0" cellspacing="0" width="100%"><tr>';
				pm += '<td>';
				if(start>2){
					pm += '<a href="javascript://" onclick="print_prods('+(start-3)+');" class="linkstandard">&laquo;</a>';
				} else {
					pm += '<span style="color: #999999;">&laquo;</span>';
				}
				pm += '</td><td width="100%" align="center"><a href="ReduceriLista.htm" class="linkstandard">vezi lista</a></td><td>'
				if((start+4)<=prods.length){
					pm += '<a href="javascript://" onclick="print_prods('+(start+3)+');" class="linkstandard">&raquo;</a>';
				} else {
					pm += '<span style="color: #999999;">&raquo;</span>';
				}
				pm += '</td></tr>';
				pm += '</table></div>';
			} else {
				if(prods.length>0){
					pm += '<div class="catalldisplay_modif"><center><a href="ReduceriLista.htm" class="linkstandard">vezi lista</a></center></div>';
				}
			}
			e = parseFloat(tv)-parseFloat(tn);
			e = '<span style="font-size: 8.5pt; color: #000000;">Economisesti:</span></span><br><span style="font-size: 16px;">'+e.toFixed(1)+"</span> RON"
			tn = '<span style="font-size: 8.5pt; color: #000000;">Pret nou:</span></span><br><span style="font-size: 16px;">'+tn.toFixed(1)+"</span> RON";
			tv = '<span style="font-size: 8.5pt;">Pret vechi:</span></span><br><span style="text-decoration: line-through;"><span style="font-size: 13px;">'+tv.toFixed(1)+"</span> RON</span>";
			
			if(pv==''){
				pv = 'Nu aveti niciun produs adaugat.';
			}
			
			prod_visible.innerHTML = pv;
			prod_more.innerHTML = pm;
			total_vechi.innerHTML = tv.replace('.',',');
			total_nou.innerHTML = tn.replace('.',',');
			economie.innerHTML = e.replace('.',',');
			nr_prod.innerHTML = prods.length;
			
			$(function(){
				$("a[src*='_S2.jpg']").thumbPopup({
					imgSmallFlag: "_S2",
					imgLargeFlag: "_S3"
				});
			});
		}
		
		//adauga/sterge produse in lista si le afisaza
		function addProductDis(id, titlu, desc, pret_vechi, pret_nou, img, link, target){
			pos = arr_find_id(id);
			if(pos==-1){
				prods.unshift({"id":id, "titlu":titlu, "desc":desc, "p_vechi":pret_vechi, "p_nou":pret_nou, "img":img, "link":link});
				if(target){
					target.innerHTML = 'Sterge din lista';
				}
			} else {
				prods.splice(pos, 1);
				if(target){
					target.innerHTML = 'Adauga in lista';
				}
			}
			
			print_prods(0);
		}
		
		//functie refresh cookie
		function refresh_cookie(){
			total_vechi = document.getElementById('ap_total_vechi');
			total_nou = document.getElementById('ap_total_nou');
			economie = document.getElementById('ap_economie');
			nr_prod = document.getElementById('prod_sel');
			tn = 0;
			tv = 0;
			e = 0;
			nr_prod = 0;
			
			ids = new Array;
			for(i=0;i<prods.length;i++){
				tn += parseFloat(prods[i].p_nou.replace(',','.'));
				tv += parseFloat(prods[i].p_vechi.replace(',','.'));
				ids[i] = prods[i].id;
			}
			e = parseFloat(tv)-parseFloat(tn);
			
			e = '<span style="font-size: 8.5pt; color:#000000;">Economisesti:</span></span><br><span style="font-size: 15px;">'+e.toFixed(1)+"</span> RON"
			tn = '<span style="font-size: 8.5pt; color:#000000;">Pret nou:</span></span><br><span style="font-size: 15px;">'+tn.toFixed(1)+"</span> RON";
			tv = '<span style="font-size: 8.5pt; ">Pret vechi:</span></span><br><span style="text-decoration: line-through;"><span style="font-size: 13px;">'+tv.toFixed(1)+"</span> RON</span>";
			
			total_vechi.innerHTML = tv.replace('.',',');
			total_nou.innerHTML = tn.replace('.',',');
			economie.innerHTML = e.replace('.',',');
			nr_prod.innerHTML = prods.length;
			
			if(prods.length>0){
				ids.join(',');
				createCookie('ikea_reduceri', ids, 100);
			} else {
				eraseCookie('ikea_reduceri');
			}
		}
		
		function delProductDis(id){
			pos = arr_find_id(id);
			prods.splice(pos, 1);
			var el = document.getElementById('add_'+id);
			if(prods.length>0){
				el.parentNode.removeChild(el);
			} else {
				el.parentNode.innerHTML = 'Nu aveti produse selectate.';
			}
			refresh_cookie();
		}