function showarchive() {
	var archive=document.getElementById("archive");
	var fundid=document.getElementById("fundid");
	if(!archive || !fundid) return false;
	var fund=parseInt(fundid.value);
	var number=archive[archive.selectedIndex].value;
	var month=number.split(":")[0];
	var year=number.split(":")[1];
	var url="pdf.php?fund="+fund+"&month="+month+"&year="+year;
	window.open(url,"archive","");
	return false;
}

function mainload() {
	var main=document.getElementById("main");
	if(!main || !main.innerHTML) return;
	main.innerHTML='<img src="images/funds/front/eye.jpg">';
}

function mainhover(fundid) {
	var main=document.getElementById("main");
	var ologo=0;
	if(!main) return;
	if(fundid<0) {
		for(key in data) {
			ologo=document.getElementById(data[key]['name']);
			setopacity(ologo,1);

		}
		main.innerHTML='<img src="images/funds/front/eye.jpg">';
		return;
	}
	var logo=document.getElementById(data[fundid]['name']);
	setopacity(logo,0.6);
	if(data[fundid]['year1']!=data[fundid]['year2']) {
		year1=data[fundid]['year1'];
		year2=data[fundid]['year2'];
	}
	else {
		year1='';
		year2='';
	}
	var html="<table class=\""+data[fundid]['name']+"\" cellpadding=0 cellspacing=0>";
	html+="<tr><td colspan=2 class=\"text\">"+data[fundid]['description']+"</td>";
	html+="<td rowspan=3 class=\"image\"><img src=\"images/funds/front/"+data[fundid]['name']+"_graph.jpg\"></td></tr>";
	html+="<tr><th class=\"price\">"+data[fundid]['month1']+" "+year1+" "+data[fundid]['final1']+"</th><td class=\"price "+data[fundid]['name']+"faint\"><span class=\"bold\">PRICE</span> $"+data[fundid]['price1']+"</td></tr>";
	html+="<tr><th class=\"price\">"+data[fundid]['month2']+" "+year2+" "+data[fundid]['final2']+"</th><td class=\"price "+data[fundid]['name']+"med\"><span class=\"bold\">PRICE</span> $"+data[fundid]['price2']+"</td></tr>";
	html+="</table>";
	main.innerHTML=html;
	
	return false;
}

function fade(id,level) {
	obj=document.getElementById(id);
	if(!obj) return;
	setopacity(obj,level);
}

function  setopacity(obj,level) {
	if(!obj) return;
	if(typeof(obj.style.filter)!="undefined") obj.style.filter="alpha(opacity="+level*100+")";
	else obj.style.opacity=level;
}

function tab(id,over) {

	if(over) addclassname(id,"sel");
	else removeclassname(id,"sel");

}

function strip_spaces(str) {
	var regexp=/^\s+/g;
	var mystring='';
	mystring=str.replace(regexp,'');
	return mystring;
}

function addclassname(elem,cn) {
        if(!elem) return;
        cn=cn.toLowerCase();
        //add the classname if it doesn't already exist
        if(elem.className.toLowerCase().indexOf(cn)==-1) elem.className=strip_spaces(elem.className+" "+cn);
		
}

function removeclassname(elem,cn) {
        //remove the classname
        if(!elem) return;
        var myclassess,newclass='',i=0;
        cn=cn.toLowerCase();
        elem.className=elem.className.toLowerCase();
        if(elem.className.indexOf(cn)!=-1) {
                myclasses=elem.className.split(" ");
                for(i=0; i<myclasses.length; i++) {
                        if(myclasses[i]!=cn) newclass=newclass+" "+myclasses[i];
                }
                elem.className=strip_spaces(newclass);
        }
}

function swap_final(name,type) {
	fname="final_"+name;
	pname="preview_"+name;
	
	if(type==1) {
		
	}

}

function delete_attachment(name) {
	var dm=document.getElementById('deletemail');
	if(!dm) {
		alert("Sorry, but we cannot delete this attachment at this time");
		return false;
	}
	dm.value=name;
	document.forms[0].submit();

}

function upload_item(id) {
	var url='mailupload.php?id='+id;
	var upload=window.open(url,'upload','width=300px,height=120px');
	upload.focus();
}

function popup(url) {
	var popup=window.open(url,'popup','width=650px,height=800px');
	popup.focus();
}

