/*
***************************************
USEFUL and GENERIC JAVASCRIPT FUNCTIONS
***************************************
*/

function setStyle_func(obj, stylevar, styleval){
	obj.style[stylevar]=styleval
}

function gotourl_func(url){
	location.href=url
}

function OpenBrWindow(url, wname, topleft, fullscreen, appw, apph, scroll) {
	if (navigator.appName == "Microsoft Internet Explorer" && parseFloat(navigator.appVersion) > 3.0){
		if (topleft == 1){
			screenx = 0
			screeny = 0
		} else {
			sreenw = screen.width
			sreenh = screen.height
			screenx = (sreenw - appw)/2
			screeny = (sreenh - apph)/2
		}
		if (fullscreen == 1){
			fscreen = "fullscreen"
		} else {
			fscreen = ""
		}
		newWin = window.open(url, wname, "Toolbar=no,status=yes,"+fscreen+",scrollbars="+scroll+",resizable=yes,menubar=no,width="+appw+",height="+apph+",left="+screenx+",top="+screeny+", maximize=yes");
		return newWin;
	} else {
		alert("Microsoft Internet Explorer is required to view this site.")
	}
}
function chkBrwser_func(browser, verno){
	browser = navigator.appName;
	version = navigator.appVersion;
}

function getByID_func(id){
	return document.getElementById(id);
}

function checkform_func(form){
	formlen = form.length;
	submitform = 1;
	for (i=0;i<formlen;i++){
		//alert(form.elements[i].name)
		if (form.elements[i].type == "text" || form.elements[i].type == "textarea" || form.elements[i].type == "file" || form.elements[i].type == "password"){
			if (form.elements[i].value == "" ){
				submitform = 0
			}
		}
	}

	if (submitform == ""){
		alert("Please fill in all fields!!")
		return false;
	} else {
		form.submit();
	}
}


// ****** SELECT FUNCTIONS ********
function popSelect_func(selObj, len ,VarArrs, ValArrs){
	selObj.length = len;
	selObj.options[0].selected=true; // SET FIRST ONE SELECTED
	for(i=0;i<len;i++){
		selObj.options[i].value = ValArrs[i]
		selObj.options[i].text = VarArrs[i]		
	}
}

function setSelectLen_func(selObj, len){
	selObj.length = len;
}

function popSelect_func(selObj, optNo, optName, optVal){
	selObj.options[optNo].value = optName
	selObj.options[optNo].text = optVal		
}
// ********************************


// ****** SCROLL FUNCTIONS ********
function getScrollYPos_func(){
	return document.body.scrollTop;
}

function setScrollYPos_func(scrolly){
	scroll(0, scrolly);
}
// ********************************



/*

\b	Backspace
\f	Form feed
\n	New line
\r	Carriage return
\t	Tab
\'	Single Quote
\"	Double Quote
\\	Backslash

*/





function setNav_func(){
	chldrnDivs = document.getElementsByTagName('DIV');
	chldrnDivsLen = chldrnDivs.length;
	for(i=0;i<chldrnDivsLen;i++){
		if (chldrnDivs[i].className=="navbut" || chldrnDivs[i].className=="navbutadmin"){
			chldrnDivs[i].onmouseover=navMover_func
			chldrnDivs[i].onmouseout=navMout_func
		}
	}
}

function navMover_func(){
	this.style.background='#67666B'
}

function navMout_func(){
	this.style.background=''
}

function delfile_func(file, page){	
	var confmtxt
	confmtxt = confirm("Are you sure you want to delete this?")	
	if (confmtxt){
		location.href=page+"?sqlaction=delfile&thefile="+file
	}
}

function delfile_func(file, page){	
	var confmtxt
	confmtxt = confirm("Are you sure you want to delete this?")	
	if (confmtxt){
		location.href=page+"?sqlaction=delfile&thefile="+file
	}
}

function confrm_func(txt, url){	
	var confmtxt
	confmtxt = confirm(txt)	
	if (confmtxt){
		location.href=url
	}
}