function imagePreview(image, text, width, height, lang) {
	window.open ("image_preview.php?image="+image+"&text="+text+"&width="+width+"&height="+height+"&lang="+lang, "mywindow","scrollbars=1,status=1,width="+ (width + 100) + ",height="+ (height + 120)); 
}

function accesorioPreview(image, text, width, height) {
	window.open ("image_preview.php?image="+image+"&text="+text+"&width="+width+"&height="+height, "mywindow","scrollbars=1,status=1,width="+ (width + 100) + ",height="+ (height + 120)); 
}

function proveedorSeleccionado(select) {
	if (select.value == -1)
	{
		alert('Manufacturer has to be selected');
		return false;
	}
	return true;
}

function buscarConditioningCharger(idLineaProducto, idProveedor) {
	document.forms[0].submit();
}

function verNovedad(id) {
	document.getElementById("id").value = id;
	document.forms[0].submit();
}

function datosCareersValidados() {
	var firstName = document.getElementById("firstName");
	var lastName = document.getElementById("lastName");
	var city = document.getElementById("city");
	var state = document.getElementById("state");
	var zipPostalCode = document.getElementById("zipPostalCode");
	var country = document.getElementById("country");
	var email = document.getElementById("email");
	var dayTelephone = document.getElementById("dayTelephone");
	var coverNote = document.getElementById("coverNote");
	
	if (firstName.value.length == 0) {
	       alert("Please enter your first name.");
	       firstName.focus();
	       firstName.select();
	       return (false);
	}
	
	if (lastName.value.length == 0) {
	    alert("Please enter your last name.");
	    lastName.focus();
	    lastName.select();
		return (false);
	}
	
	if (city.value.length == 0) {
		alert("Please enter the city.");
	    city.focus();
	    city.select();
	    return (false);
	}
	
	if (state.value == -1) {
		alert("Please select a state.");
        state.focus();
        return (false);
    }
	
	if (zipPostalCode.value.length == 0) {
        alert("Please enter the zip / postal code.");
        zipPostalCode.focus();
        zipPostalCode.select();
        return (false);
    }
	
	if (country.value == -1) {
        alert("Please select a country.");
        country.focus();
        return (false);
    }

	if (email.value.length == 0) {
        alert("Please enter an email address.");
        email.focus();
        email.select();
        return false;
	}
	
	if (isEmail(email.value) == false) {
        alert("Please enter a valid email to continue. Example:xxx@xxx.com");
        email.focus();
        email.select();
        return false;
   	}
	
	if (dayTelephone.value.length == 0) {
        alert("Please a day time phone number.");
        dayTelephone.focus();
        dayTelephone.select();
        return (false);
    }

	if (coverNote.value.length == 0) {
        alert("Please a cover note.");
        coverNote.focus();
        coverNote.select();
        return (false);
    }
    
    return (true);
	
}

function isEmail(string) {
   if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
       return true;
   else
       return false;
}

function enviarMailCareers() {
	document.getElementById("postback").value = "postback";
	document.forms[0].submit();
}

function datosContactUsValidados() {
	var firstName = document.getElementById("firstName");
	var lastName = document.getElementById("lastName");
	var email = document.getElementById("email");
	var address = document.getElementById("address");
	var city = document.getElementById("city");
	var state = document.getElementById("state");
	var zipPostalCode = document.getElementById("zipPostalCode");
	var country = document.getElementById("country");
	
	if (firstName.value.length == 0) {
	       alert("Please enter your first name.");
	       firstName.focus();
	       firstName.select();
	       return (false);
	}
	
	if (lastName.value.length == 0) {
	    alert("Please enter your last name.");
	    lastName.focus();
	    lastName.select();
		return (false);
	}
	
	if (email.value.length == 0) {
        alert("Please enter an email address.");
        email.focus();
        email.select();
        return false;
	}
	
	if (isEmail(email.value) == false) {
        alert("Please enter a valid email to continue. Example:xxx@xxx.com");
        email.focus();
        email.select();
        return false;
   	}
	
	if (address.value.length == 0) {
        alert("Please enter an address.");
        address.focus();
        address.select();
        return false;
	}

	if (city.value.length == 0) {
		alert("Please enter the city.");
	    city.focus();
	    city.select();
	    return (false);
	}
	
	if (state.value == -1) {
		alert("Please select a state.");
        state.focus();
        return (false);
    }
	
	if (zipPostalCode.value.length == 0) {
        alert("Please enter the zip / postal code.");
        zipPostalCode.focus();
        zipPostalCode.select();
        return (false);
    }
	
	if (country.value == -1) {
        alert("Please select a country.");
        country.focus();
        return (false);
    }

    return (true);
	
}

function enviarMailContactUs() {
	document.getElementById("postback").value = "postback";
	document.forms[1].submit();
}

