var xmlHttp;

function select_arch(){
	xmlHttp=GetXmlHttpObject();
	if(xmlHttp==null)
 	{
	 alert ("Browser does not support HTTP Request/AJAX, uprade to latest version of your browser");
	 return;
 	}
	
	var sel = document.getElementById('dateMenu');
	var date_val = sel.value;
	var url = "thumb_archives.php?date="+date_val+"&num="+(Math.floor(Math.random()*20));
		
	xmlHttp.onreadystatechange=stateChanged_selectArch;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function stateChanged_selectArch() 
{ 
	if(xmlHttp.readyState==1 )
	{ 
		document.getElementById('thumb').innerHTML = "<div id='loading-con' >loading albums...</div>";			
	}
	if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById('thumb').innerHTML = xmlHttp.responseText;			
	}
	
}

function showPers(galleryid,id,page)
{
	xmlHttp=GetXmlHttpObject();
	if(xmlHttp==null)
 	{
	 alert ("Browser does not support HTTP Request/AJAX, uprade to latest version of your browser");
	 return;
 	}
	
	var url = "cart/pers.php?album="+galleryid+"&id="+id+"&page="+page+"&num="+(Math.floor(Math.random()*20));
	
	
	xmlHttp.onreadystatechange=stateChanged2;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged2() 
{ 
	if(xmlHttp.readyState==1 )
	{ 
		document.getElementById('thumbs').innerHTML = "<div id='loading-con' >loading image...</div>";			
	}
	if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById('thumbs').innerHTML = xmlHttp.responseText;			
	}
	
}
var id, qty_id;
var xmlHttp2;
//show product large image
function plus(album, id, page)
{
	xmlHttp=GetXmlHttpObject();
	if(xmlHttp==null)
 	{
	 alert ("Browser does not support HTTP Request/AJAX, uprade to latest version of your browser");
	 return;
 	}
	
	var url = "cart/cart.php?id="+id+"&album="+album+"&page="+page+"&num="+(Math.floor(Math.random()*20));
	
	xmlHttp.onreadystatechange=stateChanged3;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function refresh_cart()
{
	xmlHttp=GetXmlHttpObject();
	if(xmlHttp==null)
 	{
	 alert ("Browser does not support HTTP Request/AJAX, uprade to latest version of your browser");
	 return;
 	}
	
	var url = "cart/showCart.php";
	//alert(url);
	xmlHttp.onreadystatechange=stateChanged3;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function stateChanged3() 
{ 
	if(xmlHttp.readyState==1 )
	{ 
		document.getElementById('cart_thumbs').innerHTML = "<div id='loading-con' >loading cart...</div>";			
	}
	if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById('cart_thumbs').innerHTML = xmlHttp.responseText;
		//alert(xmlHttp.responseText);
	}
	
}
function addQty(id)
{
	xmlHttp2=GetXmlHttpObject();
	if(xmlHttp2==null)
 	{
	 alert ("Browser does not support HTTP Request/AJAX, uprade to latest version of your browser");
	 return;
 	}
	
	var url2 = "cart/functions.php?id="+id+"&add&num="+(Math.floor(Math.random()*20));
	qty_id = "qty_"+id;
	//alert(id);
	xmlHttp2.onreadystatechange=stateChanged;
	xmlHttp2.open("GET",url2,true);
	xmlHttp2.send(null);
}

function subQty(id)
{
	xmlHttp2=GetXmlHttpObject();
	if(xmlHttp2==null)
 	{
	 alert ("Browser does not support HTTP Request/AJAX, uprade to latest version of your browser");
	 return;
 	}
	
	var url2 = "cart/functions.php?id="+id+"&sub&num="+(Math.floor(Math.random()*20));
	qty_id = "qty_"+id;
	//alert(id);
	xmlHttp2.onreadystatechange=stateChanged;
	xmlHttp2.open("GET",url2,true);
	xmlHttp2.send(null);
	
}

function stateChanged() 
{ 
	if(xmlHttp2.readyState==4 || xmlHttp2.readyState=="complete")
	{ 
		document.getElementById(qty_id).innerHTML = xmlHttp2.responseText;
		//alert(xmlHttp2.responseText);
		refresh_cart();
	}
}

function GetXmlHttpObject()
{
	var xmlHttp=null;
	var xmlHttp2=null;
	try
	{	
		xmlHttp=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari
		xmlHttp2=new XMLHttpRequest(); // Firefox, Opera 8.0+, Safari
	}
	catch(e)
	{	
		try //Internet Explorer
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			xmlHttp2=new ActiveXObject("Msxml2.XMLHTTP");
		}
						
		catch(e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			xmlHttp2=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
	return xmlHttp2;
}


