//Function to open preview window
function OpenPreviewWindow(formName){

	now = new Date; 
	submitAction = formName.action;
	submitTarget = formName.target;
	
	//Open the window first 	
   	winOpener('','preview',1,1,680,400)
   		
   	//Now submit form to the new window
   	formName.action = 'RTE_popup_preview.asp?ID=' + now.getTime();	
	formName.target = 'preview';
	formName.submit();
	
	//Reset submission
	formName.action = submitAction;
	formName.target = submitTarget;
}

//Function to hover button icon
function overIcon(iconItem){
	iconItem.className='WebWizRTEbuttonOver';
}

//Function to moving off button icon
function outIcon(iconItem){
	iconItem.className='WebWizRTEbutton';
}
function popupShow() {
  document.getElementById('popupDiv').style.display='block';
  return false
}
function popupHide() {
  document.getElementById('popupDiv').style.display='none';
  return false
}

function getObject(obj) {
	var theObj;
	if(document.all) {
		if(typeof obj=="string") {
			return document.all(obj);
		} else {
			return obj.style;
		}
	}
	if(document.getElementById) {
		if(typeof obj=="string") {
			return document.getElementById(obj);
		} else {
			return obj.style;
		}
	}
	return null;
}
function CountChars(strSourceObject,strCounterObject,strText,intMaxCharacters) {
	var objSource = getObject(strSourceObject);
	var objCounter = getObject(strCounterObject);
	var NumCharsLeft = intMaxCharacters - objSource.value.length;

	if(NumCharsLeft <= 0) {
		NumCharsLeft=0;
		objSource.value=objSource.value.substr(0,intMaxCharacters);
	}
	objCounter.innerHTML = strText.replace("{CHAR}",NumCharsLeft);
}
