<!--

////////////////
// ImageViewer
////////////////
function ImageViewer(imagesrc,winwidth,winheight)
{
	var look='width='+winwidth+',height='+winheight+','
	popwin=window.open("","",look)
	popwin.document.open()
	popwin.document.write('<title>Portfolio Viewer</title><body style="MARGIN: 0px"><img src="images/portfolio/large/'+imagesrc+'"></body>')
	popwin.document.close()
}


////////////////
// image preload
////////////////
function preloadimages() {

}


/////////////
// image swap
/////////////
function changer(from, to) {
	if(document.images) {
		document.images[from].src = "images/buttons/" + from + "_" + to + ".jpg";
	}
}


//////////
// general
//////////
function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
 
}


///////////////////////
// send contact_us form
//////////////////////
function sendContactUs(theElement){

	var theForm = theElement.form, z = 0;
	var contactUsName = document.getElementById('contact_us_name').value;
	var contactUsEmail = document.getElementById('contact_us_email').value;
	var contactUsBody = document.getElementById('contact_us_body').value;
		
	var errorFlag = 0;
	var elems;

	var url;
	var response;
	
	// creates a new XMLHttpRequest object to talk to the web server
	var xmlHttp = false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	try {
	  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	  try {
	    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (e2) {
	    xmlHttp = false;
	  }
	}
	@end @*/

	if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
	  xmlHttp = new XMLHttpRequest();
	}


	//alert(contactUsName);
	//alert(contactUsEmail);
	//alert(contactUsBody);
	
	if(contactUsName == ""){
		alert("Name is missing. Please enter a valid name.");
		errorFlag = 1;
	}

	if(!isValidEmail(contactUsEmail)){
		alert("Invalid email address. Please enter a valid email address.");
		errorFlag = 1;
	}
	
	if(contactUsBody == ""){
		alert("Body of the message is missing. Please enter a valid message.");
		errorFlag = 1;
	}
		
	if(errorFlag == 0){

	  // build URL to connect to
	  url = "send.php?type=contact_us&name=" + escape(contactUsName) + "&email=" + escape(contactUsEmail) + "&body=" + escape(contactUsBody);
		//alert("before open" + url);
		
	  // open a connection to the server
	  xmlHttp.open("POST", url, true);
	
		//alert("before status: " + url);
		
	  // setup a function for the server to run when it is done
	  xmlHttp.onreadystatechange = getSendState;

		//alert("after status: " + url);

	  // send the request
	  xmlHttp.send(null);
	
		alert("Thank you for contacting us.");
		document.getElementById('contact_us_name').value = "";
		document.getElementById('contact_us_email').value = "";
		document.getElementById('contact_us_body').value = "";

	}
	
	
	function getSendState() {
			
	
		  if (xmlHttp.readyState == 4) {

				 // if "OK"
				if (xmlHttp.status != 200)
				{
					alert("Problem updating.")
				} else {
	
			    response = xmlHttp.responseText;
			    //alert(response);
	
				} // end status check
	    
		  } // end readyState check
	
		} // end getSubscribeState()	
	
}




//-->