
/*
	------------- 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).show();
			$(divTag).prepend("<div style='margin: 0px 0px 5px 2px'><img src='/images/web/loading.gif'> Уншиж байна...</div>");
		},
		success: function(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).show();
			$(divTag).prepend("<div style='margin: 0px 0px 5px 2px'><img src='/mod/images/web/loading.gif'> Уншиж байна...</div>");
		},
		success: function(html){
			$(divTag).empty();
			$(divTag).append(html);
			$(divTag).show();
		}
	});
}

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');
	})
}

