//<!--
function FileCheck(message,total){
	for (c=1; c<=total; ++c){
		if(document.getElementById('file' + c).value){
			if(!(window.confirm(message)))
			{
				return false;
			}
			break;
		}
	}
	return true;
}

function isdefined(variable){
    return (typeof(window[variable]) != 'undefined');
}

function setAnchor(anchor){
	if(anchor!=null){
		if(document.form1.action.indexOf('#') == -1)
			document.form1.action += '#' + anchor;
	}
}

function FileHide(value,total){
	for (c=1; c<=total; ++c){
		if(c<=value){
			style='';
		}
		else{
			style='none';
		}
		HideC('filetag' + c, style);
	}
}

function checkToggle(objMain,objCheck){
	var master_check = objMain.checked
	if(objCheck.length==null){
		if(master_check==true){
			objCheck.checked=true;
		}
		else{
			objCheck.checked=false;
		}
	}
	else{
		for (i = 0; i < objCheck.length; i++){
			if(master_check==true){
				objCheck[i].checked = true;
			}
			else{
				objCheck[i].checked = false;
			}
		}
	}
}

function HideC(id,classname){
	var aryid = id.split(',');
	for (i=0; i<aryid.length; ++i){
		if(document.getElementById(aryid[i])){
			var style;
			if(classname!=null){
				style = classname;
			}
			else{
				style = '';
			}
			document.getElementById(aryid[i]).className = style
		}
	}
}

function clearBox(objSearch){
	if (objSearch.value=='Enter Keyword' || objSearch.value=='ID' || objSearch.value=='Keyword')
		objSearch.value = ''
}

function confirmMessage(strText){

	if(window.confirm(strText)){
		return true;
	}
	else
		return false;
}

function checkAll(objCheck){
	//if only single box exists length of objCheck will be null
	if(objCheck.length==null)
		objCheck.checked=true;
	else{
		for (i = 0; i < objCheck.length; i++)
		objCheck[i].checked = true ;
	}
}

function uncheckAll(objCheck){
	//if only single box exists length of objCheck will be null
	if(objCheck.length==null)
		objCheck.checked=false;
	else{
		for (i = 0; i < objCheck.length; i++)
		objCheck[i].checked = false ;
	}
}

function newWindow(url, windowWidth, windowHeight, scroll, resize){
	var h = windowHeight;
	var w = windowWidth;
	var disScroll, disResize;
	
	if(scroll=='bars')
		disScroll = 'yes';
	else
		disScroll = 'no';

	if(resize=='resize')
		disResize = 'yes';
	else
		disResize = 'no';

	if(screen.width){
	var winl = (screen.width-w)/2;
	var wint = (screen.height-h)/2;
	}else{winl = 0;wint =0;}
	if (winl < 0) winl = 0;
	if (wint < 0) wint = 0;
	var settings = 'height=' + h + ',';
	settings += 'width=' + w + ',';
	settings += 'top=' + wint + ',';
	settings += 'left=' + winl + ',';

	win = window.open(url , '' , settings + ', scrollbars=' + disScroll + ', menubars=no, toolbars=no, resizable=' + disResize);
	win.window.focus();
}

function changePage(perPage, pageOn, pageFrom, pageCount, pageLimit, itemCount, urlGoing, ckeOn, strName1, strValue1, strName2, strValue2, strName3, strValue3, strName4, strValue4, strName5, strValue5, strName6, strValue6){
	//Change page v.2
	var urlGoing;
	var count;

	pageTotal = itemCount - ((pageOn - 1) * perPage);
	//change value to positive
	pageTotal = pageTotal + (pageTotal * -2 )
	//shift page if current page use is on will have no records
	//left on it after a new 'per page' is selected
	shiftPage = 0
	if (pageTotal >= 0){
		shiftPage = 1
		counter = 0
		for(count = 0;count < pageTotal; count++){
			counter++;
			if(counter >= perPage){
				shiftPage++
				counter = 0
			}
		}
	}
	//calculate new 'from' page depending on new 'on' page shifted to
	intLastNum = 0
	for(count=1; count <= pageCount; count = count + parseInt(pageLimit)){
		if (count > (parseInt(pageOn)-shiftPage)){
			pageFrom = intLastNum;
			break;
		}
		intLastNum = count;
	}
	//create url and send user there
	urlGoing = urlGoing + '?pageon=' + (parseInt(pageOn)-shiftPage);
	if(pageFrom != '')
		urlGoing += '&pagefrom=' + intLastNum;
	urlGoing += '&pageper=' + perPage;
	//general querystring addition for extra values not included
	if(strName1 != null && (strValue1 != null && strValue1 != ''))
		urlGoing += '&' + strName1 + '=' + strValue1;
	if(strName2 != null && (strValue2 != null && strValue2 != ''))
		urlGoing += '&' + strName2 + '=' + strValue2;
	if(strName3 != null && (strValue3 != null && strValue3 != ''))
		urlGoing += '&' + strName3 + '=' + strValue3;
	if(strName4 != null && (strValue4 != null && strValue4 != ''))
		urlGoing += '&' + strName4 + '=' + strValue4;
	if(strName5 != null && (strValue5 != null && strValue5 != ''))
		urlGoing += '&' + strName5 + '=' + strValue5;
	if(strName6 != null && (strValue6 != null && strValue6 != ''))
		urlGoing += '&' + strName6 + '=' + strValue6;
	//if set cookie to remember pageper on frontend
	if(ckeOn == 'on')
		document.cookie = "pageper=" + perPage
	window.location.href = urlGoing;
}
//-->