jQuery.fn.center = function () { 
    this.css("position","absolute"); 
    this.css("top", ( $(window).height() - this.height() ) / 2 + $(window).scrollTop() + "px"); 
    this.css("left", ( $(window).width() - this.width() ) / 2 + $(window).scrollLeft() + "px"); 
    return this; 
}

jQuery.fn.containercenter = function () { 
    this.css("position","absolute"); 
    this.css("top", ( $(window).height() - this.height() ) / 2 - 30 + "px"); 
    this.css("left", ( $("#container-left").width() - this.width() ) / 2 + "px"); 
    return this; 
}

jQuery.fn.fullscreen = function () { 
    this.css("position","absolute"); 
    this.css("width", $(window).width() + "px"); 
    this.css("height", $(window).height() + "px"); 
	this.css("overflow","hidden");
    return this; 
}

function jQueryCheckAll( n, fieldName ) {
	if (!fieldName) { fieldName = 'cb';	}
	var chk = $('#toggle').attr('checked');
	var n2 = 0;
	for (i=0; i < n; i++) {
		cb = $('#cb' + i);
		if (cb) {
			cb.attr('checked', chk);
			n2++;
		}
	}
	if (chk) $('#boxchecked').val(n2);
	else $('#boxchecked').val(0);
}

function jQueryIsChecked(n){
	var cb = $('#cb' + n);
	var value = $('#boxchecked').val();
	if (cb.attr('checked')){ value++; }
	else { value--; }
	$('#boxchecked').val(value)
}

function jQueryOrder(orderBy, sortOrder) 
{
	$('#order').val(orderBy);
	$('#sort').val(sortOrder);
	$('#adminForm').submit();
}

function jQueryReset(keys) {
	if (keys)
	{
		var key = keys.split(';');

		for(i=0; i<key.length; i++)
		{
			$('#' + key[i]).val('');
		}
	}
}

function jQueryPublish(id, val, base) {
	$('#id').val(id);
	$('#publish').val(val);

	if (base) $('#adminForm').attr('action', base);
	$('#adminForm').submit();
}

function jQueryPubSelected(val, base)
{
	if ($('#boxchecked').val() > 0)
	{
		$('#id').val('');
		if (base) $('#adminForm').attr('action', base);
		$('#publish').val(val);
		$('#adminForm').submit();
	}
	else alert('Error : Please select from the list');
}

function jQueryDelSelected(base)
{
	if ($('#boxchecked').val() > 0)
	{
		if (confirm('Are you sure you want to delete selected record? '))
		{
			$('#id').val('');
			if (base) $('#adminForm').attr('action', base);
			$('#adminForm').submit();
		}
	}
	else alert('Error : Please select from the list to delete');
}

function jQueryEdit(id, base) 
{
	$('#id').val(id);
	if (base) $('#adminForm').attr('action', base);
	$('#adminForm').submit();
}

function jQueryDel(id, base) 
{
	if (confirm('Are you sure you want to delete selected record? '))
	{
		$('#id').val(id);
		if (base) $('#adminForm').attr('action', base);
		$('#adminForm').submit();
	}
}

function jQuerySetValue(link, place, name)
{
	$("#" + place).html("Wait...");
	$("#" + place).load(link, function () {
		$("#" + name).focus();
	});
}

function jQuerySaveValue(link, place)
{
	$("#" + place).html("Wait...");
	$("#" + place).load(link);
}
