function CloseIt()
		{
		opener.location.reload()	
		close();
		}
		
function CloseArt()
		{
		close();
		}

function openGenre()
		{
		window.open('edit_genre.php','','width=400,height=300,scrollbars=yes,left=20,top=20');
		return false;
		}
		
function openContact()
		{
		window.open('contact.php','','width=400,height=365,scrollbars=yes,left=20,top=20');
		return false;
		}

function f1()
		{
		document.logonform.username.focus();
		}

function f2()
		{
		document.editpaint.artgenre.focus();
		}
		
function f3()
		{
		document.addtype.genre.focus();
		}	
		
function f4()
		{
		document.addlink.alink.focus();
		}	
		
function openEdit(id)
		{
		window.open('edit.php?d='+id+'','','width=400,height=500,scrollbars=yes');
		}
		
function openEditlink(id)
		{
		window.open('editlink.php?d='+id+'','','width=400,height=500,scrollbars=yes');
		}
		
function openPix(pic)
		{
		window.open('pix.php?p='+pic+'','','width=600,height=750,scrollbars=yes');
		}

function submitLogon()
		{
		re = 'no';
		repass = /^[0-9A-Za-z]+$/;
			if(repass.test(document.logonform.username.value))
				{
				re='yes';
				}
			else
				{
				alert('Please make sure the username is alpha numeric');
				document.logonform.username.select();
				document.logonform.username.focus();
				return false;
				}	
			if(repass.test(document.logonform.pw.value))
				{
				re='yes';
				}
			else
				{
				alert('Please make sure the password is alpha numeric');
				document.logonform.pw.select();
				document.logonform.pw.focus();
				return false;
				}
			if(re=='yes')
				{
				return true
				}
			}
	
function submitEditpaint()
			{
		re = 'no';
		repass = /^[0-9A-Za-z\,\.\'\-\s]+$/;
		renote = /^[0-9/s]+$/;
			if(repass.test(document.editpaint.artdesc.value))
				{
				re='yes';
				}
			else
				{
				alert("Please make sure the Description is only letters, numbers and ,.'- only");
				document.editpaint.artdesc.select();
				document.editpaint.artdesc.focus();
				return false;
				}
			if(repass.test(document.editpaint.artname.value))
				{
				re='yes';
				}
			else
				{
				alert("Please make sure the Painting Name is only letters, numbers and ,.'- only");
				document.editpaint.artname.select();
				document.editpaint.artname.focus();
				return false;
				}
			if(document.editpaint.artgenre.value != "Select")
				{
				re='yes'
				}
			else
				{				
				alert("Please select a Genre");
				return false;
				}
			if(renote.test(document.editpaint.artprice.value))
				{
				re='yes';
				}
			else
				{
				alert("Please make sure the price of the painting is in whole dollars");
				document.editpaint.artprice.select();
				document.editpaint.artprice.focus();
				return false;
				}
				
			if(re=='yes')
				{
				return true
				}
			}

function submitTyp()
			{
		re = 'no';
		repass = /^[A-Za-z\,\.\'\-\s]+$/;
			if(repass.test(document.addtype.genre.value))
				{
				re='yes';
				}
			else
				{
				alert("Please make sure there is only letters and ,.'- only");
				document.addtype.genre.select();
				document.addtype.genre.focus();
				return false;
				}	
			if(re=='yes')
				{
				return true
				}
			}
			
function submitUppaint()
			{
		re = 'no';
		repass = /^[0-9A-Za-z\,\.\'\-\s]+$/;
		renote = /^[0-9/s]+$/;
			if(repass.test(document.uppaint.updescr.value))
				{
				re='yes';
				}
			else
				{
				alert("Please make sure the Description is only letters, numbers and ,.'- only");
				document.uppaint.updescr.select();
				document.uppaint.updescr.focus();
				return false;
				}
			if(repass.test(document.uppaint.upname.value))
				{
				re='yes';
				}
			else
				{
				alert("Please make sure the Painting Name is only letters, numbers and ,.'- only");
				document.uppaint.upname.select();
				document.uppaint.upname.focus();
				return false;
				}
			if(renote.test(document.uppaint.upprice.value))
				{
				re='yes';
				}
			else
				{
				alert("Please make sure the price of the painting is in whole dollars");
				document.uppaint.upprice.select();
				document.uppaint.upprice.focus();
				return false;
				}
				
			if(re=='yes')
				{
				return true
				}
			}

function Contact()
		{
		re = "no";
		remail = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
		rename = /^((?:[A-Z](?:('|(?:[a-z]{1,3}))[A-Z])?[a-z]+)|(?:[A-Z]\.))(?:([ -])((?:[A-Z](?:('|(?:[a-z]{1,3}))[A-Z])?[a-z]+)|(?:[A-Z]\.)))?$/;
		remess = /^[0-9A-Za-z\,\.\'\-\s]+$/;	
			if(rename.test(document.contact.name.value))
				{
				re="yes";
				}
			else
				{
				alert("Please check your name");
				document.contact.name.select();
				document.contact.name.focus();
				return false;
				}
			if(remail.test(document.contact.email.value))
				{
				re="yes"
				}
			else 
				{
				alert("Please check your email address");
				document.contact.email.focus();
				document.contact.email.select();
				return false
				}
			if(remess.test(document.contact.question.value))
				{
				re="yes";
				}
			else
				{
				alert("Please check your Message");
				document.contact.question.select();
				document.contact.question.focus();
				return false;
				}
		if(re=="yes")
		{
		return true
		}
		}

function getObject(obj)
		{
  		var theObj;
  		if(document.all)
			{
    		if(typeof obj=="string")
				{
      			return document.all(obj);
    			} 
				else
				{
      			return obj.style;
    			}
  			}
  			if(document.getElementById)
				{
				if(typeof obj=="string")
					{
      				return document.getElementById(obj);
    				}
					else
					{
      				return obj.style;
    				}
  			}
  			return null;
		}

	
function Contar(entrada,salida,texto,caracteres)
		{
  		var entradaObj=getObject(entrada);
 		var salidaObj=getObject(salida);
  		var longitud=caracteres - entradaObj.value.length;
  		if(longitud <= 0)
			{
		    longitud=0;
    		texto='<span class="disable"> '+texto+' </span>';
    		entradaObj.value=entradaObj.value.substr(0,caracteres);
  			}
  			salidaObj.innerHTML = texto.replace("{CHAR}",longitud);
		}