<!--
function addLoadEvent(func) {  
  var oldonload = window.onload;  
  if (typeof window.onload != 'function') {  
    window.onload = func;  
  } else {  
    window.onload = function() {  
      if (oldonload) {  
        oldonload();  
      }  
      func();  
    }  
  }  
}  

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
    var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array;
    for(i=0;i<(a.length-2);i+=3){if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x;
    if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}}
}


function showLayer(layerName){
    if (document.getElementById){
        var targetElement = document.getElementById(layerName);
        targetElement.style.visibility = 'visible';
        targetElement.style.height = 'auto';
    }
}

function hideLayer(layerName){
    if (document.getElementById) {
        var targetElement = document.getElementById(layerName);
        targetElement.style.visibility = 'hidden';
        targetElement.style.height = '0px';
    }
}


// POPUP MENU
function show(id) {
    document.getElementById(id).style.visibility = "visible";
    for(var i=1; i<8; i++){
        layerID = "topnav_" + i;
        if(document.getElementById(layerID)){
            if(layerID != id && document.getElementById(layerID).style.visibility == "visible"){
                document.getElementById(layerID).style.visibility = "hidden";
            }
        }
    }
}
function hide(id) {
    for(var i=1; i<8; i++){
        layerID = "topnav_" + i;
        if(document.getElementById(layerID)){
            if(layerID != id && document.getElementById(layerID).style.visibility == "visible"){
                document.getElementById(layerID).style.visibility = "hidden";
            }
        }
    }
}

// HREF VIA JAVASCRIPT EVENT
function redirect(url) {
    window.location = url;
}


// new window popup used for opening up artwork and flash projects
function launchwin(uri,name,args){
    //args += ",resizable=no";
    var newwin = window.open(uri,name,args);
    newwin.focus();
}


// USER TYPES EMAIL INTO FORM AND USES THIS FUNCTION TO REDIRECT TO A 'SEND PASSWORD TO MY EMAIL' PAGE
function requestpass(){
    var e = document.form1.email.value;
    uri = "actions/forgotpass.php?email=" + e + "";
    top.location.replace( uri );
}


// WEB BASED 'BACK' BUTTON
function go_back(){
    history.back();
}


// FOR USE IN CMS... CONFIRM ACTION BEFORE SUBMITTING TO db_update PAGE
function confirmSubmit(conf){
    var agree=confirm(conf);
    if (agree){
        return true ;
    } else {
        return false ;
    }
}

function confirmLink(message,destination){
    var agree = confirm(message);
    if (agree){
        window.location = destination;
    }
}

// MEDFINDS ONLY
var acctType = "";
function schoolOrProvider(userSelection){
    if(userSelection == "student") var footerText = "<br><br>If this sounds like you, click below to register as a "+userSelection+":";
    else var footerText = "<br><br>If this sounds like you, click below to register as a "+userSelection.substring(0,(userSelection.length - 1))+":";
	if(userSelection == "student"){
        document.getElementById("form_user").src = "images/buttons/btn_userpatient.gif";
		document.getElementById("form_user").oSrc = "";
        document.getElementById("form_school").src = "images/buttons/btn_school.gif";
		document.getElementById("form_school").oSrc = "";
        document.getElementById("form_student").oSrc = "images/buttons/btn_student_blue.gif";
        document.getElementById("schoolOrProviderText").innerHTML = document.getElementById("studentText").innerHTML + footerText;
    
    } else if(userSelection == "schools"){
        document.getElementById("form_user").src = "images/buttons/btn_userpatient.gif";
		document.getElementById("form_user").oSrc = "";
        document.getElementById("form_school").oSrc = "images/buttons/btn_school_blue.gif";
        document.getElementById("form_student").src = "images/buttons/btn_student.gif";
		document.getElementById("form_student").oSrc = "";
        document.getElementById("schoolOrProviderText").innerHTML = document.getElementById("schoolText").innerHTML + footerText;
        
    } else if(userSelection == "users"){
        document.getElementById("form_user").oSrc = "images/buttons/btn_userpatient_blue.gif";
        document.getElementById("form_school").src = "images/buttons/btn_school.gif";
		document.getElementById("form_school").oSrc = "";
        document.getElementById("form_student").src = "images/buttons/btn_student.gif";
		document.getElementById("form_student").oSrc = "";
        document.getElementById("schoolOrProviderText").innerHTML = document.getElementById("userText").innerHTML + footerText;
    }
    acctType = userSelection;
    if(userSelection != null){
        document.getElementById("form_submit").style.visibility = "visible";    
    }
}

function chooseAccountType(){
    redirect("actions/register.php?step=1&accountType=" + window.acctType);
}

function setMembershipType(e){
	if (e) { //function may be called without an event object
		if (e.target) targ = e.target;
		else if (e.srcElement) targ = e.srcElement;
		if (targ.nodeType == 3) // defeat Safari bug
			targ = targ.parentNode;
		if (targ.checked) { //special case for clicking on the radio button itself
			targ.checked = true;
		} else {
			targ.children[0].checked = true
		}
	}
	if (document.forms.register.providership_cost.length) {
		for (i = 0; i <= document.forms.register.providership_cost.length; i++) {
			var item = document.forms.register.providership_cost[i]
			if (!item) 
				return;
			if (item.checked) {
				//color this div
				item.parentNode && (item.parentNode.className = "providershipCostSelected")
				showHideCCForm(document.getElementById('pCost_raw_' + item.value).innerHTML, 'paymentForm')
			}
			else {
				//uncolor this div
				item.parentNode && (item.parentNode.className = "providershipCost")
			}
		}
	} else {
		showHideCCForm(document.getElementById('pCost_raw_1').innerHTML, 'paymentForm');
		document.getElementById('pCost_1').children[0].checked=true;
	}
}


// FIX COLUMN HEIGHT TO MATCH THE HIGHEST COMMON DENOMINATOR
function fixColumnHeight(pg){
    if(pg == 'home'){
        colA = document.getElementById("latestFinds");
        colB = document.getElementById("featuredBlogs");
        
        /*
        alert(colA.offsetHeight+"/"+colB.offsetHeight);
        
        if(colA.offsetHeight > colB.offsetHeight){
            colB.style.height = (colA.offsetHeight) + "px";
        } else {
            colA.style.height = (colB.offsetHeight) + "px";
        }
        //*/
    
    } else if(document.getElementById("columnLeft") && document.getElementById("columnRight")){
        colA = document.getElementById("columnLeft");
        colB = document.getElementById("columnRight");
        colC = document.getElementById("loginBlock");
        
        if(colA.offsetHeight > (colB.offsetHeight + colC.offsetHeight)){
            colB.style.height = ((colA.offsetHeight - colC.offsetHeight) + 4) + "px";
        } else {
            colA.style.height = ((colB.offsetHeight + colC.offsetHeight) - 55) + "px";
        }
        
    } else if(document.getElementById("insideLeft") && document.getElementById("columnRight")){
        colA = document.getElementById("insideLeft");
        colB = document.getElementById("columnRight");
        colC = document.getElementById("loginBlock");
        
        if(colB.offsetHeight > colA.offsetHeight) colA.style.height = colB.offsetHeight + "px";
        
    }
}


// show/hide creditcard payment form
function showHideCCForm(cost,divName){
    if (cost > 0) {
		document.getElementById("accountPrice").innerHTML = "Please enter your payment information below.<br><b>Charge for the selected account is $" + cost + "</b>";
		document.getElementById(divName).style.visibility = "visible";
		document.getElementById(divName).style.height = "auto";
	}
	else 
		/*if (cost) { //'cost' is in fact a generic description in this case. used for schools currently
			document.getElementById("accountPrice").innerHTML = cost;
			document.getElementById(divName).style.visibility = "visible";
			document.getElementById(divName).style.height = "auto";
		}
		else */ {
			document.getElementById(divName).style.visibility = "hidden";
			document.getElementById(divName).style.height = "0px";
		}
}

// my finds
function myFinds(findID, isChecked, returnPg){
    if(isChecked == " checked"){
        // GET to the REMOVE script
        redirect("actions/my_finds.php?do=remove&id=" + findID + "&returnPg=" + returnPg);
        
    } else {
        // GET to the ADD script
        redirect("actions/my_finds.php?do=add&id=" + findID + "&returnPg=" + returnPg);
        
    }
}


//-->