function showRequest(formData, jqForm, optionsConsultant) { 
	var temp = document.getElementById('title');
	if(temp.value==""){
		alert("You must enter the title of gallery");
		var temp1 = document.getElementById('span_title');
		temp1.innerHTML = " <font color='red'><b>***</b></font>";
		temp.style.border = "2px solid red";
		return false;
	}else{
		var temp1 = document.getElementById('span_title');
		temp1.innerHTML = "";
		temp.style.border = "0";
		var queryString = $.param(formData); 
		return true;
	}
} 
 
// post-submit callback 
function showResponse(responseText, statusText)  { 
	tempvalue = responseText ;
	pos = tempvalue.indexOf("@@@@@@@@@@");
	str1 = tempvalue.substring(0,pos);
	str2 = tempvalue.substring(pos+10);
	var temp = document.getElementById('creategallery_div');
	temp.innerHTML = str1;
	var temp1 = document.getElementById('gallery_listing_div');
	temp1.innerHTML =  str2;
	temp = document.getElementById('title');
	temp.value = '';
	temp = document.getElementById('description');
	temp.value = '';
	//temp = document.getElementById('listing_gallery');
	//temp.reload();
	window.listing_gallery.location.reload();
} 



function showRequestImages(formData, jqForm, optionsConsultant) { 
	
	
	var temp = document.getElementById('gallery_id');
	if(temp.value == "")
	{
		alert("You must choose gallery for upload");
		return false;	
	}else
	{
		document.getElementById("loading_div").innerHTML="<img src='http://muare.vn/forum/images/imgLoading.gif'>";
		var queryString = $.param(formData); 
		return true;
	}
     
} 
 
// post-submit callback 
function showResponseImages(responseText, statusText)  { 
	document.getElementById("loading_div").innerHTML="";
	tempvalue = responseText ;
	var temp = document.getElementById('uploadimages_div');
	temp.innerHTML = tempvalue;
	temp = document.getElementById('gallery_id');
	temp.value = '';
	temp = document.getElementById('listing_image_div');
	temp.innerHTML = '';
	
	
} 

function showarea(area_div)
{
	var temp = document.getElementById(area_div);
	if(temp.style.display == "none")
	{
		temp.style.display = "block";
	}else
	{
		temp.style.display = "none";	
	}
	
}


var xmlHttp
function ajaxcall()
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="index2.php?option=com_temprsgallery&task=listing_image&no_html=1" ;
	xmlHttp.onreadystatechange=extraservices
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function extraservices() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			document.getElementById("listing_image_div").innerHTML=xmlHttp.responseText 
			
		 } 
		 else
		{
			document.getElementById("listing_image_div").innerHTML="<img src='http://muare.vn/forum/images/imgLoading.gif'>";
		}
	}
	function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}

function newlisting(user_id){
	xmlHttp=GetXmlHttpObject()
	var cattag = document.getElementById('category');
	var category = cattag.options[cattag.selectedIndex].value;
	var limittag = document.getElementById('limit');
	var limit = limittag.options[limittag.selectedIndex].value;
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="index2.php?option=com_temprsgallery&task=newlisting&no_html=1&user_id="+user_id+"&category=" + category + "&limit=" + limit;
	xmlHttp.onreadystatechange=newlistingAjax
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function newlistingAjax() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			document.getElementById("listing_images_div").innerHTML=xmlHttp.responseText 
			
		 } 
		 else
		{
			document.getElementById("listing_images_div").innerHTML="<img src='http://sovereigngracesingles.com/j15a/components/com_temprsgallery/js/imgLoading.gif'>";
		}
	}
	function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}

function gotoPage(page,user_id){
	xmlHttp=GetXmlHttpObject()
	var cattag = document.getElementById('category');
	var category = cattag.options[cattag.selectedIndex].value;
	var limittag = document.getElementById('limit');
	var limit = limittag.value;
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="index2.php?option=com_temprsgallery&task=newlisting&user_id="+user_id+"&no_html=1&category=" + category + "&limit=" + limit + "&page=" + page;
	xmlHttp.onreadystatechange=newlistingAjax1
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function newlistingAjax1() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			document.getElementById("listing_images_div").innerHTML=xmlHttp.responseText 
			
		 } 
		 else
		{
			document.getElementById("listing_images_div").innerHTML="<img src='http://muare.vn/forum/images/imgLoading.gif'>";
		}
	}
	function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}

function removeImageAjax(id)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="index2.php?option=com_temprsgallery&task=delete_temp_image&no_html=1&id=" + id ;
	xmlHttp.onreadystatechange=deleteimage
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	}
	function deleteimage() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		 { 
			document.getElementById("listing_image_div").innerHTML=xmlHttp.responseText 
			
		 } 
		 else
		{
			document.getElementById("listing_image_div").innerHTML="<img src='http://muare.vn/forum/images/imgLoading.gif'>";
		}
	}
	function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	 {
	 // Firefox, Opera 8.0+, Safari
	 xmlHttp=new XMLHttpRequest();
	 }
	catch (e)
	 {
	 //Internet Explorer
	 try
	  {
	  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	  }
	 catch (e)
	  {
	  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	  }
	 }
	return xmlHttp;
}

function removeImage(id)
{
	var answer = confirm("Do you want to remove this image?");
	if(answer==1)
	{
		removeImageAjax(id);
	}
}
function deleteimage(alertstr,id){
	var answer = confirm(alertstr);
	if(answer==1){
		xmlHttp=GetXmlHttpObject()
		var cattag = document.getElementById('category');
		var category = cattag.options[cattag.selectedIndex].value;
		var limittag = document.getElementById('limit');
		var limit = limittag.value;
		if (xmlHttp==null)
		 {
		 alert ("Browser does not support HTTP Request")
		 return
		 }
		var url="index2.php?option=com_temprsgallery&task=deleteimage&no_html=1&category=" + category + "&limit=" + limit + "&id=" + id;
		xmlHttp.onreadystatechange=newlistingAjax
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
		}
		function newlistingAjax() 
		{ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 { 
				document.getElementById("listing_images_div").innerHTML=xmlHttp.responseText 
				
			 } 
			 else
			{
				document.getElementById("listing_images_div").innerHTML="<img src='http://muare.vn/forum/images/imgLoading.gif'>";
			}
		}
		function GetXmlHttpObject()
		{
		var xmlHttp=null;
		try
		 {
		 // Firefox, Opera 8.0+, Safari
		 xmlHttp=new XMLHttpRequest();
		 }
		catch (e)
		 {
		 //Internet Explorer
		 try
		  {
		  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		  }
		 catch (e)
		  {
		  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		  }
		 }
		return xmlHttp;
	}
}
