function doSubmit(event, val) {
	document.forms[0].pageEvent.value = event;
	if (val != null) {
		document.forms[0].pageEventSrc.value = val;
	}
	document.forms[0].submit();
}

function doSubmit(event) {
	document.forms[0].pageEvent.value = event;
	document.forms[0].submit();
}

function doTickWithValue(cbName,idx,val1,val2) {
	tickVal = val1;
	untickVal = val2;
	doTick(cbName,idx);
	tickVal = '0';
	untickVal = '1';
}

function doTick(cbName,idx) {
	var aInput = document.getElementsByName(cbName);
	if (aInput.length) {
		selectedObj = aInput[idx];
		if (aInput.length == 1)
			selectedObj = aInput[0];
	} else {
		selectedObj = aInput;
	}
	if (selectedObj.value != null && selectedObj.value == tickVal)
		selectedObj.value = untickVal;
	else
		selectedObj.value = tickVal;
}

function changeVal(form, name, index, val) {
        //check is array or not
        if(form.elements[name].length == null){
                form.elements[name].value = val;
        } else {
                //array
                form.elements[name][index].value = val;
        }
}

function changeValWithSubmit(form, name, index, val) {
        //check is array or not
        if(form.elements[name].length == null){
                form.elements[name].value = val;
        } else {
                //array
                form.elements[name][index].value = val;
        }
				doSubmit("doNothing");
}

function doConfirm(event, msg) {
	if( msg == null || msg == '' ) {
		msg = "Are you sure to proceed?";
	}
	if (confirm(msg)) {
		doSubmit(event);
	}
}

function openwindow(url, width, height) {

		var s = "toolbar=1,scrollbars=1,resizable=1,statusbar=1,menubar=1,location=1,width=" + width + ",height=" + height + ",left=0,top=0";
		var randomNum = Math.floor(Math.random()*999999);

    window.open(url, "mywindow"+randomNum, s);
}

function openImage(url, width, height) {

		var s = "toolbar=0,scrollbars=1,resizable=1,statusbar=0,menubar=0,location=0,width=" + width + ",height=" + height + ",left=0,top=0";
		var randomNum = Math.floor(Math.random()*999999);

    window.open(url, "mywindow"+randomNum, s);
}

function addFavorites(url, pageName) {
	if (window.external) { 
		window.external.AddFavorite(url,pageName);
	} else { 
		alert("Sorry! Your browser doesn't support this function."); 
	}
}