var loaded = false;
function loadImages() {
	if (document.images) {
            plus = LoadImage("/system/images/plus.gif");
	plusover = LoadImage("/system/images/plus_over.gif");
	minus = LoadImage("/system/images/minus.gif");
	minusover = LoadImage("/system/images/minus_over.gif");

		loaded = true;
	}
}

function LoadImage(img) {
		temp = new Image();
		temp.src = img;
		return temp;
}

function Roll(imgid,imgnew) {
	if (document.images) {
		document.images[imgid].src=eval(imgnew + ".src");
	}
}
function RollPhoto(id, last) {
  if (document.images) {
    thisPhoto = "photo" + id;
    document.photo.src=eval(thisPhoto + ".src");
    for (i=1; i <= last; i++) {
      imgid = "num"+i;
      if (i == id) {
         imgnew = imgid + "on";
         document.images[imgid].src=eval(imgnew + ".src");
      } else {
         imgnew = imgid;
         document.images[imgid].src=eval(imgnew + ".src");
      }
    }
  }
}

function initialize() {
	//loadImages();
	//setWindow();
  //PositionLoginButton();
doAutoSlide();
}

function PositionLoginButton (x, y) {
	//document.loginbutton.
}

//---------------------------------- form validators -------------------------------------------------

function ValidateLoginForm() {
  if (! IsAlphanum(document.Login.username.value,3)){
    document.Login.username.focus();
    alert("Please enter your Username.");
    return false;
  }
  if (! IsAlphanum(document.Login.password.value,3)){
    document.Login.password.focus();
    alert("Please enter your Password.");
    return false;
  }
  if (HasHTMLTag(document.Login.username.value)||HasHTMLTag(document.Login.password.value)){
    alert("HTML Tags are not accepted.");
    return false;
  }
  return true;
}

function ValidateJoinForm() {
  if (document.Join.name.value.length<3){
    document.Join.name.focus();
    alert("Please enter the Business Name.");
    return false;
  }
  if (document.Join.street.value.length<3){
    document.Join.street.focus();
    alert("Please enter the Street Address.");
    return false;
  }
  if (document.Join.zip.value.length<5){
    document.Join.zip.focus();
    alert("Please enter Zip Code.");
    return false;
  }
  if (document.Join.phone.value.length<7){
    document.Join.phone.focus();
    alert("Please enter Phone Number.");
    return false;
  }
  if (HasHTMLTag(document.Join.name.value)||HasHTMLTag(document.Join.email.value)){
    alert("HTML Tags are not accepted.");
    return false;
  }
  if (! IsValidEmail(document.Join.email.value)){
    document.Join.email.focus();
    alert("Please indicate your Email Address.");
    return false;
  }
  if (document.Join.agree.checked != true){
    alert("Use of this Web site or membership in its services\n requires your agreement to the Terms of Service.\nYou may not use this website unless you fully agree to its Term of Service.");
    return false;
  }
  return true;
}


//------- uni
function ValidateRegisterForm() {
  if (document.Register.first_name.value.length<2){
    document.Register.first_name.focus();
    alert("Please enter your First Name.");
    return false;
  }
  if (document.Register.last_name.value.length<2){
    document.Register.last_name.focus();
    alert("Please enter your Last Name.");
    return false;
  }
  if (! IsValidEmail(document.Register.email.value)){
    document.Register.email.focus();
    alert("Please indicate your Email Address.");
    return false;
  }
  if (document.Register.password.value.length<6){
    document.Register.password.focus();
    alert("Please enter Password.");
    return false;
  }
  if (document.Register.repassword.value.length<6){
    document.Register.repassword.focus();
    alert("Please Re-Type Password.");
    return false;
  }
  if (document.Register.card_number.value.length<12){
    document.Register.card_number.focus();
    alert("Please enter Card Number.");
    return false;
  }
  if (document.Register.street.value.length<4){
    document.Register.street.focus();
    alert("Please enter first line of your Primary Address.");
    return false;
  }
  if (document.Register.city.value.length<2){
    document.Register.city.focus();
    alert("Please enter City.");
    return false;
  }
  if (document.Register.state.value.length<2){
    document.Register.state.focus();
    alert("Please enter State or Province.");
    return false;
  }
  if (document.Register.zip.value.length<4){
    document.Register.zip.focus();
    alert("Please enter Zip / Postal Code.");
    return false;
  }
  return true;
}

function ValidateSearchForm() {
  if (document.Search.region.selectedIndex==-1){
  //if (document.Search.mregion.selectedIndex==-1){

    alert("Select a Search Region");
    return false;
//}else{
//  document.Search.region.value = document.Search.mregion.selectedIndex;
//}
  }
  return true;
}

function ValidateDepositForm() {
  if (document.Deposit.card_number.value.length<12){
    document.Deposit.card_number.focus();
    alert("Please enter a valid card number.");
    return false;
  }
  return true;
}

function ValidateUploadForm() {
  if (document.Upload.photo.value == ""){
    alert("Please locate Photo.\nClick Browse to begin.");
    return false;
  }
  if (document.Upload.photonumber.selectedIndex==0){
    alert("Please select the Photo Number");
    document.Upload.photonumber.focus();
    return false;
  }
  return true;
}

function ValidateContactForm() {
  return true;
}


function ValidateProfileForm() {
  var title = document.Profile.title.value;
  var about = document.Profile.about.value;
  var interests = document.Profile.interests.value;
  var about_match = document.Profile.about_match.value;
  //var city = document.Profile.city.value;
  //var state = document.Profile.state.value;
  //if (city == "null")
  //  document.Profile.city.value = "";
  //if (state == "null")
  //  document.Profile.state.value = "";
  if (title == "null")
    document.Profile.title.value = "";
   if (about == "null")
    document.Profile.about.value = "";
  if (interests == "null")
    document.Profile.interests.value = "";
  if (about_match == "null")
    document.Profile.about_match.value = "";
  //if (HasHTMLTag(city)){
  //  document.Profile.city.focus();
  //  InvalidCharAlert("City");
  //  return false;
  //}
  //if (HasHTMLTag(state)){
  //  document.Profile.state.focus();
  //  InvalidCharAlert("State/Province");
  //  return false;
  //}
  if (HasHTMLTag(title)){
    document.Profile.title.focus();
    InvalidCharAlert("Title");
    return false;
  }
  if (HasHTMLTag(about)){
    document.Profile.about.focus();
    InvalidCharAlert("About Me");
    return false;
  }
  if (HasHTMLTag(interests)){
    document.Profile.interests.focus();
    InvalidCharAlert("My Interests");
    return false;
  }
  if (HasHTMLTag(about_match)){
    document.Profile.about_match.focus();
    InvalidCharAlert("About My Match");
    return false;
  }

  if (document.Profile.age.selectedIndex == 0){
    document.Profile.age.focus();
    alert("Please indicate your age");
    return false;
  }
  if (document.Profile.height.selectedIndex == 0){
    document.Profile.height.focus();
    alert("Please indicate your height");
    return false;
  }
  if (document.Profile.weight.selectedIndex == 0){
    document.Profile.weight.focus();
    alert("Please indicate Weight");
    return false;
  }
  if (document.Profile.hair.selectedIndex == 0){
    document.Profile.hair.focus();
    alert("Please indicate Hair.");
    return false;
  }
  if (document.Profile.eyes.selectedIndex == 0){
    document.Profile.eyes.focus();
    alert("Please indicate color of your eyes.");
    return false;
  }
  if (document.Profile.region.selectedIndex == 0){
    document.Profile.region.focus();
    alert("Please indicate the region in which you reside");
    return false;
  }
  if (document.Profile.purpose.selectedIndex == 0){
    document.Profile.purpose.focus();
    alert("Please indicate your Purpose of joining Minoo.com");
    return false;
  }
  if (document.Profile.status.selectedIndex == 0){
    document.Profile.status.focus();
    alert("Please indicate your matital status");
    return false;
  }
  if (document.Profile.match_age_min.selectedIndex == 0){
    document.Profile.match_age_min.focus();
    alert("Please indicate the minimum desired age of your match");
    return false;
  }
  if (document.Profile.match_age_max.selectedIndex == 0){
    document.Profile.match_age_max.focus();
    alert("Please indicate the maximum desired age of your match");
    return false;
  }
  //if (document.Profile.about.length< 50)){
  //  document.Profile.about.focus();
  //  alert("Please write about yourself in About Me text area.");
  //  return false;
  //}
  return true;
}

function InvalidCharAlert(name) {
    alert("\tInvalid characters in \"" +name+ "\" field.\t\n\tNo HTML tags accepted for this field.\t");
}

function ValidateFindForm() {
  if (! IsAlphanum(document.Find.word.value,3)){
    document.Find.word.focus();
    alert("The search word must be at least 3 characters long,\nand may only consist of alpha-numerics, underline, and hyphen.");
    return false;
  }
  return true;
}
function ValidateOldTownFindForm() {
  if (document.Find.word.value.length<3){
    document.Find.word.focus();
    alert("The search word must be at least 3 characters long,\nand may only consist of alpha-numerics, underline, and hyphen.");
    return false;
  }
  return true;
}
function ValidatePayForm() {
  return true;
}
function ValidateFindLoginForm() {
  return true;
}

function ShowTerms() {
	showWin = window.open('http://www.inoldtown.info/terms.html','viewer','height=300,width=600,status,left=10,screenX=10,top=200,screenY=200,z-lock,scrollbars=yes');
}

