function prov()
{
    var r_eturn  = true;
    if(document.getElementById('main')==null || document.getElementById('main')=='undefined' || document.getElementById('main')=='null')
    {
        r_eturn = false;
    }

    if(document.getElementById('main2')==null || document.getElementById('main2')=='undefined' || document.getElementById('main2')=='null')
    {
        r_eturn = false;
    }

    if(document.getElementById('main3')==null || document.getElementById('main3')=='undefined' || document.getElementById('main3')=='null')
    {
        r_eturn = false;
    }
    return r_eturn;
}

function hide_all()
{
    document.getElementById('main').style.display = 'none';    
    document.getElementById('main1').style.display = 'none';    
    document.getElementById('main2').style.display = 'none';    
    document.getElementById('main3').style.display = 'none';    
}

function show(num)
{
      
      if(!prov())  
        return 0;
    hide_all();

    
    
    document.getElementById('main').style.display = 'none';
    document.getElementById('main'+num).style.display = 'block';
    
}

function big_img(img)
{
    window.open(img, 'pm_the_one', 'width=379, height=508, resizable=0, scrollbars=0, menubar=0, toolbar=0, titlebar=0');
}

function set_cur(el,id)
{
    //var arr = document.getElementsByName('td_raz');
             
    var count = document.getElementById('count_td').value;
        
    for(var i = 0; i<count; i++)
    {
        //arr[i].style.backgroundColor = '#FCF6DE';
        document.getElementById('td_raz'+i).style.backgroundColor = '';
        document.getElementById('td_raz'+i).style.color = '';
    }
    
    el.style.backgroundColor = '#F5CE42';
    el.style.color = '#295980';
    
    document.getElementById('order-gr').selectedIndex = id+1; 
}

function set_cur2(id)
{   
    var count = document.getElementById('count_td').value;
    
    for(var i = 0; i<count; i++)
    {
        document.getElementById('td_raz'+i).style.backgroundColor = '';
        document.getElementById('td_raz'+i).style.color = '';
    }
    
    var tmp = id - 1;
    
    document.getElementById('td_raz' + tmp).style.backgroundColor = '#F5CE42';
    document.getElementById('td_raz' + tmp).style.color = '#295980';
}

function prov_sub()
{
    if(document.getElementById('order-gr-hidden').value!='')
    {
        submite_order();
        return;
    }
    if(document.getElementById('order-gr').options[document.getElementById('order-gr').selectedIndex].value==0 || document.getElementById('order-quantity').value=='') 
    {
        document.getElementById('gross').style.color = 'red';
        document.getElementById('order-gr').style.border = 'solid 1px red';
        
    }
    else 
    {
        submite_order();
    }
}

 $(document).ready(function(){
                                                                                    
      $("#cm1, #pl1 label").click(function() {
            $(".chhose_element .rad1").css("background-color","#D4DEE5");
            $(".chhose_element .text").css("background-color","#EAEEF2");
             $(".chhose_element_kred .rad1").css("background-color","#C8D6DF"); 
             $(".chhose_element_kred .text").css("background-color","#E1E8ED"); 
            
            $("#pl1 div:first").css("background-color","#D6EEA7"); 
            $("#pl1 div:last").css("background-color","#EBF6D3");
      });
       $("#cm2, #pl2 label").click(function() {
            $(".chhose_element .rad1").css("background-color","#D4DEE5");
            $(".chhose_element .text").css("background-color","#EAEEF2");
             $(".chhose_element_kred .rad1").css("background-color","#C8D6DF"); 
             $(".chhose_element_kred .text").css("background-color","#E1E8ED"); 
            
            $("#pl2 div:first").css("background-color","#D6EEA7"); 
            $("#pl2 div:last").css("background-color","#EBF6D3");
      });
       $("#cm3, #pl3 label").click(function() {
            $(".chhose_element .rad1").css("background-color","#D4DEE5");
            $(".chhose_element .text").css("background-color","#EAEEF2");
             $(".chhose_element_kred .rad1").css("background-color","#C8D6DF"); 
             $(".chhose_element_kred .text").css("background-color","#E1E8ED"); 
            
            $("#pl3 div:first").css("background-color","#D6EEA7"); 
            $("#pl3 div:last").css("background-color","#EBF6D3");
      });
       $("#cm4, #pl4 label").click(function() {
            $(".chhose_element .rad1").css("background-color","#D4DEE5");
            $(".chhose_element .text").css("background-color","#EAEEF2");
             $(".chhose_element_kred .rad1").css("background-color","#C8D6DF"); 
             $(".chhose_element_kred .text").css("background-color","#E1E8ED"); 
            
            $("#pl4 div:first").css("background-color","#D6EEA7"); 
            $("#pl4 div:last").css("background-color","#EBF6D3");
      });
});


function go_article(el)
{
    
    $("#main_information").html("<img src='/i/ajax-loader.gif' style='margin-top:25%; margin-left:35%;' />");
     
    $(".order").html("");
    $(".order").load(el.href+'&type=order');
    
    //$("#main_information").load(el.href+'&type=main_information');
    
    $.ajax({
    url: el.href+'&type=main_information',             
    dataType : "html",                     
    success: function (data, textStatus) { 
                            
        $("#main_information").html(data);
        JT_init();
    }
    });
    
    
       
    
    if ($.browser.msie==true && $.browser.version<=6) 
    {
    }
    else
    {
        location.hash = el.name;
    }
    
    
    return false;  
}


function submite_order() 
{   
    $("#order-gr-hidden").val($("#order-gr option:selected").val());
    var str = $("#form_add_b").serialize();
    $("#tb_ajax_place").html("<div id=\"top_basket\"><img src='/i/ajax-loader2.gif' style='margin-top:25%; margin-left:35%;' /></div>");
    
    
    $("#tb_ajax_place").load("/ajax.php?"+str);
}
