function checkPhotos(btn, f){
  var bIsOk = false;
  var sPhotoMain = document.getElementById("photomain")!=undefined?document.getElementById("photomain").value:"";
  var sPhotoSec = document.getElementById("photosec")!=undefined?document.getElementById("photosec").value:"";
  
  if (!bIsOk && sPhotoMain!=undefined && sPhotoMain!=""){
    sPhotoMain = sPhotoMain.toLowerCase();
    if (sPhotoMain.indexOf(".jpg")>=0 || sPhotoMain.indexOf(".gif")>=0){
      bIsOk = true;
    }
  }
  
  if (!bIsOk && sPhotoSec!=undefined && sPhotoSec!=""){
    sPhotoSec = sPhotoSec.toLowerCase();
    if (sPhotoSec.indexOf(".jpg")>=0 || sPhotoSec.indexOf(".gif")>=0){
      bIsOk = true;
    }
  }
  
  if (bIsOk){
    btn.disabled=true;  
    f.submit();
  }
  else{
    if ((sPhotoMain==undefined || sPhotoMain=="") && (sPhotoSec==undefined || sPhotoSec==""))
      alert("Por favor sube una foto.");
    else
      alert("Las fotos deben estar en formato GIF o JPG.");
  }
}

function showLegalConditions() {

    var w = window.open('/legal', 'legal', 'width=640,height=300,scrollbars=yes');

}



function updateProvincesListStatus(defaultCountry, step) {

    if (document.forms["register" + step].country.options[document.forms["register" + step].country.selectedIndex].value != defaultCountry) {

        document.forms["register" + step].province.selectedIndex = 0;

        document.forms["register" + step].province.disabled = true;

    }

    else document.forms["register" + step].province.disabled = false;

}



function updatePLS(defaultCountry) {

    var f = document.forms["f_fullsearch"];

    if (f.country.options[f.country.selectedIndex].value != defaultCountry) {

        f.province.selectedIndex = 0;

        f.province.disabled = true;

    }

    else f.province.disabled = false;

}



function goToStep(nextStep, currentStep) {

    if (nextStep == 1) document.forms["register" + currentStep].action.value = "UPDATE";

    document.forms["register" + currentStep].next_step.value = nextStep;

    document.forms["register" + currentStep].submit();

    return false;

}



function openSecPopup(image) {

    var w = window.open(image, 'legal', 'width=520,height=405,scrollbars=no,toolbar=no,personalbar=no,menubar=no,location=no,resizable=no');

}



function openSecLitePopup(userid, photoid) {

    //var w = window.open("/photos/popuplite?userid=" + userid + "&photoid=" + photoid, 'legal', 'width=520,height=500,scrollbars=no,toolbar=no,personalbar=no,menubar=no,location=no,resizable=no');

    var w = window.open("/photos/popuplite?userid=" + userid + "&photoid=" + photoid, 'legal', '');

}



function openSecNavPopup(userid, photoid) {

    //var w = window.open("/photos/popup?userid=" + userid + "&photoid=" + photoid, 'legal', 'width=520,height=495,scrollbars=no,toolbar=no,personalbar=no,menubar=no,location=no,resizable=no');

    var w = window.open("/photos/popup?userid=" + userid + "&photoid=" + photoid, 'legal', '');

}



function openMainPopup(image) {

    var w = window.open(image, 'legal', 'width=214,height=165,scrollbars=no,toolbar=no,personalbar=no,menubar=no,location=no,resizable=no');

}

