
function statusUpdate(cmd,divname,cid,pre)
{
	queryString = 'cmd=' + cmd + '&divname=' + divname + '&cid=' + cid + '&pre='+ pre;
	setHtmlById (divname, "<div class='ajaxUpdatingSmall' valign='top' align='center'><img src='images/small_loading.gif'></div>");
	uri = 'ajaxquery.php';
	myAjaxRequest = new cs_Ajax('statusUpdate', uri, divname, queryString,false,'');
	myAjaxRequest.getAjaxResult();
}

function starUpdate(cmd,divname,cid,pre)
{
	queryString = 'cmd=' + cmd + '&divname=' + divname + '&cid=' + cid + '&pre='+ pre;
	setHtmlById (divname, "<div class='ajaxUpdatingSmall' valign='top' align='center'><img src='images/small_loading.gif'></div>");
	uri = ROOT_PATH + 'ajaxquery.php';
	myAjaxRequest = new cs_Ajax('starUpdate', uri, divname, queryString,false,'');
	myAjaxRequest.getAjaxResult();
}

function changeNewStatus(cmd,divname,cid,pre)
{
	queryString = 'cmd=' + cmd + '&divname=' + divname + '&cid=' + cid + '&pre='+ pre;
	setHtmlById (divname, "<div class='ajaxUpdatingSmall' valign='top' align='center'><img src='images/small_loading.gif'></div>");
	uri = 'ajaxquery.php';
	myAjaxRequest = new cs_Ajax('newStat', uri, divname, queryString,false,'');
	myAjaxRequest.getAjaxResult();
}

function checkAvailability(cmd,divname,name, field, tbl)
{
	queryString = 'cmd=' + cmd + '&divname=' + divname + '&name=' + name + '&field=' + field + '&tbl='+ tbl ;
	setHtmlById (divname, "<div class='ajaxUpdatingSmall' valign='top' align='left'><img src='images/small_loading.gif'></div>");
	uri = 'ajaxquery.php';
	myAjaxRequest = new cs_Ajax('checkAvailability', uri, divname, queryString,false,'');
	myAjaxRequest.getAjaxResult();
}

function sendContact(cmd,divname)
{
	name = getHtmlById('name');
	email = getHtmlById('email');
	msg = getHtmlById('message');
	message = msg.replace(/\n/g, "<br>")
	phone = getHtmlById('phone');
	
	queryString = 'cmd=' + cmd + '&email=' + email + '&name=' + name + '&message=' + message + '&phone=' + phone;
	setHtmlById (divname, "<div valign='top' align='center' ><img src='images/loading.gif'></div>");
	uri = 'ajaxsql.php';

	myAjaxRequest = new cs_Ajax('mail', uri, divname, queryString,false,'');
	myAjaxRequest.getAjaxResult();
}


function sendTellAFriend(cmd,divname)
{
	name = getHtmlById('name');
	email = getHtmlById('email');
	femail = getHtmlById('femail');
	msg = getHtmlById('message');
	message = msg.replace(/\n/g, "<br>")
	
	queryString = 'cmd=' + cmd + '&email=' + email + '&name=' + name + '&message=' + message + '&femail=' + femail;
	setHtmlById (divname, "<div valign='top' align='center'><img src='" + ROOT_PATH + "images/loading.gif'></div>");
	uri = ROOT_PATH + 'ajaxsql.php';

	myAjaxRequest = new cs_Ajax('mail', uri, divname, queryString,false,'');
	myAjaxRequest.getAjaxResult();
}


function deleteMail(cmd,divname,msg_id)
{
	queryString = 'cmd=' + cmd + '&msg_id=' + msg_id;
	setHtmlById (divname, "<div class='retrieving' valign='top' align='center'><img src='images/small_loading.gif'><br>Deleting Mail...</div>");
	uri = 'pra_ajax.php';
	myAjaxRequest = new cs_Ajax('mail', uri, divname, queryString,false,'');
	myAjaxRequest.getAjaxResult();
}

function checkavailability(cmd,divname)
{
	usr = document.getElementById('c_username').value;	
	if(usr)
	{
		queryString = 'cmd=' + cmd + '&username=' + usr;
		setHtmlById (divname, "Checking...");
		uri = 'pra_ajax.php';
		myAjaxRequest = new cs_Ajax('available', uri, divname, queryString,false,'');
		myAjaxRequest.getAjaxResult();
	}
}

function sortUpdate(cmd,divname, id, act)
{
	queryString = 'cmd=' + cmd + '&divname=' + divname + '&cid=' + id + '&act=' + act;
	setHtmlById (divname, "");
	uri = 'ajaxquery.php';
	myAjaxRequest = new cs_Ajax('sortUpdate', uri, divname, queryString,false,'');
	myAjaxRequest.getAjaxResult();
}

function sendPassword(cmd,divname)
{
	email = getHtmlById('email');
	
	queryString = 'cmd=' + cmd + '&email=' + email;
	setHtmlById (divname, "<div valign='top' align='center' height='20'><img src='" + ROOT_PATH + "images/small_loading.gif'> Sending password!</div>");
	uri = 'ajaxsql.php';

	myAjaxRequest = new cs_Ajax('mail', uri, divname, queryString,false,'');
	myAjaxRequest.getAjaxResult();
}

function getJobCat(cmd, divname, userId,pg)
{
	queryString = 'cmd=' + cmd + '&userId=' + userId + '&pg=' + pg;
	setHtmlById (divname, "<div valign='top' align='center' height='20'><img src='images/small_loading.gif'> Retrieving Data</div>");
	uri = 'ajaxsql.php';

	myAjaxRequest = new cs_Ajax('getJobCat', uri, divname, queryString,false,'');
	myAjaxRequest.getAjaxResult();	
}

function saveJobCat(cmd, divname, userId, catList, pg)
{
	queryString = 'cmd=' + cmd + '&userId=' + userId + '&catList=' + catList + '&pg=' + pg;
	setHtmlById (divname, "<div valign='top' align='left' height='20' style='color:#DD0000'><img src='images/small_loading.gif'> Saving Job Preferences</div>");
	uri = 'ajaxsql.php';

	myAjaxRequest = new cs_Ajax('saveJobCat', uri, divname, queryString,false,'');
	myAjaxRequest.getAjaxResult();	
}

function getCheckedJobCat(userId, pg)
{

	var total=""
	for(var i=0; i < document.pageForm.jobCatPref.length; i++)
	{
		if(document.pageForm.jobCatPref[i].checked)
		total +=document.pageForm.jobCatPref[i].value + ":"
	}
	if(total == "")
		alert("Please select job category") 
	else
	{
		saveJobCat('saveJobPref', 'saveJobPref', userId, total, pg);
	}
	
	return false;
 
}

function allCheckedBox()
{

	var total = "";
	for(var i=0; i < document.pageForm.jobCatPref.length; i++)
	{
		if(document.pageForm.jobCatPref[i].checked)
		total +=document.pageForm.jobCatPref[i].value + ":"
	}
	if(total != "")
	{
		document.getElementById('listedId').value = total;
	}
 
}

function displayLicenses(cmd,divname,uid)
{
	queryString = 'cmd=' + cmd + '&divname=' + divname + '&uid=' + uid;
	
	setHtmlById (divname, "<div class='ajaxUpdatingSmall' valign='top' align='center'><img src='" + ROOT_PATH + "images/loading.gif'></div>");
	uri = ROOT_PATH + 'ajaxsql.php';
	myAjaxRequest = new cs_Ajax('displayLicenses', uri, divname, queryString,false,'');
	myAjaxRequest.getAjaxResult();
}

function deleteLicense(cmd,divname,uid,lid)
{
	delConfirm = confirm('Are you sure you want to delete?');
	if(delConfirm)
	{
		queryString = 'cmd=' + cmd + '&divname=' + divname + '&uid=' + uid + '&lid=' + lid;
		setHtmlById (divname, "<div class='ajaxUpdatingSmall' valign='top' align='center'><img src='" + ROOT_PATH + "images/loading.gif'></div>");
		uri = ROOT_PATH + 'ajaxsql.php';
		myAjaxRequest = new cs_Ajax('deleteLicense', uri, divname, queryString,false,'');
		myAjaxRequest.getAjaxResult();
	}
	else
		return false;
}
