

function openPopUpItem(baseUrl,itemID,Type)
{
	openWindow(baseUrl+'/customer/edititem/type/'+Type+'/itemID/'+itemID,'Item','500','400','');
	
}
function submitDelItemDetail(theform,item,baseUrl)
{	
		if (confirm('Do you want to delete selected item(s)?') == true){
			theform.action = baseUrl;
			theform.dellist.value = item + ",";
			return theform.submit();
		}
}

function submitDelFormDetail(theform,baseUrl)
{	
	if (makeDelList(theform) > 0) {
		if (confirm('Do you want to delete selected item(s)?') == true){
			theform.action = baseUrl;
			return theform.submit();
		}
	}
}

function submitDelItem(theform,item)
{	
		if (confirm('Do you want to delete selected item(s)?') == true){
			theform.action += '/delete';
			theform.dellist.value = item + ",";
			return theform.submit();
		}
}

function submitDelForm(theform)
{	
	if (makeDelList(theform) > 0) {
		if (confirm('Do you want to delete selected item(s)?') == true){
			theform.action += '/delete';
			return theform.submit();
		}		
	}
}

function checkAll(theform)
{
	if (theform.chkid==null) return;
	var state = theform.chkall.checked;
	var chkitems = theform.chkid.length;
	if (chkitems > 0) {
		for (var i=0; i<chkitems; i++) {
			if (theform.chkid[i].disabled == false)
				theform.chkid[i].checked = state;
		}
	} else {
		if (theform.chkid.disabled == false)
			theform.chkid.checked = state;
	}
}

function checkOneItem(theform) 
{
	var state=true;
	
	var chkitems = theform.chkid.length;
	if (chkitems > 0)
	{
		for (var i=0; i<chkitems; i++)
			if (theform.chkid[i].checked==false){
				state=false;
				break;
				}
	}
	
	theform.chkall.checked = state;
}

function makeDelList(theform)
{			
	var delList="";
	delList += theform.dellist.value;
	var chkitems = theform.chkid.length;
	var count = 0 ;
	if (chkitems >= 2)
	{
		for(var i=0; i<chkitems; i++){
			
			if (theform.chkid[i].checked == true)
			{
				delList += theform.chkid[i].value + ",";
				count++ ;				
			}
		}
		theform.dellist.value = delList;
	}
	else
	{
		if(theform.chkid.checked == true)
		{
			delList	+=	theform.chkid.value+ ",";
			theform.dellist.value = delList;
			return 1;
		}
		return 0;
	}
	return count;
}

function isEmpty(thefield)
{
 	// need to trim the value
	if (thefield.value=='')
		return true;
	return false;
}

function doSubmit(theform, cmd)
{
	theform.command.value = cmd;
	return theform.submit();
}


// ---------------------------------------------------------------------------
// Script for view_blockmanager and view_pagemanager
// ---------------------------------------------------------------------------
function refreshList(theform, curobject)
{
	//theform.selItemsPerPage.selectedIndex = curobject.selectedIndex;
	theform.selItemsPerPage.selectedIndex = curobject.selectedIndex;
	return doSubmit(theform, '');	
}

function showAll(theform, resetlist)
{
	theform.hidPageNO.value = 1;
	if (resetlist!=null)
		for (var i=0; i<resetlist.length; i++)
			resetlist[i].selectedIndex = 0;
	return doSubmit(theform, '');
}

function showPage(theform, page)
{
	theform.hidPageNO.value = page;
	return doSubmit(theform, '');
}

function doEdit(theform, theIDfield, cmd, id)
{
	theIDfield.value = id;
	return doSubmit(theform, cmd);
}
function openWindow(filename, winname, width, height, feature) {
 	var features, top, left;
 	var reOpera = /opera/i ;
 	var winnameRequired = ((navigator.appName == "Netscape" && parseInt(navigator.appVersion) == 4) || reOpera.test(navigator.userAgent));

 	left = (window.screen.width - width) / 2;
 	top = (window.screen.height - height) / 2;
 	if(feature == '')
 		features = "width=" + width + ",height=" + height + ",top=" + top + ",left=" + left + ",status=0,location=0";
 	else
 		features = "width=" + width + ",height=" + height + ",top=" + top + ",left=" + left + "," + feature;
	// if(!winnameRequired) winname = "";
 	newwindow = window.open(filename,null,features);
 	newwindow.focus();
}	
function showTimeDate(dayName)
{   	
	monName = new Array ("1","2","3","4","5","6","7","8","9","10","11","12");
	now = new Date;
	document.write( dayName[now.getDay()]+ ", " +now.getDate()+ "/ " +monName[now.getMonth()]+ "/ " +now.getFullYear() + "  " + now.getHours() + ":" + now.getMinutes() );
}
