// various Medium specific scripts

// navigation: teach IE about :hover
sfHover = function() {
	var sfEls = document.getElementById("navigation_ul").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


// submission form: add another image box
imageFormCount = 1;
function addImageForm() {
	imageFormCount++;
	str = $('image_form_base').innerHTML.gsub(/Image_1/, "Image_"+imageFormCount );
	html = '<h3>Image #'+imageFormCount+'</h3><div class="image_form" id="Image_'+imageFormCount+'" style="display: none;">'+str+'</div>'
	new Insertion.Top( 'image_forms', html);
	new Effect.Appear('Image_'+imageFormCount);
}

// verify submit work form; don't use builtin zem_contact stuff, which requires a roundtrip
function verifySubmissionForm() {  
  if( $F('agreetoterms') != 'on' ) {
    alert("You must agree to the terms and conditions of submission.");
    return false;
  }
  else if( !Field.present('name','email', 'school', 'howdyouhearaboutus') ) {
    alert("Please fill in all the required info about yourself (name, e-mail, school, how you heard about us)");
    return false;
  }
  else {
    // check images
    for(var n = 1;; n++) {
      if( !Field.present('Image_'+n, 'Image_'+n+'_Title', 'Image_'+n+'_Media', 'Image_'+n+'_Dimensions_X', 'Image_'+n+'_Dimensions_Y', 'Image_'+n+'_Year') ) {
        alert("Missing information for Image #"+n);
        return false;
      }
    }
    return true;
  }
}