	function chenge_color(id){
		if (active_color!='0' && $('d_c_'+active_color) ) $('d_c_'+active_color).className='border_colorfoto';
		if (id!='0' && $('d_c_'+id) ) $('d_c_'+id).className='border_colorfoto_a';	
		chengeListFoto(id);
		active_color=id;
		var size=$('product_sel_size').value;
		/*if (active_color!='0' && size!='0') changePriceProduct(id_product,active_color,size,0);*/
		if (active_color!='0'){
			var url = 'index.php?type=get_select_size_product&id='+id_product+"&color="+active_color;			
			var myAjax = new Ajax.Request(url,{method: 'get',onComplete: showResponse1});								
		}
		
		function showResponse1(ret){
			if (ret.responseText){
				var html=ret.responseText;			
				$('size1').innerHTML=html;
			}										
		}
	}
    
    function change_package_color(color, product_id, color_zindex){
        var zindex=color_zindex-1;
        var url = 'index.php?type=get_select_size_package_product&product_id='+product_id+"&color="+color+"&zindex="+zindex;            
        var myAjax = new Ajax.Request(url,{method: 'get',onComplete: showResponse1});
        
        function showResponse1(ret){
            if (ret.responseText){
                var html=ret.responseText;            
                $('size_'+product_id).innerHTML=html;
            }                                        
        }
    }
	
	/*function chenge_size(size){		
		var color=$('product_sel_color').value;
		if (setartikel==0){
			if (color!='0' && size!='0') changePriceProduct(id_product,color,size,0);
		}else{
			if (color!='0' && size!='0'){
				var url = 'index.php?type=get_select_size_product&id='+id_product+"&color="+color+"&size="+size+'&ext=1';			
				var myAjax = new Ajax.Request(url,{method: 'get',onComplete: showResponse2});								
			}	
		}
				
		function showResponse2(ret){
			if (ret.responseText){
				var html=ret.responseText;			
				$('size3').innerHTML=html;
			}										
		}
	}*/
    
    function chenge_size(size){        
        var color=$('product_sel_color').value;    
        if (color!='0' && size!='0') changePriceProduct(id_product,color,size,0);      
    }
	
	function chenge_size3(size3){
		var color=$('product_sel_color').value;
		var size=$('product_sel_size').value;		
		if (color!='0' && size!='0' && size3!='0'){
			changePriceProduct(id_product,color,size,size3);
		}
		
	}
	
	function chengeListFoto(id_color){
		active_color=id_color;	
		list_foto=list_c_foto[id_color];
		end_foto=list_foto.length;
		showBigFoto(0);
	}

	function showButtonNP(){
		$('foto_n_end').innerHTML=end_foto;
		if (active_foto>0) $('but_prev').style.display='block'; else $('but_prev').style.display='none';
		if (active_foto<end_foto-1) $('but_next').style.display='block'; else $('but_next').style.display='none';
	}
	
	function show_next_img(){
		active_foto=active_foto+1;
		showBigFoto(active_foto);
	}
	
	function show_prev_img(){
		active_foto=active_foto-1;
		showBigFoto(active_foto);
	}
	
	function showFullFoto(){
		window.open('index.php?type=fullimage&image=index.php%3Ftype%3DgetImage%26id%3D'+id_product+'%26num%3D'+active_foto+'%26color%3D'+active_color,'window','width=600, height=800, scrollbars=no,status=no,toolbar=no,menubar=no,resizable=yes,location=no');			
	}
	
	function showBigFoto(num){
		document.getElementById('big_foto').src=list_foto[num];
		active_foto=num;
		var number=num+1;
		document.getElementById('foto_n_act').innerHTML=number;
		showButtonNP();
	}
	
	function checkFormProduct(){        
        if (isPackageArticle=="True"){
            checkFormProductPackage();
        }else{
            checkFormProductNormal();
        }        		
	}
    
    function checkFormProductNormal(){
        $('product_sel_color_div_mm').style.border="0px solid #B8030A";
        $('product_sel_size_div_mm').style.border="0px solid #B8030A";        
        $('product_count').style.border="1px solid #999";
        
        var color=$('product_sel_color').value;
        var size=$('product_sel_size').value;                                
        var count=parseInt($('product_count').value);
        if (!count) count=0;
        var url="index.php?type=get_count_itemvariant&id="+id_product+"&color="+color+"&size="+size+"&edit_id="+edit_id;
        var myAjax = new Ajax.Request(url,{method: 'get',onComplete: showResponse});
                
        function showResponse(ret){
            var count_exist=parseInt(ret.responseText);          
            
            if (color!='0' && size!='0' && count>0 && count<=count_exist){
                document.f1.submit();
            }
            else{
                if ( color=='0' ) $('product_sel_color_div_mm').style.border="1px solid #B8030A";
                if ( size=='0' ) $('product_sel_size_div_mm').style.border="1px solid #B8030A";
                if ( count<=0 || count>count_exist) $('product_count').style.border="1px solid #B8030A";
                if (color=='0' || size=='0' || count<=0){ 
                    $('id_product_message').innerHTML=
                    '<div style="padding-top:20px;"><table cellpadding="0" cellspacing="0" class="login_message_error">'+            
                    '<td style="padding-left:7px;"><b>Hinweis:</b><br/>Bitte wählen Sie eine Farbe, Größe und Menge aus.<br/><br/></td></tr></table></div>';
                }else{
                    if (count_exist>0){
                        $('id_product_message').innerHTML=
                        '<div style="padding-top:20px;"><table cellpadding="0" cellspacing="0" class="login_message_error">'+            
                        '<td style="padding-left:7px;"><b>Hinweis:</b><br/>Error max. Menge '+count_exist+'<br/><br/></td></tr></table></div>';
                    }else{
                        $('id_product_message').innerHTML=
                        '<div style="padding-top:20px;"><table cellpadding="0" cellspacing="0" class="login_message_error">'+            
                        '<td style="padding-left:7px;"><b>Hinweis:</b><br/>Artikel zurzeit ausverkauft!<br/><br/></td></tr></table></div>';
                    } 
                }
                
            } 
        }                                
    }
    
    function checkFormProductPackage(){
        var error = 0;
        
        var count=parseInt($('product_count').value);        
        if (!count) count=0;
        
        if ( count<=0 ) {
            $('product_count').style.border="1px solid #B8030A";
            error=1;
        }    
        
        var count_package_product = package_product.length;
        
        var url="index.php?type=get_count_itemvariant_package&id="+id_product+"&edit_id="+edit_id;        
        
        for(var i=0;i<count_package_product;i++){
            var prod = package_product[i];
            $('product_sel_color_'+prod+'_div_mm').style.border="0px solid #B8030A";
            if ($('product_sel_color_'+prod).value=='0'){                    
                $('product_sel_color_'+prod+'_div_mm').style.border="1px solid #B8030A";
                error=1;
            }
            $('product_sel_size_'+prod+'_div_mm').style.border="0px solid #B8030A";
            if ($('product_sel_size_'+prod).value=='0'){                    
                $('product_sel_size_'+prod+'_div_mm').style.border="1px solid #B8030A";
                error=1;
            }                        
            url+="&colors["+prod+"]="+$('product_sel_color_'+prod).value;
            url+="&sizes["+prod+"]="+$('product_sel_size_'+prod).value;
        }
        
        var myAjax = new Ajax.Request(url,{method: 'get',onComplete: showResponse});
        
        function showResponse(ret){
            var count_exist=parseInt(ret.responseText);
                        
            if (error==1){
                $('id_product_message').innerHTML=
                '<div style="padding-top:20px;"><table cellpadding="0" cellspacing="0" class="login_message_error">'+            
                '<td style="padding-left:7px;"><b>Hinweis:</b><br/>Bitte wählen Sie eine Farbe, Größe und Menge aus.<br/><br/></td></tr></table></div>';
                return 0;
            }
            
            if (count>count_exist){
                if (count_exist>0){
                    $('id_product_message').innerHTML=
                    '<div style="padding-top:20px;"><table cellpadding="0" cellspacing="0" class="login_message_error">'+            
                    '<td style="padding-left:7px;"><b>Hinweis:</b><br/>Error max. Menge '+count_exist+'<br/><br/></td></tr></table></div>';
                }else{
                    $('id_product_message').innerHTML=
                    '<div style="padding-top:20px;"><table cellpadding="0" cellspacing="0" class="login_message_error">'+            
                    '<td style="padding-left:7px;"><b>Hinweis:</b><br/>Artikel zurzeit ausverkauft!<br/><br/></td></tr></table></div>';
                }                
                return 0;                
            }
                    
            if (error==0){
                document.f1.submit();
            }        
        }                    
    }
	
	function edit_product(id, back, mark){
		var myAjax = new Ajax.Request('/index.php?type=edit_basket&id='+id+'&back='+back+'&mark='+mark,{method: 'get', onComplete: showResponse});
		function showResponse(r){
			var mas=r.responseText.split("|+|+|");
			eval(mas[0]);
			$('window').innerHTML=mas[1];
			showWin('window');
			$('window').style.left='225px';
			chengeListFoto(active_color);
		}
	}
    
    /* get price package product */
    function changePriceProductPackage(){
        var url = 'index.php?type=get_price_info_product_package_cs&id='+id_product;
        var count_package_product = package_product.length;
        for(var i=0;i<count_package_product;i++){
            var prod = package_product[i];
            var color = $('product_sel_color_'+prod).value;
            var size = $('product_sel_size_'+prod).value;
            url+="&colors["+prod+"]="+color;
            url+="&sizes["+prod+"]="+size;
        }                
        var myAjax = new Ajax.Request(url,{method: 'get', onComplete: showResponse});
        function showResponse(ret){
            if (ret.responseText){
                var mas=ret.responseText.split("||");            
                $('p_c_price_b').innerHTML=mas[1];
            }                                        
        }
    }
