function getAJAXResponse (reqURL, dataArray, dataType) {
	var response = '';
	
	jQuery.ajax({
		global: false,
		type: "POST",
		url: reqURL,
		data: dataArray,
		dataType: dataType,
		async: false,
		cache: true,
		success: function(data){
			response = data;
		},
		error: function(XMLHttpRequest, textStatus, errorThrown){
			response = textStatus;
		}
	});
	
	return response;
}

function appendHTML (parentID, htmlData, appendFlag) {
	if (appendFlag) {
		jQuery(parentID).append(htmlData);
	} else {
		jQuery(parentID).html(htmlData);
	}
}

/*function resetFields(formID){
	jQuery(":text, :password, :file", "#"+formID).val('');
	//jQuery(":radio, :checkbox", "#"+formID)[0].checked = true;
}*/

function resetFields(txtFlag, rdoFlag, chkFlag, formID){
	if (txtFlag) { jQuery(":input", formID).not(":radio, :checkbox, :button, :submit, :reset").val(''); }
	if (chkFlag) { jQuery(":radio", formID)[0].checked = true; }
	if (chkFlag) { jQuery(":checkbox", formID)[0].checked = true; }
}

function lockedFields(formID, flag) {
	jQuery(":input", formID).not(":button, :submit, :reset").attr("disabled", flag);
}

function openForm(formID){
	var height = jQuery(window).height();
	var width = jQuery(window).width();
	
	jQuery(formID).css({
		'left': width/2 - (jQuery(formID).width()/2),
		'top': height/2 - (jQuery(formID).height()/2),
		'display': 'block',
		'position': 'fixed',
		'z-index': 88888
	});
	
	//var targetOffset = jQuery(formID).offset().top;	
	//jQuery("html, body").animate({scrollTop:targetOffset}, "slow");
}

function closeForm(formID){
	jQuery(formID).css({'display':'none'});
}

function flashMessage(msgID, speed, duration, callback){
	jQuery(msgID).fadeIn(speed, function(){
		jQuery(msgID).fadeOut(duration, function(){
			if (callback != ""){
				return callback();
			} else {
				return true;
			}
		});
	});
}

function popupMessage(theParent, theChild, theMsg) {
	jQuery(theParent).prepend(theMsg);
	jQuery(theChild)
	.fadeIn('slow')
	.animate({opacity:1}, 1500)
	.fadeOut('slow', function() {
		jQuery(this).remove();
	});
}

function selectAllText(textID) {
	textID.focus();
	textID.select();
}

function get_time_zone_offset() {
	var current_date = new Date();
	var gmt_offset = current_date.getTimezoneOffset()*60;
	return gmt_offset;
}

function popup(url, title) {
 params  = 'width='+screen.width;
 params += ', height='+screen.height;
 params += ', top=0, left=0'
 params += ', fullscreen=yes';

 newwin=window.open(url, title, params);
 if (window.focus) { newwin.focus() }
 return false;
}


function resetForm(formID) 
{
	jQuery(':text, :password, :file', formID).val('');
	jQuery(':input', formID).removeAttr('checked').removeAttr('selected');
}

function fadeBackground(ID, showFlag)
{
	//console.log('hi');
	if ( showFlag ) 
	{
		var width = jQuery(window).width();
		var height = ( jQuery(window).height() > jQuery(document).height() ? jQuery(window).height() : jQuery(document).height() );
		jQuery(ID).css({'width':width, 'height':height, 'opacity':0.6, 'display':'block'});
	}
	else 
	{
		jQuery(ID).css({'display':'none'});
	}
}
