function config(object,i,k,q,t){
    var name = $(object).attr('name');
    var target = name + "_content";

	$.ajax({
		type: 'POST',
		url: 'menu/form/productconfig.php',
		dataType: "html",
		data: {
			var0:t,
			var1:i,
			var2:k,
			var3:q
		},
		async: true,
		success: function (data) {
			elemento = '#'+target;
			$(elemento).empty().append(data);
		}
	});
};


function getInitialConfig(){

    $("#form_content").find("input[type='checkbox']").attr("config","config").each(function () {
          if ($.browser.msie && $.browser.version < 9) {
              eval($(this).attr("onclick"));
              $(this).attr("checked", "checked");
          } else {
              $(this).click();
          }
          $(this).attr("disabled","disabled");
    });

}

function validateSend(){
    var selectedValue = $("input[id='choose']:checked");
    if(selectedValue.length == 0){
        send();
    }else{
        if ($("#hiddenSelectedLanguage").val() == 'french' || $("#hiddenSelectedLanguage").val() == '_fr') {
            alert('Vous devez configurer votre produit correctement')
        } else {
            alert('You must to configure your product properly')
        }
    }

}

function send(){



    var tagsArray = new Array();

//    $("form select").each(function (){


//        if($(this).is("select[name=select_name]")){
//
//            alert("entro en select");
//
//        }


//    });


    $("form input").each(function (){

        //	$("select[name=select_name]").each(function () {

        //		if(parseInt($(this).val())>0){
        //		tagsArray.push(2+','+0+','+$(this).val()+','+$(this).attr('value2'));
        //		}
        //	});

//        if($(this).is("select[name=select_name]")){
//
//            alert("entro en select");
//
//        }


        if($(this).is("input[type='hidden']")){
//             alert("hidden");
            tagsArray.push($(this).val());

        }else if($(this).attr('type')=='checkbox'){
//            alert("checkbox  "+$(this).attr('type')+"    "+$(this).val())

            if($(this).attr('checked') == true){
            tagsArray.push($(this).val());
            }

        }else if($(this).attr('type')=='radio'){

            if($(this).attr('checked') == true){
//                alert("radio true "+$(this).val());
                tagsArray.push($(this).val());
            }


//            alert("radio:" +$(this).attr('checked'));
//            if($(this).attr('checked', 'checked')){

//            alert($(this).val());

//            }
        }


    });

var txtcommend_end = document.getElementById("txtcommend_end").value;
var txtcommend_end_name = document.getElementById("txtcommend_end_name").value;
    $("form select").each(function (){

        if($(this).is("select[name=select_name]")){


        		if(parseInt($(this).val())>0){
				//alert("entro en select " + $(this).attr('product'));
								a = $(this).attr('product')
								a = a.replace('(','').replace(')', '')
								b = a.split(',')
								product = "(" + b[0] + ',' + b[1] + ',' + b[3] + ',' + $(this).val() + ',' + b[4] + ',' + b[5] + ")"
								tagsArray.push(product);
//				tagsArray.push(2+','+0+','+$(this).val()+','+$(this).attr('value2'));
        		}

        }


    });





//, txtcommend_end:txtcommend_end


	$.ajaxSetup({async:true});
    $.post("menu/form/resp.php", {'data[]':tagsArray, txtcommend_end:txtcommend_end, txtcommend_end_name:txtcommend_end_name},function(data){

    render();
         
                window.location.href = $('#redirect-to').val();

    });



}

jQuery.browser = {};
(function () {
    jQuery.browser.msie = false;
    jQuery.browser.version = 0;
    if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) {
        jQuery.browser.msie = true;
        jQuery.browser.version = RegExp.$1;
    }
})();
