var xmlHttp

function showCustomer(str)
{ 
str=document.getElementById(str).value;
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  } 
var url="getuser.php";
url=url+"?action=UserName&q="+str;
url=url+"&sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4)
	{
	 if(xmlHttp.status==200)
		 {
		 var data=xmlHttp.responseText;
		 alert(data);
		 if(data!='Please change user name.') {
			 document.getElementById('txtAlert').innerHTML=  document.getElementById('user_name').value + ' Please change user name.';
			 document.getElementById('txtAlert').style.display='block';	
			 document.getElementById('user_name').value='';
			 document.getElementById('user_name').focus();
		  }
		  else
		  {
			 document.getElementById('txtAlert').style.display='none';	
			
		  }
 
	  }
		
		//document.getElementById("txtAlert").innerHTML=xmlHttp.responseText;
	}
}

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 Show_Artist_List(str){
	document.getElementById('price_list').style.display="none";
	document.getElementById('artist_list').style.display="block";
	document.getElementById("artist_list").innerHTML='Loading';
		
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="getuser.php";
	url=url+"?action=Artist&q="+str;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateArtist;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	}
	
function stateArtist() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById("artist_list").innerHTML=xmlHttp.responseText;
	}
}
	
function Close_div(){
	document.getElementById('artist_list').style.display="none";
}

//Price List
function Show_Price_List(){
	document.getElementById('artist_list').style.display="none";
	document.getElementById('price_list').style.display="block";
	document.getElementById("price_list").innerHTML='Loading';
		
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="getuser.php";
	url=url+"?action=Price";
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=statePrice;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	}
	
function statePrice() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById("price_list").innerHTML=xmlHttp.responseText;
	}
}


function Show_Artist_Image(move,page,artid,pid,step){
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="getuser.php";
	url=url+"?action=Artist_Image&move=" + move + '&p=' + page + '&artid=' + artid + "&pid=" + pid + "&step=" + step ;
	url=url+"&sid="+Math.random();
	xmlHttp.onreadystatechange=stateArtistImage;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	}
	
function stateArtistImage() 
{ 
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById("artist_img").innerHTML=xmlHttp.responseText;
	}
}


function Close_Price_div(){
	document.getElementById('price_list').style.display="none";
}

function NewsLetterNameBlank(){
	document.getElementById('news_letter_name').value='';
}
function NewsLetterName(){
	if(document.getElementById('news_letter_name').value==''){
		document.getElementById('news_letter_name').value='Enter your name';
	}
}

function NewsLetterEmailBlank(){
	document.getElementById('news_letter_email').value='';
}
function NewsLetterEmail(){
	if(document.getElementById('news_letter_email').value==''){
		document.getElementById('news_letter_email').value='Enter your email';
	}
}

function LoginNameBlank(){
	document.getElementById('login_name').value='';
}
function LoginName(){
	if(document.getElementById('login_name').value==''){
		document.getElementById('login_name').value='Enter user name';
	}
}

function LoginPasswordBlank(){
	document.getElementById('login_pass').value='';
}
function LoginPassword(){
	if(document.getElementById('login_pass').value==''){
		document.getElementById('login_pass').value='Enter password';
	}
}

function ShowArtist(showby){
	var url='1-' + showby + '-artists.html';
	window.location=url;
}
function ShowImageDetails(e,img,name,title,year,medium,sty,inch,cm,img_width,img_height,big_img_height){
	if(img_height >=140){
		img_height =140
	}
	var height;
	var sml_img_height = 300;
	if(String(big_img_height) >= String(sml_img_height))
	{
		height = (big_img_height - 300)/2.5;
	}
	else
	{
		height = -70;
	}
	
	var browserName  = navigator.appName;
	var x = e.clientX;
	var divleft = x - 20 + 'px';
	if(browserName == 'Netscape'){
		var y = e.pageY;
		var divtop = y - 300 + 'px';
	}else{
		var y = e.clientY;
		var divtop = y + height + 'px';
	}
	if(year==0){
		year='';
	}
	
	var img ='<div style="text-align:center; margin:0px; padding:0px;"><img src="painting/thumb/'+ img + '" width="' + img_width + '" height="' + img_height +'"></div><span class="text"><b>' + name + '</b><br />' + title + '<br />' +  year + '<br />' + medium + '<br />' + sty + '<br />' + inch + '<br />' + cm + '</span>';
	document.getElementById('img_show').style.display = 'block';
	document.getElementById('img_show').style.background='#FFFFFF';
	document.getElementById('img_show').style.position = 'absolute';
	document.getElementById('img_show').style.padding = '5px';
	document.getElementById('img_show').style.width = '160px';
	document.getElementById('img_show').style.height = '230px';
	document.getElementById('img_show').style.left = divleft;
	document.getElementById('img_show').style.top = divtop;
	
	document.getElementById('img_show').style.border = '#77969E solid 1px';
	document.getElementById('img_show').innerHTML = img;
}

function CloseDetails(){
	document.getElementById('img_show').style.display = 'none';
}

function Artist_Painting_Paging(move,p,artid,pid,step){
	var url = "painting-info.php?pid=" + pid + "&artID=" + artid +"&move=" + move + "&p=" + p + "&step=" + step + "#controlImage";
	window.location=url ;
	
}

function Close_Artist_Div(){
	document.getElementById("artist_list").style.display='none';
}

function Close_Price_Div(){
	document.getElementById("price_list").style.display='none';
}
