// checks existence of ID in markup
function checkID(idName) {
	if (document.getElementById(idName)) {
		return true;
	} else {
		return false;
	}
}

// focuses on element
function focusMe(idName) {
	if (checkID(idName)){
		document.getElementById(idName).focus();
	}
}

// submit an element
function submitMe(idName) {
	if (checkID(idName)) {
		document.getElementById(idName).submit();
	}
}

// submit an element
function resetMe(idName) {
	if (checkID(idName)) {
		document.getElementById(idName).reset();
	}
}

// sets the href of a value
function hrefMe(idName,h) {
	if (checkID(idName)) {
		document.getElementById(idName).href=h;
	}
}

// clears an element
function clearMe(t,val) {
	if (t.value==val) {
		t.value = '';
	}
}

// gives INNERHTML to an element
function htmlMe(idName,h) {
	if (checkID(idName)) {
		document.getElementById(idName).innerHTML = h;
	}
}

//gets the value
function getValue(idName) {
 if (checkID(idName)) {
 		return document.getElementById(idName).value;
	}
}

//gets the innerHTML
function getHTML(idName) {
 if (checkID(idName)) {
 		return document.getElementById(idName).innerHTML;
	}
}

// gives value to an ID
function valueMe(idName,val) {
	if (checkID(idName)){
		document.getElementById(idName).value=val;
	}
}

// gets the class
function getClassName(idName) {
 if (checkID(idName)) {
 		return document.getElementById(idName).className;
	}
}

// shows a html block
function showMe(idName) {
	if (checkID(idName)) {
		document.getElementById(idName).style.display="block";
	}
}

// shows a html block
function showMe2(idName) {
	if (checkID(idName)) {
		document.getElementById(idName).style.display="inline";
	}
}

// hides a html block
function hideMe(idName) {
	if (checkID(idName)) {
		document.getElementById(idName).style.display="none";
	}
}

// changes a stylesheet class to a specified ID
function changeClass(idName,toClass) {
	if (checkID(idName)) {
		document.getElementById(idName).className=toClass;
	}
}

function topOn(zone,idName) {
	document.getElementById("top"+zone+idName).className="top"+zone+"On";
}

function topOff(zone,idName) {
	document.getElementById("top"+zone+idName).className="top"+zone;
}

function Popup(myUrl,popType) {
	var winName='a';
	var d = new Date();
	var winTime = d.getUTCHours()+'_'+d.getUTCMinutes()+'_'+d.getUTCSeconds();

	switch (popType) {
		case 1:   // upload
			var winTop=100;
			var winLeft=100;
	  	pop = window.open(myUrl,winName,'width=450,height=220,top=' + winTop + ',left=' + winLeft + ',toolbar=no,scrollbars=yes,resizable=yes,location=no,menubar=no,directories=no,status=yes,copyhistory=no');
		break
		case 2:   // preview
			var winTop=100;
			var winLeft=100;
	  	pop = window.open(myUrl,winName,'width=709,height=493,top=' + winTop + ',left=' + winLeft + ',toolbar=no,scrollbars=yes,resizable=yes,location=no,menubar=no,directories=no,status=yes,copyhistory=no');
		break
		case 3:   // preview
			var winTop=100;
			var winLeft=100;
	  	pop = window.open(myUrl,winName,'width=600,height=500,top=' + winTop + ',left=' + winLeft + ',toolbar=no,scrollbars=yes,resizable=yes,location=no,menubar=no,directories=no,status=yes,copyhistory=no');
		break
	}

	pop.focus();

}

function matchArray(val,arr1,arr2) {
	var output = "";
	for (a = 0; a < arr1.length; a++) {
		if (val == arr1[a]) {
			output = arr2[a];
		}	
	}
	return output;
}


function checkMatch(thisValue,curValue,showThis,showThat) {
	var output = "";
	if (thisValue == curValue) {
		output = showThis;
	} else {	
		output = showThat;
	}
	return output;
}