/**
 * Load html data using ajax
 *
 */
function loadHtmlData( elem, url, callback, method )
{
    // in most cases it is element ID, in other cases - object of jQuery
    if (typeof elem == 'string')
        elem = '#' + elem; // create selector from ID
    
    var $block = $(elem);
    
    var blockPos = $block.css('position');
    
	$block.css('position', 'relative'); // set temporarily for displaying "loading icon"
    
    var $loadingDiv = $(
        '<div class="loading_ajax">' +
            '<img style="margin-top: 16px;" alt="Loading..." src="' + baseURL + 'img/ajax-loader.gif" />' +
        '</div>'
    )
    .appendTo($block);

 	var iLeftOff = $block.width()  / 2 - ($loadingDiv.find('img:first').width()  / 2);
	var iTopOff  = $block.height() / 2 - ($loadingDiv.find('img:first').height() / 2) + 10;
    if (iTopOff<0) iTopOff = 0;

    $loadingDiv.css({
        position: 'absolute',
        left: iLeftOff,
        top:  iTopOff,
        zIndex:100
	});

	if (undefined != method && (method == 'post' || method == 'POST')) {		

		$.post(url, function(data) {

			$block.html(data);

	        $block
			    .css('position', blockPos) // return previous value
        
	        if (typeof callback == 'function')
			    callback.apply($block);
		});

	} else {

		$block.load(url + '&_r=' + Math.random(), function() {
	        $(this)
			    .css('position', blockPos) // return previous value
        
	        if (typeof callback == 'function')
			    callback.apply(this);
		});

	}
}
/**
 * Function used to display License order form
 *
 */
function showOrderForm(item){    
    loadHtmlData('order_div', baseURL+'ajax.php?ajax=1&tool=license&action=show_order_form&item='+item);
}

function validateForm(){
	if($('input[name="first_name"]').val() == ''){
		alert('Please enter first name');
		return false;
	} else if($('input[name="last_name"]').val() == ''){
		alert('Please enter last name');
		return false;
	}else if($('input[name="custom"]').val() == ''){
		alert('Please enter domain');
		return false;
	}
	return true;
}
