// ****************************************************************************
// popup
// ****************************************************************************
function popupwindow(url,name,windowWidth,windowHeight){
  myleft=(screen.width)?(screen.width-windowWidth)/2:100;
	mytop=(screen.height)?(screen.height-windowHeight)/2:100;
	properties = "width="+windowWidth+",height="+windowHeight+",scrollbars=yes, top="+mytop+",left="+myleft;
  window.open(url,name,properties)
}

// ****************************************************************************
// popupplayer
// ****************************************************************************
function popupplayer(){
  var url = 'flash/player.html';
  var windowWidth = 320;
  var windowHeight = 420;
  var name = 'player';
  
  myleft=(screen.width)?(screen.width-windowWidth)/2:100;
	mytop=(screen.height)?(screen.height-windowHeight)/2:100;
	properties = "width="+windowWidth+",height="+windowHeight+",scrollbars=no, top="+mytop+",left="+myleft;
  window.open(url,name,properties)
}

// ****************************************************************************
// checkinput
// ****************************************************************************
function checkinput(obj, strDef) {
  // if content equals def than clear
  if (obj.value == strDef) {
    obj.value = "";
  }
}

// ****************************************************************************
// showLayer
// ****************************************************************************
function showLayer(szDivID, iState) {
	if(document.layers)    //NN4+
	{
		 document.layers[szDivID].visibility = iState ? "show" : "hide";
	}
	else if(document.getElementById)      //gecko(NN6) + IE 5+
	{
		var obj = document.getElementById(szDivID);
		obj.style.visibility = iState ? "visible" : "hidden";
	}
	else if(document.all)       // IE 4
	{
		document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
	}
}

// ****************************************************************************
// openContact
// ****************************************************************************
function openContact() {
	showLayer("contactform", true);
}

// ****************************************************************************
// closeContact
// ****************************************************************************
function closeContact() {
	showLayer("contactform", false);
}

// ****************************************************************************
// clearContact
// ****************************************************************************
function clearContact() {
	MM_findObj("form_name").value = "YOUR NAME";
	MM_findObj("form_email").value = "YOUR EMAIL";
	MM_findObj("form_website").value = "YOUR WEBSITE (optional)";
	MM_findObj("form_message").value = "YOUR MESSAGE";		
}

// ******************************************************************
// buildPOST
// ******************************************************************				
function buildPOST(form) { 
    var qs = '' 
    for (e=0;e<form.elements.length;e++) { 
        if (form.elements[e].name!='') { 
            var name = form.elements[e].name; 
            qs+=(qs=='')?'':'&' 
            qs+= name+'='+escape(form.elements[e].value); 
        } 
    } 
    qs+="\n"; 
    return qs 
} 

// ****************************************************************************
// validateonsubmit
// ****************************************************************************
function validateonsubmit(form) {
	var xmlhttp = false;
					
	// If the user is using Mozilla/Firefox/Safari/etc
	if (window.XMLHttpRequest) {
		//Intiate the object
		xmlhttp = new XMLHttpRequest();        
		if(xmlhttp.overrideMimeType){               
			//Set the mime type
			xmlhttp.overrideMimeType('text/xml');
		}            
	} else if (window.ActiveXObject) {
		//Intiate the object
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	}

	// send to order processor
	xmlhttp.open('POST', "contacthandler/action", true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");        
	xmlhttp.onreadystatechange = function() {
		if(xmlhttp.readyState == 4 && xmlhttp.status == 200) {
		}
	}
	// package up form    
	var strPost = buildPOST(form);
	xmlhttp.send(strPost);    

	closeContact();
	clearContact();
	
	return false;
}
