function swapImg(on,img,name) { if(name == false) name = img; if(document.images) { var image = "/graphics/" + img + ((on)?'-over.gif':'.gif'); document.images[name].src= image; } } // - - - - - - - - - - - - - - - - - - - - - - - - // Lägg in annons var text = ""; var error = false; function frmAd() { error = false; if(document.frm.c_place.value == ""){ error = true; text += "Provicia es casilla obligatoria" + "\n"; return false; } if(document.frm.c_name.value == ""){ error = true; text += "Nombre es casilla obligatoria" + "\n"; } if(document.frm.c_email.value == ""){ error = true; text += "E-mail es casilla obligatoria" + "\n"; } else if(document.frm.c_email.value != "") { if(!document.frm.c_email.value.isValidEmail()) { error = true; text += "Su E-mail no es correcto, pruebe otra vez" + "\n"; } } if(document.frm.c_phone.value == ""){ error = true; text += "Teléfono es casilla obligatoria" + "\n"; } if(document.frm.c_category.value == ""){ error = true; text += "Categoría es casilla obligatoria" + "\n"; } if(document.frm.c_headline.value == ""){ error = true; text += "Titulo de su anuncio es casilla obligatoria" + "\n"; } if(document.frm.c_year) { if(document.frm.c_year.value == ""){ error = true; text += "Elige año por favor" + "\n"; } } if(document.frm.c_mile) { if(document.frm.c_mile.value == ""){ error = true; text += "Elige Km por favor" + "\n"; } } if(document.frm.c_text.value == ""){ error = true; text += "Descripción es casilla obligatoria" + "\n"; } if(document.frm.c_password.value == ""){ error = true; text += "Contraseña es casilla obligatoria" + "\n"; }else if(document.frm.c_password.value != ""){ if(!(isValidString(document.frm.c_password.value))){ error = true; text += "Tu contraseña contiene caracteres inválidos" + "\n"; } } if(document.frm.c_password.value != document.frm.c_retype.value){ error = true; text += "Las contraseñas no son correctas" + "\n"; } if(document.frm.c_password.value != ""){ if(document.frm.c_password.value.length < 5){ error = true; text += "Su contraseña es demasiado corta, usted necesita un mínimo de 5 caracteres" + "\n"; } if(document.frm.c_password.value.length > 10){ error = true; text += "Su contraseña es demasiado larga, usted necesita un máximo de 10 caracteres" + "\n"; } } if(error) { alert(text); text = ""; error=false; return false; } } // - - - - - - - - - - - - - - - - - - - - - - - - // Svara på annons function answerForm() { if(document.frm.c_name.value == ""){ text += "Nombre es casilla obligatoria" + "\n"; error = true; } if(document.frm.c_email.value == ""){ text += "E-mail es casilla obligatoria" + "\n"; error = true; } else if(document.frm.c_email.value != "") { if(!document.frm.c_email.value.isValidEmail()) { text += "Su E-mail no es correcto, pruebe otra vez" + "\n"; error = true; } } if(document.frm.c_subject.value == ""){ text += "Título es una casilla obligatoria" + "\n"; error = true; } if(document.frm.c_text.value == ""){ text += "Mensaje es una casilla obligatoria"; error = true; } if(error) { alert(text); text = ""; error=false; return false; } } // - - - - - - - - - - - - - - - - - - - - - - - - // Svara på annons function checkFile(obj) { if(obj.c_image.value != ""){ if(!obj.c_image.value.match(/(\.gif|\.jpg|\.png|\.jpe|\.jpeg)$/i)){ alert("Usted solo puede descargar cualquiera de los formatos siguientes de las fotos: .jpg, .jpeg, .jpe, .png, o .gif."); return false; } return true; } } // - - - - - - - - - - - - - - - - - - - - - - - - // Funktion för att kontrollera epost String.prototype.isValidEmail = function(){ return !!this.match(/^([a-zA-Z0-9]{1}([a-zA-Z0-9\.\-\_]*)[a-zA-Z0-9]{1})@([a-zA-Z0-9]{1}([a-zA-Z0-9\.\-\_]*)[a-zA-Z0-9]{1})\.([a-zA-Z]{2,4})$/) } function isValidString(string){ var validChars = "0123456789ABCDEFTGHIJKLMOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; var character; var valid = true; // test strString consists of valid characters listed above for (i = 0; i < string.length && valid == true; i++) { character = string.charAt(i); if (validChars.indexOf(character) == -1) { valid = false; } } return valid; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // function MaxLen(TA, Size) { if(TA.value.length > Size-1){TA.value = TA.value.substring(0, Size -1)} }