function loadPage () {
	// updateImage ('gallery/gallery.php', 'gallerymenu');
	
	updateNav('gallery/gallery.php', 'gallerymenu');
	setTimeout("updateImage('gallery/view.php?hit=no&gid=1', 'thumbmenu')", 1000);
	}
function updateImage (theURL, theFrame) {
	setStatus ("loading...", theFrame);
	
	//theURL = '../'+theURL;	
	processajax (theURL, theFrame, "post", "");

	if (theFrame == 'thumbmenu') {
		
		//theURL = 'test.html';
		//theFrame = 'galleryimage';
		//alert ('theURL: '+theURL+'; theFrame: '+theFrame);
		setTimeout("backTwoIt(theURL, 'galleryimage')", 500);
	}
	//document.all.galleryimage.src = theURL;
	
}
function backTwoIt (theURL, theFrame) {
	//theURL = '../'+theURL;
	//alert (theURL + theFrame);
	//document.getElementById(theFrame).innerHTML = '<div style = "position: absolute; margin-top:0px; margin-left: 0px; background-color: #000000; width: 100%; height: 100%;">Choose the gallery on the left, then choose the image above. <br />Knikkolette accepts visa and mastercard payments through Propay. You can contact her at <a href = "mailto:art@knikkolette.com">art@knikkolette.com</a>.</div>';
	processajax (theURL, theFrame, "post", "");
}

function updateNav(theURL, theFrame) {
	theURL = '../'+theURL;
	//alert (theURL+' '+theFrame);
	processajax (theURL, theFrame, "post", "");
}


function setStatus(theStatus, theObj)
	{
	obj = document.getElementById(theObj);
	if (obj)
		{
		obj.innerHTML = "<div id = \"status\" class = \"status\">" + theStatus + "</div>";

		}
	}

// function for submitting form
function submit_form (theForm) {
	name =  document.getElementById('name').value;
	company =  document.getElementById('company').value;
	phone = document.getElementById('phone').value;
	fax =  document.getElementById('fax').value;
	email =  document.getElementById('email').value;
	if (name == '') {
	  document.getElementById('div_name').style.color = '#ff0000';
	  alert ('Please enter your name.');
	   
	  } else {
	    document.getElementById('name').style.color = '#000000';
	    if ((isPhoneNumber (phone)) ) {
	      if (email != '') {
	        if (echeck(email)) {
	       	  document.theForm.submit();
		} else { return false; }
	      } else { 
		  document.theForm.submit();
	      }
	    } else { return false; }

	  }
	

}

function isPhoneNumber(s) 
{

     // Check for correct phone number
     rePhoneNumber = new RegExp(/^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/);

     if (!rePhoneNumber.test(s)) {
          alert("Phone Number Must Be Entered As: (555) 555-1234");
	  document.getElementById('div_phone').style.color = '#ff0000';
          return false;
     }
document.getElementById('div_phone').style.color = '#000000';
return true;
}


function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   document.getElementById('div_email').style.color = '#ff0000';
		   alert("Invalid E-mail ID, please enter an email in the form of yourname@domain.com.");
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   document.getElementById('div_email').style.color = '#ff0000';
		   alert("Invalid E-mail ID, please enter an email in the form of yourname@domain.com.")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    document.getElementById('div_email').style.color = '#ff0000';
		    alert("Invalid E-mail ID, please enter an email in the form of yourname@domain.com.");
		    return false;
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    document.getElementById('div_email').style.color = '#ff0000';
		    alert("Invalid E-mail ID, please enter an email in the form of yourname@domain.com.");
		    return false;
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    document.getElementById('div_email').style.color = '#ff0000';
		    alert("Invalid E-mail ID");
		    return false;
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    document.getElementById('div_email').style.color = '#ff0000';
		    alert("Invalid E-mail ID");
		    return false;
		 }
		
		 if (str.indexOf(" ")!=-1){
		    document.getElementById('div_email').style.color = '#ff0000';
		    alert("Invalid E-mail ID");
		    return false;
		 }
		document.getElementById('div_email').style.color = '#000000';
 		 return true;					
	}	