	function ampliar(cual){
		console.log("ampliar = "+cual);
	}
	
	$(document).ready(function (){
	     if(document.frmPersonalData != null){
    		//CalculaTotal ();
    		$("#facturacion input[@name='facturacion']").click(ChangeFacturacion);	    	
    		$(".textfieldcopy").change(CopyTextField);
    		$(".selectfieldcopy").change(CopySelectField);
    		ChangeFacturacion();
     	 }

     	 if (!sbproduct_hasgirlfriend) {
    		$('#o_nombre').attr("disabled", true); 
    		$('#o_apellidos').attr("disabled", true); 
    		$('#o_direccion').attr("disabled", true); 
    		$('#o_poblacion').attr("disabled", true); 
    		$('#o_provincia').attr("disabled", true); 
    		$('#o_cp').attr("disabled", true); 
    		$('#mensaje').attr("disabled", true); 				
     	 }
    
	});

	function enableShipData (enable) {
		$("#f_nombre").attr ('disabled', !enable);
		$("#f_apellidos").attr ('disabled', !enable);
		$("#f_email").attr ('disabled', !enable);
		$("#f_telefono").attr ('disabled', !enable);
		$("#f_direccion").attr ('disabled', !enable);
		$("#f_poblacion").attr ('disabled', !enable);
		$("#f_provincia").attr ('disabled', !enable);
		$("#f_cp").attr ('disabled', !enable);
	}
	
	function CopyTextField (event) {
	    if (samedata == '1') {
	       var src = event.target;
	       var dest = document.getElementById ("f_" + src.id.substring (2) );
	       dest.value = src.value;
	    }
	}

	function CopySelectField (event) {
	    if (samedata == '1') {
	       var src = event.target;
	       var dest = document.getElementById ("f_" + src.id.substring (2) );
	       textToSelect (src, dest);
	    }
	}

	function Valida() {
	  var acepta_politica  =   $("input[@name='politica']:checked").val();	 
		if(acepta_politica == '1'){ return true
	  } else {
	  	alert ("Before continuing, you must accept the shopping conditions.")
	    return false
	  }
	} 
	
	/*
	function CalculaTotal (){
		
		//Obtenemos el total sin el euro del final
		var total_without_send = $("#total_without").text()
		total_without_send = total_without_send.substring(0,total_without_send.length -1 );
		
		//Obtenemos el total sin gastos de envío
		var total_ships = $("#total_ships").text()
		total_ships= total_ships.substring(0,total_ships.length -1 );
		
	}	
	*/

	function textToSelect (txt, slc) {
		var cmp = txt.value.toUpperCase();
		for (var i = 0; i < slc.options.length; i++) {
	        if (cmp == slc.options[i].text.toUpperCase() ) {
	            slc.options[i].selected = true;
				break;
			}
		}
	}

	samedata = '0';
	function ChangeFacturacion(){
		
		samedata  =   $("input[@name='facturacion']:checked").val();	 
		if(samedata == '1'){
			
			
			$("#f_nombre").val (document.getElementById('u_nombre').value);
			$("#f_apellidos").val (document.getElementById('u_apellidos').value);
			$("#f_email").val (document.getElementById('u_email').value);
			$("#f_telefono").val (document.getElementById('u_telefono').value);			
			$("#f_direccion").val (document.getElementById('u_direccion').value);
			$("#f_poblacion").val (document.getElementById('u_poblacion').value);
			$("#f_cp").val (document.getElementById('u_cp').value);

			textToSelect (document.getElementById('u_provincia'), document.getElementById('f_provincia') );

			enableShipData (false);
			
		}else{
		    enableShipData (true);
		}
		
		
	}

