// Jelili's Bunch of Lib Functions 
//
// window pop up
// src width height
//
	
function pop_doc(doc_src,doc_width,doc_height){
	 
	 var doc_src1 = ((doc_src == null) || (doc_src == '')) ? '': doc_src;
	 var doc_width1 = (doc_width == null) ? '200': doc_width;
     var doc_height1 = (doc_height == null) ? '200': doc_height;
	 var doc_size = "width=" + doc_width1 + ",height=" + doc_height1;
     window.open(doc_src1,"windoc",doc_size);
}






// Split Function Mx singular Split
// delimeter character eg :
// which word/phrase "12 " or "John", " Red Wagon" etc 
// text in which to look for value 
// I use this because the damn split function doesn't
// work on all platforms
function j_SplitMx(sep,which,inwhat){ 
	
	var n = 0;			// start of a phrase
	var wstr = 0;		// holds substring
	var i = 0;			// loop counter
	var s = 0;			// start of winning phrase
	var f = 0;          // end of winning phrase
	var inwhat = inwhat + ''; // I put this in because of a damn mac 4.5 bug !!!!			
	for (i = 1 ; i < which ; i++) 
		{
		 n = inwhat.indexOf(sep,n);	// look for separator
		   if (n < 0 )					// if you do not find it	
			{	
			 return '';				// return is empty string
			 break;					// jump out of loop
			}	
			n++;								// otherwise, loop again		
		 }
	
	// now we should be at the right place
	if ( n >= 0)							// ... but do this only if we
	   {											// found the separator
		
		var s = n;							// phrase starts with n, now s
		var f = inwhat.indexOf(sep,n);	// get next instance of sep
		if (f < 0 ) f = inwhat.length;	// but if there is none ...
		wstr = inwhat.substring(n,f);	// must be last phrase in string
	    }
	
	   return wstr;							// return string; it will be
										   // empty if sep was not found.
    }

// 
function j_Split(del,string){
  var MObject = new Array();
  var Array_pointer = 0;
  
  while (j_SplitMx(del,Array_pointer,string) != ''){
       MObject[Array_pointer] = j_SplitMx(del,Array_pointer,string);
	   Array_pointer++;
  }
  return MObject;
  
}


//Global variables

var isNav, isIE;
var coll = "";
var styleObj = "";

if (parseInt(navigator.appVersion) >= 4) {
   if (navigator.appName == "Netscape") {
       isNav = true;
} else {
    isIE = true;
	coll = "all.";
	styleObj = ".style"; 
   }
}

// ****Begin Utility Functions************************************

// Convert object name string or object reference
// into a valid object reference 
function getObject(obj){
     var theObj;
	 if (typeof obj == "string") {
	    theObj = eval("document." + coll + obj + styleObj);
		} else {
		       theObj = obj;
		}
		return theObj;
}

// set Zindex
function setZIndex(obj, zOrder) {
    obj.zIndex = zOrder;
	}
	
function setBorderColor(obj, color){
     obj.borderColor = color;
	}


function setBGColor (obj, color){
    var theObj = getObject(obj);
	if (isNav4) {
	    theObj.bgcolor = color;
		} else {
		   theObj.backgroundColor = color;
		}
}


function currPos(obj) {
    var theObj = getObject(obj);
	var dump = theObj.left;
	var trash = j_Split('px',dump);
	// this is suck a $%&!ING HACK  ... I hate Netscape
	if (isIE){ trash = dump.split('px');}
	return trash[0];
}

// set visibility visible
function show(obj) {
    var theObj = getObject(obj);
	theObj.visibility ="visible";
}

// set visibility to hidden
function hide(obj){
    var theObj = getObject(obj);
	theObj.visibility ="hidden";
}

//position an object at a specific point
function shiftTo(obj, x, y) {
     if(isNav){
	    obj.moveTo(x,y);
	 } else {
	     obj.pixelLeft = x;
		 obj.pixelTop = y;
	 }
}

//Move an object by x or y pixels
function shiftBy(obj, deltaX, deltaY) {
     var theObj = getObject(obj);
	 if (isNav) {
         theObj.moveBy(deltaX, deltaY);
	 } else {
       theObj.pixelLeft += deltaX;
	   theObj.pixelTop += deltaY;

	 }
}




//** end of Utility Functions *********************************

// Snap in or out
function Snap(what,how,why){
    var box = why;

 	var cp = currPos(what);
	if (cp <= 0){ 
	    how = how * -1;
	    
	
	}
	if (cp >= 0){ 
	how = how * 1;
	

   }
  shiftBy(what, how ,0);
  F_Clip(how,why);
  

}

function F_Clip(how2,why){
if(how2 >= 0){
  if ((isNav) && (document.choose.clip) && (why == 1)){
				document.choose.clip.width=65;
				document.point.clip.width=71;
				}
  if ((isIE) && (document.all.choose) && (why == 1)){
  				document.all.choose.style.clip = "rect(0px 66px 200px 0px)";
				document.all.point.style.clip = "rect(0px 71px 36px 0px)";
				}

  if ((isNav) && (document.choose.clip) && (why == 2)){
				 document.choose.clip.width=46;
				 document.point.clip.width=71;
				 }
  if ((isIE) && (document.all.choose) && (why == 2)){
  				document.all.choose.style.clip = "rect(0px 50px 200px 0)";
				document.all.point.style.clip = "rect(0px 71px 36px 0px)";
				}

  if ((isNav) && (document.choose.clip) && (why == 3)){
				document.choose.clip.width=75;
				document.point.clip.width=71;
				}
  if ((isIE) && (document.all.choose) && (why == 3)){
  				document.all.choose.style.clip = "rect(0px 75px 200px 0)";
				document.all.point.style.clip = "rect(0px 71px 36px 0px)";
				}

  
}
  
else {
     
		if ((isNav) && (document.choose.clip) && (why == 1)){
				document.choose.clip.width=245;
				document.point.clip.width=1;
}
		if ((isIE) && (document.all.choose) && (why == 1)){
				document.all.choose.style.clip = "rect(0px 247px 200px 0)";
				document.all.point.style.clip = "rect(0px 0px 0px 0px)";
				}

		if ((isNav) && (document.choose.clip) && (why == 2)){
		document.choose.clip.width=306;
		document.point.clip.width=1;
	    }
		if ((isIE) && (document.all.choose) && (why == 2)){
				document.all.choose.style.clip = "rect(0px 313px 200px 0)";
				document.all.point.style.clip = "rect(0px 0px 0px 0px)";
		}

		if ((isNav) && (document.choose.clip) && (why == 3)){
			document.choose.clip.width=287;
			document.point.clip.width=1;
}
		if ((isIE) && (document.all.choose) && (why == 3)){
			document.all.choose.style.clip = "rect(0px 291px 200px 0)";
			document.all.point.style.clip = "rect(0px 0px 0px 0px)";
			}

      
     }
// end of function
}



