/////////////////////////////////////////////////////////////////
//                                                             //
//        JavaScript Functions for EasyHTMLHelp                //
//                                                             //
/////////////////////////////////////////////////////////////////


function easyhhpopup(){	
	// Opens a popup window
	// Optional arguments: 
	//	href
	//	window name
	//	window width
	//	window height

	var n = arguments.length;
	if (n==0) {
		alert(" No arguments passed to easyhhpopup function \n in easyhhjavascript.js")
		return false;
	}

	var fn = arguments[0];
	if (n>1) var wn = arguments[1]; else wn = "easyhhpopup";
	if (n>2) var w  = arguments[2]; else w = 400;
	if (n>3) var h  = arguments[3]; else h = 300;
	
	var features = 'width='+w+',height='+h;
	features += ',resizable=yes,location=no,scrollbars=yes,toolbar=no,status=no';
	
	//alert(features);

	pwin = window.open(fn, wn, features);
	pwin.focus();
}


//Default mouseover script attaches to the anchor tag
function swap(id,name)
{
  if (document.anchors(id))
    {
    var sHref = document.anchors(id).href;
    if (sHref.substring(sHref.length - 1) != "#")
      {
      if (document.images(id)) document.images(id).src=name;
      }
    }
  else
    {
    if (document.images(id)) document.images(id).src=name;
    }
}




// Create the chmfile object for each page
function getchmfile(){
    document.chmfile = new Object();
    document.chmfile.fullname = "";
    document.chmfile.name = "";
    document.chmfile.path = "";
    document.chmfile.page = "";

	var ra, sl, a, X, Y, Z;
	ra = /:/;
	a = location.href.search(ra);
	sl = "::";
	Y = location.href.lastIndexOf(sl);
	if (a == 4) {		// file: or http: 
		Y = location.href.lastIndexOf("/");
		chmfile.page = unescape(location.href.substring(Y+1));
		if(location.href.substring(0,4) == "file"){
			chmfile.path = unescape(location.href.substring(8, Y+1));
			}
		}
	else	{
		if (a == 2) X = 14;	// mk:@MSITStore: 
		if (a == 7) X = 7;	// ms-its: 
		chmfile.fullname = unescape(location.href.substring(X, Y));
		Z = chmfile.fullname.lastIndexOf("\\");
		chmfile.path = unescape(chmfile.fullname.substring(0, Z+1));
		chmfile.name = unescape(chmfile.fullname.substring(Z+1));
		chmfile.page = unescape(location.href.substring(Y+3));
	}
//	alert(location.href+"\n\n"+"fullname="+chmfile.fullname+"\n"+"path="+chmfile.path+"\n"+"name="+chmfile.name+"\n"+"page="+chmfile.page);
}


