
var explorerPaneStatus = "open";

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_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_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 getArgs(separator) {

	if (separator == ""){
		separator = "&";
	}
	
    var args = new Object(  );
    var query = location.search.substring(1);     
      // Get query string
    var pairs = query.split(separator);
     // Break at comma
    for(var i = 0; i < pairs.length; i++) {
        var pos = pairs[i].indexOf('=');
          // Look for "name=value"
        if (pos == -1) continue;
          // If not found, skip
        var argname = pairs[i].substring(0,pos);
          // Extract the name
        var value = pairs[i].substring(pos+1);
          // Extract the value
        args[argname] = unescape(value);
         // Store as a property
       // In JavaScript 1.5, use decodeURIComponent(  ) 
       // instead of escape(  )
    }
    return args;     // Return the object
}



function getExtension(filename){
    var txtmyPath = filename.replace(/^\s*/,"").replace(/\s*$/,"")
    var objRegExp = /.jpeg|.bmp|.gif$/

	var txtmyPath = txtmyPath.replace(/^[^\.]*\./,"");
            if (txtmyPath.replace(/[^\.]/g,"") != "")
                   {
                        alert("You can only have one '.' in a filename");
                        return false;
                   }
          
//         frm.file_type.value = txtmyPath;
		return txtmyPath;
         //return true;

}

function getFormGroupValue(Obj_checkBoxGroup){
	for(j=0; j< Obj_checkBoxGroup.length; j++){
		if(Obj_checkBoxGroup[j].checked){
			return Obj_checkBoxGroup[j].value;
		}
		else{}
	}  
	return null;
}  


function maximise(){
	window.moveTo(0,0);
	window.resizeTo(screen.availWidth,screen.availHeight);
}





function setLink(formName,fieldName) {

  eval("currentLink = "+formName+"."+fieldName+".value;");

  str=prompt("Enter url (starting with http://):", (currentLink > "") ? currentLink : "http:\/\/");

  if ((str!=null) && (str!="http://")) {
	eval(formName+"."+fieldName+".value = str");
  }
}

function setSiteLink(formName,fieldName,area){
	eval("var currLink = "+formName+"."+fieldName+".value;");
	newWin("linkPicker.asp?currLink="+currLink+"&area="+area+"&formName="+formName+"&fieldName="+fieldName,"linkpicker",500,100,"scrollbars=no,status=no");
}


function setShowHideIcon(){

	myImage = new Image();

  	if (explorerPaneStatus == "open"){
		myImage.src = "../menu-images/showhide_hide.gif"; // use the image that opens the pane
	} else {
		myImage.src = "../menu-images/showhide_show.gif"; // use the image that opens the pane
	}
	document.showhideImage.src = myImage.src;

}
  

function resize(layerName,increment,finalWidth){
	increment = increment * (-1);
	if (increment <0){
		grow(layerName,increment,finalWidth);
	} else {
		shrink(layerName,increment,finalWidth);
	}
	setDocumentVar("explorerPanelWidth",finalWidth);
}

function shrink(layerName,increment,finalWidth){	

	eval("newWidth = document.all."+layerName+".width - increment");
	
	// set the enw width	
	eval("document.getElementById('"+layerName+"').width = newWidth");
		
	if (newWidth > finalWidth){
		setTimeout("shrink(\""+layerName+"\","+increment+","+finalWidth+")",1);
	} else {
		eval("document.getElementById('"+layerName+"').width = finalWidth");	
		document.getElementById("mainPanel").width = screen.availWidth-finalWidth-20;
		setShowHideIcon()
	}
	
}

function grow(layerName,increment,finalWidth){	
	eval("newWidth = document.getElementById('"+layerName+"').width - increment");
	
	eval("document.getElementById('"+layerName+"').width = newWidth");
	
	if (newWidth < finalWidth){
		setTimeout("grow(\""+layerName+"\","+increment+","+finalWidth+")",1);
	} else {
		try{
			eval("document.getElementById('"+layerName+"').width = finalWidth");	
			window.top.document.getElementById("mainPanel").width = screen.availWidth-finalWidth-20;
			setShowHideIcon();
		} catch(er){
		}
	}
	
}



function toggleExplorerPane(force){

	if (force == "open"){
		// set the var to closed, so that it will open it
		explorerPaneStatus = "closed";
	} else if (force == "closed"){
		// set the var to closed, so that it will open it
		explorerPaneStatus = "open";
	}

		
	if (explorerPaneStatus == "open"){
		resize('explorerPanel',-45,0);
		explorerPaneStatus = "closed"; 
	} else {
		resize('explorerPanel',45,250);
		explorerPaneStatus = "open"; 
	}

}


function divider_drag(){
	x = event.clientX;
	y = event.clientY;
	if(x<0){x=0;}
	resize('explorerPanel',45,x);
}


function urlEncode (string) {
  string = string.replace(/ /g, '+');
  return escape(string);
}


