//<!--
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 clearBox(objSearch){
	if (objSearch.value=='Enter Keyword' || objSearch.value=='ID')
		objSearch.value = ''
}

function confirmMessage(strText){

	if(window.confirm(strText)){
		return true;
	}
	else
		return false;
}

function pageChange(perPage, reqPageOn, reqPageFrom, reqSearchText, reqSearchCat, reqSearchBnd, pageCount , pagelimit, itemCount, urlGoing, reqExtraName1, reqExtraValue1, reqExtraName2, reqExtraValue2, reqExtraName3, reqExtraValue3, reqExtraName4, reqExtraValue4){

	var urlGoing;
	var count;

	pageTotal = itemCount - ((reqPageOn - 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(reqPageOn)-shiftPage)){
			reqPageFrom = intLastNum;
			break;
		}
		intLastNum = count;
	}

	//create url and send user there
	urlGoing = urlGoing + '?pageon=' + (parseInt(reqPageOn)-shiftPage);
	
	if(reqPageFrom != '')
		urlGoing += '&pagefrom=' + intLastNum;

	urlGoing += '&pageper=' + perPage;
	
	if(reqSearchText != '')
		urlGoing += '&searchKey=' + reqSearchText;
	if(reqSearchCat != '')
		urlGoing += '&searchList=' + reqSearchCat;
	if(reqSearchBnd != '')
		urlGoing += '&searchBrand=' + reqSearchBnd;	
	
	//if called without extra value parameters
	if(reqExtraName1 == null)
		reqExtraName1 = '';
	if(reqExtraValue1 == null)
		reqExtraValue1 = '';
	if(reqExtraName2 == null)
		reqExtraName2 = '';
	if(reqExtraValue2 == null)
		reqExtraValue2 = '';
	if(reqExtraName3 == null)
		reqExtraName3 = '';
	if(reqExtraValue3 == null)
		reqExtraValue3 = '';		
	if(reqExtraName4 == null)
		reqExtraName4 = '';
	if(reqExtraValue4 == null)
		reqExtraValue4 = '';
			
	//general querystring addition for extra values not included
	if(reqExtraName1 != '' && reqExtraValue1 != '')
		urlGoing += '&' + reqExtraName1 + '=' + reqExtraValue1;
	if(reqExtraName2 != '' && reqExtraValue2 != '')
		urlGoing += '&' + reqExtraName2 + '=' + reqExtraValue2;	
	if(reqExtraName3 != '' && reqExtraValue3 != '')
		urlGoing += '&' + reqExtraName3 + '=' + reqExtraValue3;
	if(reqExtraName4 != '' && reqExtraValue4 != '')
		urlGoing += '&' + reqExtraName4 + '=' + reqExtraValue4;
	
	//if from dept page, set cookie to remember pageper on frontend
	if(reqExtraName1 == 'cke' || reqExtraName1 == 'validate')
		document.cookie = "pageper=" + perPage

	window.location.href = urlGoing;
}

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';

	//centered screen script
	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();
}

//-->