// connect the onmousedown event of the document object to our function
// for Netscape Navigator 4.x
/*	if (document.layers) 
		noRightClick(window.captureEvents(Event.MOUSEDOWN));
	else	
		document.onmousedown = noRightClick;	
*/		
//	if (ns && appMajor < 5) window.onmousedown = noRightClick;
// window.onresize = reloadPage(true);

function Trim(trim_value) {
	if (trim_value.length < 1) return '';    
	trim_value = RTrim(trim_value);
	trim_value = LTrim(trim_value);	
	if (trim_value == '') 
		return '';
	else 
		return trim_value;		
} //End Function

function RTrim(value) {
	var w_space = String.fromCharCode(32);
	var v_length = value.length;
	if (v_length < 1) return '';	
	var strTemp = '';
	var iTemp = v_length - 1;
	while (iTemp > -1) {
		if (value.charAt(iTemp) != w_space) {
			strTemp = value.substring(0, iTemp + 1);
			break;
		}
		iTemp = iTemp - 1;
	} //End While	
	return strTemp;
} //End Function

function LTrim(value) {
	var w_space = String.fromCharCode(32);
	var v_length = value.length;
	if (v_length < 1) return '';	
	var strTemp = '';
	var iTemp = 0;	
	while (iTemp < v_length) {
		if (value.charAt(iTemp) != w_space) {
			strTemp = value.substring(iTemp, v_length);
			break;
		}
		iTemp = iTemp + 1;
	} //End While	
	return strTemp;
} //End Function

function MinMaxW(a,b) {
	var nw = "auto", w = document.documentElement.clientWidth;
	if (w >= b) { nw = b + "px"; } if(w <= a) { nw = a + "px"; }
	return nw;
} // End Funtion

function findObj(n, d) { //v3.0
  	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 = findObj(n, d.layers[i].document);
  	return x;
}

function preloadImages() { //v3.0
	var d = document;
 	if (d.images) {
 		if (!d.pix) d.pix = new Array();
   		var i, j = d.pix.length, a = preloadImages.arguments;
   		for (i = 0; i < a.length; i++) {
   			if (a[i].indexOf("#") != 0) {
   				d.pix[j] = new Image;
   				d.pix[j++].src = a[i];
   			}
   		}	
   	}
}

function reloadPage(init) { 
	// Environment: Netscape Navigator 4.x+
	if (init == true) with (navigator) {
		if ((appName.toLowerCase() == "netscape") && (parseInt(appVersion) >= 4)) {
			document.pgW = innerWidth;
			document.pgH = innerHeight;
			onresize = reloadPage;
		}
	}
	else if (innerWidth != document.pgW || innerHeight != document.pgH)
		location.reload();
}

function swapImage() { //v3.0
  	var i, j = 0, x, a = swapImage.arguments;
  	document.imgSrc = new Array();
  	for (i = 0; i < (a.length - 2); i += 3) {
	   if ((x = findObj(a[i])) != null) {
	       document.imgSrc[j++] = x;
	    	if (!x.oSrc) x.oSrc = x.src;
	    	x.src = a[i + 2];
	   }
    }
}

function swapImgRestore() { //v3.0
  	var i, x, a = document.imgSrc;
  	for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++)
  		x.src = x.oSrc;
}

function noRightClick(e) {
    // Environment: IE 4.0+ and Nav4.x 	
	var strCRMsg = "All rights reserved by Mississauga Chiness Business Association!!";
	if ((document.layers) && (e.which > 1))	{	
		// for NN4.x 
		alert(strCRMsg);
	} 
	if ((document.all) && (event.button > 1)) {	
		// for IE4+
		alert(strCRMsg);		
	}
	if ((document.getElementById) && !(document.all) && (e.which == 3))	{	
		// for NN6+
		alert(strCRMsg);
		window.event.cancelBubble = false;
	}
	return;
}