function Print()
{
	window.print();
}

function Back()
{
	history.back();
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
    //document.getElementById(id).scrollIntoView(true);
}

function showdiv(id) {
	//safe function to show an element with a specified id

	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
    //document.getElementById(id).scrollIntoView(true);
}

function showdivWithOffset(id, control, xOffset, yOffset) {
	//safe function to show an element with a specified id
    document.getElementById(id).style.top = (control.offsetTop + yOffset) + 'px';
	document.getElementById(id).style.left = (control.offsetLeft + xOffset) + 'px';	
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
    //document.getElementById(id).scrollIntoView(true);
}

function showdivforcopygeneric(id, control, xOffset, yOffset, displayNameFrom, displayIdFrom, displayNameTo, displayIdTo) {
	//safe function to show an element with a specified id
    var clientIdString = control.id;
    var clientPathString = clientIdString.substr(0,clientIdString.indexOf("Add"));
    var clientPathRootString = "ctl00_ContentPlaceHolder1";
    
    document.getElementById(clientPathRootString + "_" + displayIdTo).value = clientPathString + displayIdFrom;
    document.getElementById(clientPathRootString + "_" + displayNameTo).value = clientPathString + displayNameFrom;
    
   
    document.getElementById(id).style.top = (control.offsetTop + yOffset) + 'px';
	document.getElementById(id).style.left = (control.offsetLeft + xOffset) + 'px';	
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
		
	}
    //document.getElementById(id).scrollIntoView(true);
}

function showdivforcopy(id, control, xOffset, yOffset, CUCName, CUC) {
	//safe function to show an element with a specified id
    var clientIdString = control.id;
    var clientPathString = clientIdString.replace("Add","");
    var clientPathRootString = "ctl00_ContentPlaceHolder1";
    

    document.getElementById(clientPathRootString + "_hdnCUC").value = clientPathString + CUC;
    document.getElementById(clientPathRootString + "_hdnCUCName").value = clientPathString + CUCName;
    
    document.getElementById(id).style.top = (control.offsetTop + yOffset) + 'px';
	document.getElementById(id).style.left = (control.offsetLeft + xOffset) + 'px';	
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
		
	}
}
function popUp(URL,width, height) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=" + width + ",height=" + height + ",left = 675,top = 475');");
}

function popUpScroll(URL,width, height) {
    alert('here');
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=" + width + ",height=" + height + ",left = 675,top = 475');");
}

function inStr(exp, inputstr){
	var regExp = new RegExp(exp,'g');
	return (regExp.test(inputstr));
}

function replaceStr(exp, inputstr, newString){
	var regExp = new RegExp(exp,'g');
	results = inputstr.replace(regExp, newString)
	return results;
}

// copy functions/////////////////////////////////////////////


function copyToArea(area, value)
{
    
	this.document.getElementById(area).innerHTML = value.replace("'","");
	if(this.document.getElementById(area + "Hidden"))
	{
	    this.document.getElementById(area + "Hidden").Value = value.replace("'","");
	}
}	

function copyToTextboxNoList(location, value)
{
	this.document.getElementById(location).value = value;
}

function copyToParent(location, area, parentLocation, parentArea){
	copyToParentTextbox(parentLocation, this.document.getElementById(location).value);
	copyToParentArea(' ',' ', parentArea, this.document.getElementById(area).innerHTML);
	return true;
}
function copyToParentTextbox(location, value){
	self.opener.document.getElementById(location).value = value;
}
function copyToParentArea(pre, post, location, value){
	self.opener.document.getElementById(location).innerHTML = pre + value + post;
}

function copyToTextbox(location, value){
	var text = this.document.getElementById(location).value;
	var exists = inStr(';' + value + ';', text);
	if( inStr(';' + value + ';', text) == true){
		//true so do not add
	}else{
		//not in string so add
		this.document.getElementById(location).value = this.document.getElementById(location).value + ";" + value + ";";
	}
}
function copyToTextboxAndArea(location, area, value){
	var text = this.document.getElementById(location).value;
	var exists = inStr(';' + value + ';', text);
	if( inStr(';' + value + ';', text) == true){
		//true so do not add
	}else{
		//not in string so add
		this.document.getElementById(location).value = this.document.getElementById(location).value + ";" + value + ";";
		this.document.getElementById(area).innerHTML = this.document.getElementById(area).innerHTML  + value +  "<br />";
	}
}

function removeFromTextbox(location, value){
	var text = this.document.getElementById(location).value;
	var newText = replaceStr(';' + value + ';', text, '');
	this.document.getElementById(location).value = newText;
	return true;
}
function removeFromTextboxAndArea(location, area, value){
	var text = this.document.getElementById(location).value;
	var newText = replaceStr(';' + value + ';', text, '');
	this.document.getElementById(location).value = newText;
	newText = replaceStr(';;', newText, '<br />');
	newText = replaceStr(';', newText, '');
	this.document.getElementById(area).innerHTML = newText;
	return true;
}

// array variables and functions ////////////////////////////////////
var list = new Array(0);

function add(value){
	list.push(value);
}

function remove(){
}

function clear(){
}


function deleteElement(array) {
	size = array.length;
	delindex = parseInt(prompt("Please enter the element index of the item to remove.",""));
	validNo = (delindex != "NaN");
	inRange = ( (delindex >= 0) && (delindex <= array.length) );

	if (validNo && inRange) {
		for (var i=0; i<=size; i++)
			array[i] = ((i == delindex) ? "delete" : array[i]);
		for (var j=delindex; j<size-1; j++)
		if (j != size) array[j] = array[j+1];
		array.length = size-1;
		alert("Element index " + delindex + " has been removed.  The other elements have moved to fill the spot.");
		showArray(array);
	}
		else alert("You only delete from element index 0 to " + (size-1) + ".");
	}

function showArray(array) {
	arraytext = "";
	for (var i=0; i<array.length; i++) {
		arraytext += "Element Index " + i + ":  " + array[i] + "\n";
	}
	document.form.text.value = arraytext;
}


function mask(num)
{  
     reg=/^(\d{2})(\d{2})(\d{4})/  
     return num.replace(reg,"" + "$1" + "\/" + "$2" + "\/" + "$3")  
}  

