
/*
	------------- ASU Discovery Co.,Ltd -------------
	
	CreateDate: 2008-11-15 13:12
	UpdateDate: 2008-11-16 11:38
	Created by programmer UGTAKHBAYAR Mandakh

	-------------------------------------------------
	JQuery user defined function
*/

function loadPage(divTag, goUrl){
	$.ajax({
		type: "GET",
		url: goUrl,
		beforeSend: function(){
			// Handle the beforeSend event
			$(divTag).html("<div align='center'><img src='images/loading6.gif'><br>Уншиж байна. Түр хүлээнэ үү! ...</div>");
		},
		success: function(html){
			//$(divTag).html("");
			$(divTag).empty();
			$(divTag).append(html);
		}
	});
	//$(divTag).load(goUrl);	
}

function postPage(divTag, f, goUrl){
	s='';
	for(i=0;i<f.elements.length;i++) s=s+'&'+f.elements[i].name+'='+f.elements[i].value;
	$.ajax({
		type: "POST",
		url: goUrl,
		data: s,
		beforeSend: function(){
			// Handle the beforeSend event
			$(divTag).html("<div align='center'><img src='images/loading2.gif'></div>");
		},
		success: function(html){
			//$(divTag).html("");
			$(divTag).empty();
			$(divTag).append(html);
			//$('#divPageMemberRight').load('memberloginright.php');
		}
	});
}

function changeSelectBox(pUrl, pSBSrc, pSBDst, pSBStrSelect, pSBDstValue){
	$.getJSON(pUrl,{sbdst: pSBDst, id: $(pSBSrc).val(), sbstrselect: pSBStrSelect, ajax: 'true'}, function(j){
		var options = '';
		for (var i = 0; i < j.length; i++) {
			options += '<option value="' + j[i].optionValue + '"';
			//if (i == 0) options += ' selected="selected"';
			if (pSBDstValue!='' && pSBDstValue == j[i].optionValue) options += ' selected="selected"';
			options += '>' + j[i].optionDisplay + '</option>';
			//options += '<option value="' + j[i].optionValue + '">' + j[i].optionDisplay + '</option>';
		}
		$(pSBDst).html(options);
		//$(pSBDst+' option:first').attr('selected', 'selected');
	})
}

