// JavaScript Document


/*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];}}
}
	
MM_preloadImages('');*/
	
function clear_field(v, defString){
	if(v.value==defString) v.value="";
	}
	
function do_search(fm_id){
	document.getElementById(fm_id).submit();	
	}
	
function confirm_delete(vic, vicID, dscript){
	if(confirm("Are you sure you want to delete "+vic+"?")){
		location.href=dscript+"?pass="+vicID
	}
}

// ****************************	
// Browser version
// ****************************

var ua=navigator.userAgent;

function get_IE_version(){
	var offset=ua.indexOf("MSIE ");
	return parseFloat(ua.substring(offset+5, ua.indexOf(";", offset)));	
	}

/*************************************************\
Together with the divs and maps below 
this makes a neat little fader upper
cut down from wecdc_fade.js
\*************************************************/

var div_opacity=0;
var div_timer=0;
var prog_timer=0
version=get_IE_version();

function fadeStart(pnl, endOp, imgId, imgSrc, anchorObject){
	var args=fadeStart.arguments
	var ov_id=pnl+"_overlay"
	if(args.length>2){
		document.getElementById(args[2]).src=args[3];
		}
	//set initial opacity pnl to 0 b4 this style to block. make pnl_overlay visible till fadestart
		document.getElementById(pnl).style.opacity=0
		document.getElementById(pnl).style.display="block";
		
		//branch fade inits
		if(version>=5.5){
				if(anchorObject){
					//alert("Yes there is an anchor - its parents name is "+document.getElementById(anchorObject).offsetParent.id+" and its at "+document.getElementById(anchorObject).offsetParent.offsetTop+"px")
							document.getElementById(pnl).style.top=document.getElementById(anchorObject).offsetParent.offsetTop-200+"px";
							document.getElementById(ov_id).style.top=document.getElementById(anchorObject).offsetParent.offsetTop-100+"px";
							}
				endOp=endOp*100
				document.getElementById(pnl).style.filter ="progid:DXImageTransform.Microsoft.Alpha(opacity="+0+")"
				document.getElementById(pnl+"_image").onload=function(){
						document.getElementById(ov_id).style.display="none"
						
						div_timer=setInterval("fade_up_ie('"+pnl+"',"+endOp+")", 30);
						clearInterval(prog_timer)
				}
		}else{
				//if(version>=0){
						//ie lt 5.5 not supported yet
				//}else{
					// moved this in here cos explorer cant deal with it
						make_overlay(pnl, "Loading...");
						if(anchorObject){
							document.getElementById(pnl).style.top=window.pageYOffset+"px";
							document.getElementById(ov_id).style.top=window.pageYOffset+40+"px";
						}
					document.getElementById(pnl+"_image").onload=function(){
							document.getElementById(ov_id).style.display="none"
							div_timer=setInterval("fade_up_ff('"+pnl+"',"+endOp+")", 30);
							clearInterval(prog_timer)
					}
				//}
		}
}

function fadeEnd(d){
		var args=fadeEnd.arguments
		
		//branch hide map masks
				if(version>=5.5){
						document.getElementById(d).style.filter ="progid:DXImageTransform.Microsoft.Alpha(opacity="+0+")"
		}else{
				if(version>=0){
						//ie lt 5.5 not supported yet
				}else{
						document.getElementById(d).style.opacity=0;
				}
		}
		//reset mid fade masks
		div_opacity=0;
		if(div_timer) clearInterval(div_timer)
		if(args.length>1 && args[1]==0) document.getElementById(d).style.display="none";
}

function fade_up_ie(d, endOp){
		if(!div_opacity) div_opacity=0;
		div_opacity+=10;
document.getElementById(d).style.filter ="progid:DXImageTransform.Microsoft.Alpha(opacity="+div_opacity+")"

		if(div_opacity>=endOp){
			clearInterval(div_timer)
			div_opacity=0;
		}
}

function fade_up_ff(d, endOp){
	//alert("fade_up_ff called")
		if(!div_opacity) div_opacity=0;
		div_opacity+=0.1;
		document.getElementById(d).style.opacity=div_opacity;
		if(div_opacity>=endOp){
			clearInterval(div_timer)
			div_opacity=0;
		}
}



function make_overlay(pnl_id, msg){
			ov_id=pnl_id+"_overlay"
			document.getElementById(pnl_id+"_image").onload=function(){
				clearInterval(prog_timer)
				document.getElementById(ov_id).style.display="none"
				}
			obj=document.getElementById(ov_id)
			obj.innerHTML="<p id=\"overlay_text\" style=\"margin:0px;\">"+msg+"</p>";
			obj.style.display="block";
			prog_timer=setInterval("progress_bar('overlay_text')", 500)
	}

function progress_bar(ov){
	document.getElementById(ov).innerHTML+='.'
	}

	

