// JavaScript Document
function initForm()
{

}//end function


function viewCategory()
{
	with (window.document.frmListCategory) {
		if (selCategory.selectedIndex == 0) {
			window.location.href = 'index.php';
		} else {
			window.location.href = 'index.php?view=list&catId=' + selCategory.options[selCategory.selectedIndex].value;
		}
	}
}//end viewWorkshop

function viewCategoryMainPage()
{
	with (window.document.frmListCategory) {
		if (selCategory.selectedIndex == 0) {
			window.location.href = 'workshop.php';
		} else {
			window.location.href = 'workshop.php?view=list&catId=' + selCategory.options[selCategory.selectedIndex].value;
		}
	}
}//end viewCategoryMainPage

function viewDateAdd()
{
	with (window.document.frmWorkshop) {
		if (selDay.selectedIndex == 0 && selMonth.selectedIndex == 0 && selYear.selectedIndex == 0) {
			window.location.href = 'index.php';
		} 
		else {
			window.location.href = 'index.php?view=add&day=' + selDay.options[selDay.selectedIndex].value + '&month=' + selMonth.options[selMonth.selectedIndex].value + '&year='+selYear.options[selYear.selectedIndex].value;
		}
	}
}//end viewDate

function viewModifyDate(wId)
{
	with (window.document.frmWorkshop) {
		if (selDay.selectedIndex == 0 && selMonth.selectedIndex == 0 && selYear.selectedIndex == 0) {
			window.location.href = 'index.php';
		} 
		else {
			window.location.href = 'index.php?view=modify&wId='+ wId +'&day=' + selDay.options[selDay.selectedIndex].value + '&month=' + selMonth.options[selMonth.selectedIndex].value + '&year='+selYear.options[selYear.selectedIndex].value;
		}
	}
}//end viewDate

function checkWorshopForm()
{
    with (window.document.frmWorkshop) {
		//if (isEmpty(txtCode, 'Enter category code')) {
		//	return;
		//}
		if (isEmpty(selCategory, 'Enter workshop category')) {
			return;
		} 
		if (isEmpty(txtCode, 'Enter workshop code')) {
			return;
		} 
		else if(isEmpty(txtName, 'Enter workshop name')) {
			return;
		} 
		else if(isEmpty(txtTotal, 'Enter total participants')) {
			return;
		} 
		else if(isEmpty(selLocation, 'Enter location')) {
			return;
		} 		
		else {
			submit();
		}
	}
}

function updateActivationWorkshop(wId, wstatus)
{
	window.location.href = 'processWorkshop.php?action=activateWorkshop&wId='+wId+'&status='+wstatus;
}

function addWorkshop()
{
	window.location.href = 'index.php?view=add';
}

function modifyWorkshop(wId)
{
	window.location.href = 'index.php?view=modify&wId=' + wId;
}

function deleteWorkshop(wId)
{
	if (confirm('Deleting Workshop?')) {
		window.location.href = 'processWorkshop.php?action=delete&wId=' + wId;
	}
}

function deleteImage(wId)
{
	if (confirm('Delete this image')) {
		window.location.href = 'processWorkshop.php?action=deleteImage&wId=' + wId;
	}
}//end deleteImage

function deleteSelectedWorkshop()
{
	if (confirm('Deleting Workshops?')) {
		window.location.href = 'processWorkshop.php?action=deleteAll';
	}
}