// JavaScript Document
// Piadina Mia, Inc.

function toggleSubMenu(id, show){
	var myMenu = document.getElementById(id);

	if(show == true){
		myMenu.style.display = '';
	}else{
		myMenu.style.display = 'none';
	}
}

function AC_RunActiveContent(){
var acContent = '\
<OBJECT \
classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" \
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH="600" HEIGHT="200" \
id="flash_header" ALIGN=""> \
<PARAM NAME=movie VALUE="./flash/flash_header.swf"> \
<PARAM NAME=quality VALUE=high> \
<PARAM NAME=wmode VALUE=transparent> \
<PARAM NAME=bgcolor VALUE=#FFFFFF> \
<EMBED src="./flash/flash_header.swf" quality=high wmode=transparent bgcolor=#FFFFFF  WIDTH="600" HEIGHT="200" NAME="flash_header" \
ALIGN="" TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer"></EMBED> \
</OBJECT>';

	document.write(acContent);
}

function callFrame(){
	var myIframe = document.getElementById('order_iframe');
	var form = document.order_form_piadina;
	var myForm;

	if (myIframe.contentDocument) {
   	// For NS6
    	myForm = myIframe.contentDocument.order_form_piadina; 
  	} else if (myIframe.contentWindow) {
    	// For IE5.5 and IE6
    	myForm = myIframe.contentWindow.document.order_form_piadina;
  	} else if (myIframe.document) {
    	// For IE5
    	myForm = myIframe.document.order_form_piadina;
  	} 
	
	for(var i = 0; i < form.elements.length; i++){
		if(form.elements[i].type != 'button'){
			myForm[form.elements[i].name].value = form.elements[i].value;
		}
	}
	
	myForm.submit();
}

function validateForm() {
	var myForm = document.order_form_piadina;
	
	if(myForm.first_name_piadina.value == ""){
		alert("First Name is Required!");
		myForm.first_name_piadina.focus();
		return false;
	}else if(myForm.last_name_piadina.value == ""){
		alert("Last Name is Required!");
		myForm.last_name_piadina.focus();
		return false;
	}else if(myForm.phone_piadina.value == ""){
		alert("Phone Number is Required!");
		myForm.phone_piadina.focus();
		return false;
	}else if(myForm.email_piadina.value == ""){
		alert("Email Address is Required!");
		myForm.email_piadina.focus();
		return false;
	}else if(myForm.email_piadina.value.indexOf('.') == -1){
		alert("A valid Email Address is Required!");
		myForm.email_piadina.focus();
		return false;
	}else if(myForm.email_piadina.value.indexOf('@') == -1){
		alert("A valid Email Address is Required!");
		myForm.email_piadina.focus();
		return false;
	}else if(myForm.order_piadina.value == ""){
		alert("Order Request is Required!");
		myForm.order_piadina.focus();
		return false;
	}


	return true;
}

function getVideo(id){
      var html;
      
      if(id == 'mimmo'){
      	html = '<div class="video-close"><img src="./images/12-em-cross.gif" onclick="Element.remove(\'pmu-video\');"/></div><span class="video-title">Piadina Mia Video</span><br/><span class="video-sub">Gloriana Casadei, President of Piadina Mia, and Chef Mimmo presenting various piadina recipes.</span><br/><br/><object width="425" height="344"><param name="wmode" value="opaque"></param><param name="movie" value="http://www.youtube.com/v/nXYNSpe9CO8&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/v/nXYNSpe9CO8&hl=en&fs=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344" wmode="opaque"></embed></object>';
		}else if(id == 'italfest'){
			html = '<div class="video-close"><img src="./images/12-em-cross.gif" onclick="Element.remove(\'pmu-video\');"/></div><span class="video-title">Piadina Mia Video</span><br/><span class="video-sub">Piadina Mia, Inc presenting at the Italian Festival.</span><br/><br/><object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/ITrUzh9T3Nc&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/ITrUzh9T3Nc&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>';
		}

		//create new element and set attributes
		var newDiv = document.createElement('div');
		var docBody = document.body;
	  	newDiv.id = 'pmu-video';
  		newDiv.innerHTML = html;
      newDiv.style.top = '60px';
      newDiv.style.left = '600px';
      newDiv.className = 'video-content';
  		docBody.appendChild(newDiv);
  		
      var newWinObject = $('pmu-video');
  		var maxWidth = Element.getWidth('page_setup');
      newWinObject.style.left = (maxWidth - 425)/2 + 'px';
}