//function window.onerror(msg,url,line){
//	var date = document.lastModified;
//	var host = window.location.host;
//	//error=window.open("error","_blank","width=320,height=200");
//	//if (url.indexOf("file://")!=-1) {url=unescape(url).substring(7,url.length).toLowerCase();}
//	//error.document.write("<body bgcolor=buttonFace style=\"margin:0;font-family:tahoma;border:0;\"><table height=\"100%\" width=\"100%\"  border=\"0\" cellspacing=\"6\" cellpadding=\"0\"><tr><td><div style=\"font-size:12;\" align=\"center\"><strong><sub><sub></sub></sub>Javascript Error </strong></div></td></tr><tr><td><div style=\"font-size:12;\" align=\"center\"> "+msg+"<br>URL: \""+url+"\"<br>Last Modified: "+date+"<br>Line Number: "+line+"</div></td></tr><tr><td valign=bottom><div style=\"font-size:12;\" align=\"center\"><input name=\"Submit\" type=\"submit\" onClick=\"window.close();return false;\" value=\"    OK    \"></div></td></tr></table></font>");
//	//error.document.title=unescape("Javascript Error                                 ");
//	alert(msg + "\r" + url + "\r" + line);
//	return true;
//}
function sleep(Amount){
	d = new Date(); //today's date
	while (1){
		mill=new Date(); // Date Now
		diff = mill-d; //difference in milliseconds
		if( diff > Amount ) {break;}
	}
}


/**
 * writes the value of 'selectValue' to 'selectFieldHolder'
 * @param String selectHolderField 	- form field on page to hold value
 * @param String selectValue		- value to write to form field
 */	
function writeSelectValue(form, selectHolderField, selectValue){
	eval("window.document.forms['" + form + "']." + selectHolderField + ".value = '" + selectValue + "'");
}

function writeSelectValueFromIFRAME(form, selectHolderField, selectValue){
	eval("window.parent.document.forms['" + form + "']." + selectHolderField + ".value = '" + selectValue + "'");
}

function submit(form){
	window.document.forms[form].submit();
}

function submitFromIFRAME(form){
	window.parent.document.forms[form].submit();
}

/**
 *
 *
 */
function newWindow(name, url){
	window.open(url,name,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=480,height=480');
}

/**
 *
 *
 */
function openNewWindow(url, name, scrollbars, resizable, width, height){
	newWindow = window.open("","",'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=' + scrollbars + ',resizable=' + resizable + ',width=' + width + ',height=' + height);
	newWindow.location = url;
}

/**
 *Write content to a div tag
 *div1	= string representation of the outer div
 *div2	= string representation of the div to be written to
*/
function WriteLayer(ID,parentID,sText) { 
	if (document.layers) { 
   		var oLayer; 
   		if(parentID){ 
    		oLayer = eval('document.' + parentID + '.document.' + ID + '.document'); 
		}else{ 
			oLayer = document.layers[ID].document; 
		}
		oLayer.open(); 
	   	oLayer.write(sText);
   		oLayer.close(); 
	}else if (parseInt(navigator.appVersion)>=5 && (navigator.appName=="Netscape" || navigator.appName=="Mozilla")) {
   		document.getElementById(ID).innerHTML = sText; 
 	}else{
 		eval(ID + ".innerHTML = sText;");
 	}
}


function cleanFieldUp(inputField){
	inputField.value = escape(inputField.value);
	//alert(inputField.value);
	for(i=0; i<inputField.value.length; i++){
	
	 	if(inputField.value.indexOf("%0D%0A") > -1){
		inputField.value=inputField.value.replace("%0D%0A","<br>");
		}else if(inputField.value.indexOf("%22") > -1){
		inputField.value=inputField.value.replace("%22","&quot;");
		}else if(inputField.value.indexOf("%27") > -1){
		inputField.value=inputField.value.replace("%27","&#39;");
		}
	}
	inputField.value=unescape(inputField.value);
	//alert(inputField.value);
	return inputField.value;
}

function removeBreaks(inputField){
	alert(inputField.value);
	inputField.value = escape(inputField.value);
	alert(inputField.value);
	inputField.value=inputField.value.replace("%0D%0A","");
	alert(inputField.value);
	inputField.value=unescape(inputField.value);
	alert(inputField.value);
}


function showDiv(ID){ 
	document.getElementById(ID).style.display='block'; 
} 
  
function hideDiv(ID){ 
	document.getElementById(ID).style.display='none'; 
} 
 
 function isDisplayed(ID){
 	display = "";
	if (isNetscape()) { 
		display = document.getElementById(ID).style.display; 
	}else{ 
		display = eval(ID + ".style.display;"); 
    }
    if(display == ""){
    	return true;
    }else{
    	return false;
    }
 }
 
 function setDivVisible(ID, visible){
 	var vis = "visible";
 	if(!visible){
 		vis = "hidden";
 	}
	if (isNetscape()) { 
		document.getElementById(ID).style.visibility = vis; 
	}else{ 
		eval(ID + ".style.visibility = '" + vis + "';"); 
	} 
 } 
 
  
 function isNetscape(){ 
      if (parseInt(navigator.appVersion)>=5 && (navigator.appName=="Netscape" || navigator.appName=="Mozilla")){ 
           return true; 
      }else{ 
           return false; 
      } 
 }

/**
 *
 */
function imageswitch(path,val,image){
   	val.src=path + image;
}

function hilightText(val){
	val.style.color = "red";
}

function unhilightText(val){
	val.style.color = "black";
}

function formatCurrency(value){
	numberFormat = new NumberFormat(value);
	numberFormat.setNegativeFormat(numberFormat.PARENTHESIS);
	numberFormat.setNegativeRed(true);
	return numberFormat.toFormatted();
}

function showGalleryImage(image){
	thumbKey = "thumb";
	var imageRef = image.src;
	position = imageRef.indexOf(thumbKey);
	if(imageRef.indexOf(thumbKey) != -1){
		bigImage = imageRef.substring(0, position);
		bigImage += imageRef.substring(position + thumbKey.length, imageRef.length) + "jpg";
		openNewWindow(bigImage, "gallery", "yes", "yes", 750, 550);
	}else{
		thumbKey = "-sm.jpg";
		var imageRef = image.src;
		position = imageRef.indexOf(thumbKey);
		if(imageRef.indexOf(thumbKey) != -1){
			bigImage = imageRef.substring(0, position);
			bigImage += imageRef.substring(position + thumbKey.length, imageRef.length) + ".jpg";
			openNewWindow(bigImage, "gallery", "yes", "yes", 750, 550);
		}
	}
}

/**
 *
 */
function formFieldExists(formName, fieldName){
	if(window.document.forms[formName] != null){
		if(window.document.forms[formName].elements[fieldName] != null){
			//alert(window.document.forms[formName].elements[fieldName].value);
			//alert("field exists");
			return true;
		}else{
			//alert("field doesn't exist");
			return false;
		}
	}else{
		//alert("form doesn't exist");
		return false;
	}
}

/**
function ValidatePhone(m){
	n = m.name;
	p1 = m
	p = p1.value
	if(p.length == 3){
		pp=p;
		d4=p.indexOf('(')
		d5=p.indexOf(')')
		if(d4==-1){
			pp="("+pp;
		}
		if(d5==-1){
			pp=pp+")";
		}
		document.frmPhone.txtphone.value="";
		document.frmPhone.txtphone.value=pp;
	}
	if(p.length > 3) {
		d1=p.indexOf('(')
		d2=p.indexOf(')')
		if (d2==-1){
			l30=p.length;
			p30=p.substring(0,4);
			p30=p30+")"
			p31=p.substring(4,l30);
			pp=p30+p31;
			document.frmPhone.txtphone.value="";
			document.frmPhone.txtphone.value=pp;
		}
	}
	if(p.length > 5){
		p11=p.substring(d1+1,d2);
		if(p11.length > 3) {
			p12=p11;
			l12=p12.length;
			l15=p.length
			p13=p11.substring(0,3);
			p14=p11.substring(3,l12);
			p15=p.substring(d2+1,l15);
			document.frmPhone.txtphone.value="";
			pp="("+p13+")"+p14+p15;
			document.frmPhone.txtphone.value=pp;
		}
		l16=p.length;
		p16=p.substring(d2+1,l16);
		l17=p16.length;
		if(l17>3&&p16.indexOf('-')==-1){
			p17=p.substring(d2+1,d2+4);
			p18=p.substring(d2+4,l16);
			p19=p.substring(0,d2+1);
			pp=p19+p17+"-"+p18;
			document.frmPhone.txtphone.value="";
			document.frmPhone.txtphone.value=pp;
		}
	}
	setTimeout(ValidatePhone,100)
}
*/
