
// AJAX ----------------------------------------
////////////FOR FIRST IMAGE//////////////////
var xmlHttp

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;

}

// Show the image for first image
function browseImg(){
	//delInfo();
	var addInfo1=document.all?document.all['del_info']:document.getElementById('del_info');
	xmlHttp = GetXmlHttpObject()
	var image = document.getElementById('img').value;
	if(xmlHttp == null){
		alert ("Your browser does not support AJAX!");
		return;
	  }

	xmlHttp.onreadystatechange = function(){
		
	var loader = document.getElementById('showImg');
	
		if (xmlHttp.readyState == 4){ 
			
			//loader.style.display = 'none';
			var res = xmlHttp.responseText;
			string = res.replace(new RegExp(/\\/g),"/");
			if (document.images){
				pic1= new Image(10,40); 
				pic1.src=string; 
			}
			if(navigator.appName=='Microsoft Internet Explorer') {
			loader.innerHTML ='<image width=80 height=80 src='+pic1.src+ ' >';
				addInfo1.style.display = '';
				}
		} else {
			if(navigator.appName=='Microsoft Internet Explorer') {
			loader.innerHTML = '<img src="images/rating_loading.gif" alt="loading" />';
			}
			 addInfo1.style.display = 'none';	
		}
	
	}
	var url = "checkAvailability1.php?image="+image;
	var params = "image="+image;
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);
} 
///Delete image
function browseImg1(){
	//delInfo();
	var addInfo1=document.all?document.all['del_info']:document.getElementById('del_info');
	xmlHttp = GetXmlHttpObject()
	var image = document.getElementById('img').value;
	if(xmlHttp == null){
		alert ("Your browser does not support AJAX!");
		return;
	  }

	xmlHttp.onreadystatechange = function(){
		
	var loader = document.getElementById('showImg');
	
		if (xmlHttp.readyState == 4){ 
			
			//loader.style.display = 'none';
			var res = xmlHttp.responseText;
			loader.innerHTML =res;
			
		} else {
			loader.innerHTML = '<img src="images/rating_loading.gif" alt="loading" />';
			 addInfo1.style.display = 'none';	
		}
	
	}
	var url = "checkAvailability1.php?image="+'';
	var params = "image="+'';
	xmlHttp.open("POST",url,true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);
} 
 function clearMe() { 

  document.getElementById("img").value='';
 document.getElementById("test").innerHTML="<input type=\"file\" name=\"image\" id=\"img\" onChange=\"browseImg()\">";
}
/*function delInfo() {
var addInfo1=document.all?document.all['del_info']:document.getElementById('del_info');
if (addInfo1.style.display == 'none') {
    addInfo1.style.display = '';
     } else {
     addInfo1.style.display = 'none';
   }
}*/

// Show the image for second image
// AJAX ----------------------------------------
//////////////////////FOR SECOND IMAGE//////////////////////////////////////
var xmlHttp2

function GetXmlHttpObject2(){
var xmlHttp2 = null;

	try {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp2 = new XMLHttpRequest2();
	  }
	catch (e) {
	  // Internet Explorer
	  try {
			xmlHttp2 = new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e){
			xmlHttp2 = new ActiveXObject("Microsoft.XMLHTTP");
		}
	  }
	  
	return xmlHttp2;

}
// Show the image for second image
function browseImgSe(){
	//delInfo();
	var addInfo1=document.all?document.all['del_infoSe']:document.getElementById('del_infoSe');
	xmlHttp2 = GetXmlHttpObject2()
	var image = document.getElementById('imgSe').value;
	if(xmlHttp2 == null){
		alert ("Your browser does not support AJAX!");
		return;
	  }

	xmlHttp2.onreadystatechange = function(){
		
	var loaderSe = document.getElementById('showImgSe');
	
		if (xmlHttp2.readyState == 4){ 
			
			//loader.style.display = 'none';
			var res = xmlHttp2.responseText;
			string = res.replace(new RegExp(/\\/g),"/");
			if (document.images){
				pic1= new Image(10,40); 
				pic1.src=string; 
			}
			loaderSe.innerHTML ='<image width=80 height=80 src='+pic1.src+ ' >';
			//delInfo();
			addInfo1.style.display = '';
		} else {
			loaderSe.innerHTML = '<img src="images/rating_loading.gif" alt="loading" />';
			 addInfo1.style.display = 'none';	
		}
	
	}
	var url = "checkAvailability2.php?image="+image;
	var params = "image="+image;
	xmlHttp2.open("POST",url,true);
	xmlHttp2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp2.setRequestHeader("Content-length", params.length);
	xmlHttp2.setRequestHeader("Connection", "close");
	xmlHttp2.send(params);
} 
///Delete image
function browseImg1Se(){
	//delInfo();
	var addInfo1=document.all?document.all['del_infoSe']:document.getElementById('del_infoSe');
	xmlHttp2 = GetXmlHttpObject2()
	var image = document.getElementById('imgSe').value;
	if(xmlHttp2 == null){
		alert ("Your browser does not support AJAX!");
		return;
	  }

	xmlHttp2.onreadystatechange = function(){
	var loaderSe = document.getElementById('showImgSe');
		if (xmlHttp2.readyState == 4){ 
			
			//loader.style.display = 'none';
			var res = xmlHttp2.responseText;
			loaderSe.innerHTML =res;
			
		} else {
			loaderSe.innerHTML = '<img src="images/rating_loading.gif" alt="loading" />';
			 addInfo1.style.display = 'none';	
		}
	
	}
	var url = "checkAvailability2.php?image="+'';
	var params = "image="+'';
	xmlHttp2.open("POST",url,true);
	xmlHttp2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp2.setRequestHeader("Content-length", params.length);
	xmlHttp2.setRequestHeader("Connection", "close");
	xmlHttp2.send(params);
} 
 function clearMeSe() { 

  document.getElementById("imgSe").value='';
 document.getElementById("testSe").innerHTML="<input type=\"file\" name=\"image\" id=\"imgSe\" onChange=\"browseImgSe()\">";
}
// Show the image for third image
var xmlHttp3

function GetXmlHttpObject3(){
var xmlHttp3 = null;

	try {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp3 = new XMLHttpRequest3();
	  }
	catch (e) {
	  // Internet Explorer
	  try {
			xmlHttp3 = new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e){
			xmlHttp3 = new ActiveXObject("Microsoft.XMLHTTP");
		}
	  }
	  
	return xmlHttp3;

}
function browseImgThi(){
	//delInfo();
	var addInfo1=document.all?document.all['del_infoThi']:document.getElementById('del_infoThi');
	xmlHttp3 = GetXmlHttpObject3()
	var image = document.getElementById('imgThi').value;
	if(xmlHttp3 == null){
		alert ("Your browser does not support AJAX!");
		return;
	  }

	xmlHttp3.onreadystatechange = function(){
		
	var loader = document.getElementById('showImgThi');
	
		if (xmlHttp3.readyState == 4){ 
			
			//loader.style.display = 'none';
			var res = xmlHttp3.responseText;
			string = res.replace(new RegExp(/\\/g),"/");
			if (document.images){
				pic1= new Image(10,40); 
				pic1.src=string; 
			}
			loader.innerHTML ='<image width=80 height=80 src='+pic1.src+ ' >';
			//delInfo();
			addInfo1.style.display = '';
		} else {
			loader.innerHTML = '<img src="images/rating_loading.gif" alt="loading" />';
			 addInfo1.style.display = 'none';	
		}
	
	}
	var url = "checkAvailability3.php?image="+image;
	var params = "image="+image;
	xmlHttp3.open("POST",url,true);
	xmlHttp3.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp3.setRequestHeader("Content-length", params.length);
	xmlHttp3.setRequestHeader("Connection", "close");
	xmlHttp3.send(params);
} 
///Delete image
function browseImg1Thi(){
	//delInfo();
	var addInfo1=document.all?document.all['del_infoThi']:document.getElementById('del_infoThi');
	xmlHttp3 = GetXmlHttpObject3()
	var image = document.getElementById('imgThi').value;
	if(xmlHttp3 == null){
		alert ("Your browser does not support AJAX!");
		return;
	  }

	xmlHttp3.onreadystatechange = function(){
		
	var loader = document.getElementById('showImgThi');
	
		if (xmlHttp3.readyState == 4){ 
			
			//loader.style.display = 'none';
			var res = xmlHttp3.responseText;
			loader.innerHTML =res;
			
		} else {
			loader.innerHTML = '<img src="images/rating_loading.gif" alt="loading" />';
			 addInfo1.style.display = 'none';	
		}
	
	}
	var url = "checkAvailability3.php?image="+'';
	var params = "image="+'';
	xmlHttp3.open("POST",url,true);
	xmlHttp3.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp3.setRequestHeader("Content-length", params.length);
	xmlHttp3.setRequestHeader("Connection", "close");
	xmlHttp3.send(params);
} 
 function clearMeThi() { 

  document.getElementById("imgThi").value='';
 document.getElementById("testThi").innerHTML="<input type=\"file\" name=\"image\" id=\"imgThi\" onChange=\"browseImgThi()\">";
}
 