
// Function "goForm" covers the donation forms for
// (1)  Man Mo Temple Gimmick
// (2)  TCM Portal
//
// Function "PopUpWin" was created for browse all the revamped on-line forms (2007-09-12).


function goForm(formname)
{
	var formURL = "https://apps.twghintranet.org/donation/" + formname + ".html";
//	var formURL = "http://www.tungwah.org.hk/forms/maint.html";
	var newWin  = null;
		newWin  = window.open(formURL, '', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=680,height=500');
}


//  Function "servForm" covers all hyperlinks other then (1) and (2) above.
//  Note : The parameters 'showList' determines whether and which service scope list is to be shown.

//  showList : null => Do not show service scope list (instead show eventName)
//                1 => Show general Service scope list
//                2 => Show Service scope list for "Patron of Tung Wah Services Donation Scheme"

function servForm(formName, eventName, showList)
{
	if (showList == null)
		window.w = open("https://apps.twghintranet.org/sslform/"+encodeURI(formName)+"?support_serv="+encodeURI(eventName),"myWin","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=680,height=500");
	else
		window.w = open("https://apps.twghintranet.org/sslform/"+encodeURI(formName)+"?support_serv="+encodeURI(eventName)+"&show_list="+encodeURI(showList),"myWin","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=680,height=500");
}

function donate(formName, eventName, showList)
{
	var baseGBurl = "http://202.67.226.39/gate/gb";
	var hostName  = document.location.host;

	if ( baseGBurl.indexOf(hostName) != -1 ) 			// viewing at simplified Chinese version
		formName = formName.replace("_c", "_g");		// switch to GB version of donation form

	PopUpWin(formName, eventName, showList);
}

		function PopUpWin(form, ent, subj){
			var url;
			
			switch (form)
			{
			case 'gdfvp_c':
			case 'gdfvp_g':
			case 'gdfvp_e':
			url = "https://www.tungwah.org.hk/admin/df/gdfvp/newpage/newpage.php?" + "form=" + form;
			if (ent) {
				url = url  + "&ent=" + ent + "&";
			}
			if (subj) {
				url = url  + "subj=" + subj ;
			}
			break;
			case 'gdfpp_c':
			case 'gdfpp_g':
			case 'gdfpp_e':
			url = "https://www.tungwah.org.hk/admin/df/gdfpp/newpage/newpage.php?" + "form=" + form;
			if (ent) {
				url = url  + "&ent=" + ent + "&";
			}
			if (subj) {
				url = url  + "subj=" + subj ;
			}
			break;
			case 'meddf_c':
			case 'meddf_g':
			url = "https://www.tungwah.org.hk/admin/df/meddf/newpage/newpage.php?" + "form=" + form;
			if (ent) {
				url = url  + "&ent=" + ent + "&";
			}
			if (subj) {
				url = url  + "subj=" + subj ;
			}
			break;

			default:
			url = "https://www.tungwah.org.hk/admin/df/" + form + ".php?" + "form=" + form + "&ent=" + ent + "&";
			if (subj) {
			url = url + "&subj=" + subj + "&";
			}
			}
			
			 	
			switch (form)
			{
			case 'gdfpp_c':
			case 'gdfpp_g':
			case 'gdfpp_e':			
			var pWin = window.open(encodeURI(url), 
			"PopUpWindow", "width = 1000, height = 650, toolbar=no, scrollbars=yes" );
			break;
			default:
			var pWin = window.open(encodeURI(url), 
			"PopUpWindow", "width = 720, height = 650, toolbar=no, scrollbars=yes" );
			}

		}
		




// Solely for the Inauguration of the Board of Directors 2008/2009

function ia_donate(formName, eventName, showList)
{
    var baseGBurl = "http://202.67.226.39/gate/gb";
    var hostName  = document.location.host;
 
    if ( baseGBurl.indexOf(hostName) != -1 )             // viewing at simplified Chinese version
        formName = formName.replace("_c", "_g");        // switch to GB version of donation form
 
    ia_PopUpWin(formName, eventName, showList);
}
 
function ia_PopUpWin(form, ent, subj){
    var url;
	var bw;
			
			switch (form)
			{
			case 'ia09_c':
			case 'ia09_g':
			case 'ia09_e':
			case 'ia08_c':
			case 'ia08_g':
			case 'ia08_e':
			url = "https://www.tungwah.org.hk/admin/df/" + form + ".php?" + "form=" + form + "&ent=" + ent + "&";
			if (subj) {
				url = url + "&subj=" + subj + "&";
			}
			bw = "770";
			break;
			default:
			var formname = form.substring(0,5);
			var formsize = form.substring(4,5);
			url = "https://www.tungwah.org.hk/admin/df/" + formname + "/newpage/newpage.php?" + "form=" + form;
			if (ent) {
				url = url  + "&ent=" + ent + "&";
			}
			if (subj) {
				url = url  + "subj=" + subj ;
			}
			
				if (formsize=="p") {
				  bw = "1000";
				}
				else
				{
				  bw = "720";
				}
			}
			
			 	
			var pWin = window.open(encodeURI(url), 
			"PopUpWindow", "width = " + bw + ", height = 650, toolbar=no, scrollbars=yes" );
		}

// The function directForm is used to open up an online form with a RewriteRule being set up.
// The paraameter "formName" is the name specified in the RewriteRule. 

function directForm(formName) {
	var url;
	url = "https://www.tungwah.org.hk/" + formName;
	var dWin = window.open(encodeURI(url), "DirectFormWindow", "width=720, height=650, toolbar=no, scrollbars=yes");
}

