// JavaScript Document

function ampreplace(str)
{
	return str.replace(/&/g,"%26");
}

function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}

/*------------------------ End of Common Fucntions ------------------------------*/

function fn_changelanguage(langid)
{	
	$('#hidlangid').val(langid);
	
	var formaction = $('#hidcurrpagename').val();
	
	var frm = document.frmnn;
	frm.method = "post";
	frm.action = formaction;
	frm.submit();
	
}

function fn_clearsearchtext() {
	$('#txtsearch').val('');
}

function fn_searchproducts(searchtext)
{	
	dataparam = "oper=searchproducts&searchtext="+searchtext;

	$.ajax({
		type: "POST",
		url: "../ajaxpages/ajax-products.php",
		data: dataparam,
		beforeSend: function(){ $('#divapplist').html('<b class="black">Loading Please Wait ... </b>'); } ,
		success: function(html){
			if(trim(html) != '')
			{
				$('#divapplist').html(trim(html));
			}
			else {
				$('#divapplist').html('No Apps Founds');
			}
		}
		//complete: function(){ HideLightBox(); }
	});
}

function fn_searchbycategory(catid)
{	
	dataparam = "oper=searchbycat&catid="+catid;

	$.ajax({
		type: "POST",
		url: "../ajaxpages/ajax-products.php",
		data: dataparam,
		beforeSend: function(){ $('#divapplist').html('<center><p><b class="preloadertxt">Loading Please Wait</b><br /><div class="preloader"></div></p></center>'); } ,
		success: function(html){
			if(trim(html) != '')
			{
				$('#divapplist').html(trim(html));
			}
			else {
				$('#divapplist').html('No Apps Founds');
			}
		}
		//complete: function(){ HideLightBox(); }
	});
}

function ShowLightBox(lb_div, isModal) 
{ 
	//alert(lb_div);
	document.getElementById(lb_div).style.display='block'; 
	document.getElementById('fade').style.display='block'; 
	curr_lb_div = lb_div; 
	
	if (isModal) 
		is_modal = true; 
	else 
		is_modal = false; 
} 
 
function HideLightBox() 
{ 
	if (document.getElementById(curr_lb_div)) 
	{ 
		 document.getElementById(curr_lb_div).style.display='none'; 
	 	 document.getElementById('fade').style.display='none'; 
		 curr_lb_div = ''; 
	} 
} 

function fn_jobopp(id)
{
	dataparam = "oper=jobopp&jobid="+id;

	$.ajax({
		type: "POST",
		url: "../ajaxpages/ajax-careers.php",
		data: dataparam,
		beforeSend: function(){ ShowLightBox('divlbox',true); $('#divlbox').html('<center><p><b class="preloadertxt">Loading Please Wait</b><br /><div class="preloader"></div></p></center>'); } ,
		success: function(html){
			$('#divlbox').html(html);
		}
		//complete: function(){ HideLightBox(); }
	});
}

function fn_refresh() {
	
	dataparam = "oper=refresh";

	$.ajax({
		type: "POST",
		url: "../ajaxpages/ajax-refresh.php",
		data: dataparam,
		beforeSend: function(){ $('.recaptchaimgbox').html('<center><p><b class="preloadertxt">Loading Please Wait</b><br /><div class="preloader"></div></p></center>'); } ,
		success: function(html){
			$('.recaptchaimgbox').html(html);
		}
		//complete: function(){ HideLightBox(); }
	});	
	
}

