sfHover = function() {
	var sfEls = document.getElementById("discipline").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);

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// clear the text in a text input type
function doClear(theObj) {
    theObj.value = "";
}

// left navigation hide and show
function ltnav(theObj,topItem) {
    var theElement = document.getElementById(theObj);
    var parentElement = document.getElementById(topItem);
    if(theElement.style.display == "" || theElement.style.display == "inline") { 
        theElement.style.display="none";
        parentElement.className = "";
    }
    else {
        theElement.style.display = "inline";
        parentElement.className = "active";
    }
}

function replaceSelects(toggleType) {
    var displayVal = 'none';
    
    // set the toggleType
    if(toggleType == 'show')
        displayVal = 'inline';
        
    //get all the input fields on the page
    inputs = document.getElementsByTagName('select');

    //cycle trough the input fields
    for(var i=0; i < inputs.length; i++) 
      inputs[i].style.display = displayVal;
}

function disciplineDropShow(theElement) {
  document.getElementById(theElement).style.display='block';
  replaceSelects('hide');
  return false
}
function disciplineDropHide(theElement) {
  document.getElementById(theElement).style.display='none';
  replaceSelects('show');
  return false
}

function pop() {
  document.getElementById('popoverdiv').style.display='block';
  return false
}
function hide() {
  document.getElementById('popoverdiv').style.display='none';
  return false
}
function pop2() {
  document.getElementById('popoverdiv2').style.display='block';
  return false
}
function hide2() {
  document.getElementById('popoverdiv2').style.display='none';
  return false
}

function showElement(theElement) {
  document.getElementById(theElement).style.display='block';
  return false
}
function hideElement(theElement) {
  document.getElementById(theElement).style.display='none';
  return false
}

// methods for cycling through featured content
var selectedFeature = 1;
function hideFeatures(total) {
    for (var i=1; i<=total; i++){
        currentFeature = "feature" + i;
        document.getElementById(currentFeature).style.display="none";
    }
}

var tItem;
function showFeature(total) {
    if(selectedFeature > total)
        selectedFeature = 1;
        
    hideFeatures(total);
    currentFeature = "feature" + selectedFeature;
    document.getElementById(currentFeature).style.display="inline";
    
    nextCall = "showFeature(" + total + ")";
    tItem = setTimeout(nextCall,5000);
    selectedFeature++;
}
function LimitAttach(form, file, width, hieght) {
    extArray = new Array(".jpg", ".png", ".bmp", ".gif");
    allowSubmit = false;
    var org_file=file;
    if (!file) return;
    while (file.indexOf("\\") != -1)
    file = file.slice(file.indexOf("\\") + 1);
    ext = file.slice(file.indexOf(".")).toLowerCase();
    for (var i = 0; i < extArray.length; i++) {
    if (extArray[i] == ext) { allowSubmit = true; break; }
    }
    if (allowSubmit) {
		if (getImgSize(org_file,width, hieght))
		{
			//alert(file);
			document.Form1.filename_1.value="/uploads/"+file;
			//alert(document.Form1.filename_1.value);
			form.submit();
		}
		else
		{
			return false;
		}
		//getImgSize(org_file,width, hieght);
		//return true;
    }
    else
    alert("Please only upload files that end in types:  "
    + (extArray.join("  ")) + "\nPlease select a new "
    + "file to upload and submit again.");
    return false;
}
function getImgSize(imgSrc,width, hieght, flag){
if(!flag){
	var newImg = new Image();
	imgSrc="file://localhost/"+imgSrc;
	newImg.src =imgSrc;
	
}
else
	var newImg = imgSrc
	if (typeof newImg.complete=='boolean'&&(newImg.complete&&newImg.height*1>0)){
	var l_height = newImg.height;
	var l_width = newImg.width;
	//alert ('The image size is '+l_width+'*'+l_height);
	//alert(l_height);
		if (eval(l_height>0) && eval(l_width>0))
		{
			if ( eval(l_width<=width) && eval(l_height<=hieght))
				{return true;}
			else {
				alert ('The Current image size is '+l_width+'*'+l_height+' \nSpecified allowed image size is '+width+'*'+hieght);
				return false;
			}
		}
	}
	else if (typeof newImg.complete=='boolean'){
	//alert('having trouble')
	setTimeout(function(){getImgSize(newImg,width, hieght,'x')}, 3000);	
	}
	else alert('Image cannot be evaluated for size');
}
