// JavaScript Document

function showIntro()
{
  document.write ("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='500' height='300'>");
  document.write ("<param name='movie' value='stamps10.swf'>");
  document.write ("<param name='quality' value='high'>");
  document.write ("<param name='menu' value='false'>");
  document.write ("<embed src='stamps10' width='500' height='300' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' menu='false'></embed></object>");
}

function showCountdown()
{
  document.write ("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='409' height='24'>");
  document.write ("<param name='movie' value='countdown.swf'>");
  document.write ("<param name='quality' value='high'>");
  document.write ("<param name='menu' value='false'>");
  document.write ("<embed src='countdown.swf' width='409' height='24' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' menu='false'></embed></object>");
}

function showMenuItem(image)
{
  window.open ('menu_item.php' + '?image=' + image, '','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=675,height=505,screenX=0,screenY=0,top=0,left=0');
}

function showPoster(image, w, h)
{
  window.open ('http://www.jamesonspubs.com/ne/poster.php' + '?image=' + image, '','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=' + w + ',height=' + h + ',screenX=0,screenY=0,top=0,left=0');
}

function editDay(id)
{
  window.open ('http://www.jamesonsirishpub.com/admin/edit_day.php' + '?id=' + id, '','toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=550, height=175, screenX=0,screenY=0,top=0,left=0');
}

function validateContact()
{
  if (document.form1.name.value.length < 1 || document.form1.comment.value.length < 1 || document.form1.phone.value.length < 1)
  {
    alert("Please complete the required fields");
	return false;
  }  
}

function validateBooking()
{
  if (document.form1.name.value.length < 1)
  {
    alert("Please enter your name");
	return false;
  }
  else if (document.form1.phone.value.length < 1)
  {
    alert("Please enter your phone number");
	return false;
  }
  else if (document.form1.type.value == "select")
  {
    alert("Please select the type of event");
	return false;
  } 
  else if(document.form1.type.value == "Other" && document.form1.other.value.length < 1)
  {
    alert("Please specify the type of event (other)");
	return false;
  }  
  else if(document.form1.pref_date.value.length < 1)
  {
    alert("Please enter the preferred date of your booking");
	return false;
  }
  else if(document.form1.pref_time.value.length < 1)
  {
    alert("Please enter the preferred time of your booking");
	return false;
  }
  else if(document.form1.guests.value.length < 1)
  {
    alert("Please enter the approximate number of guests");
	return false;
  }
}

function validateEmployment() 
{        
  if (document.frmSend.fname.value.length < 1)
  {
    alert("Please enter your first name");
	return false;
  }
  else if (document.frmSend.lname.value.length < 1)
  {
    alert("Please enter your last name");
	return false;
  }  
  else if (document.frmSend.phone.value.length < 1)
  {
    alert("Please enter a phone number");
	return false;
  }      
  else if (document.frmSend.foh.value.length < 1 && document.frmSend.boh.value.length < 1 && document.frmSend.manage.value.length < 1)
  {
    alert("Please select at least one position of interest");
	return false;
  } 
  else if (document.frmSend.attach2.value.length > 0)
  {
    var dot = document.frmSend.attach2.value.indexOf(".")
    var ext = document.frmSend.attach2.value.substring(dot+1, document.frmSend.attach2.value.length)

    ext = ext.toLowerCase();	
	
	if (!(ext == "doc" || ext == "pdf" || ext == "txt"))
    {    
      alert("Please attach a file of format .doc, .pdf or .txt");
	  return false;
    }
	else
	{	        
	  if (document.frmSend.attach2.value.length < 1 && document.frmSend.resume.value.length < 1)
	  {
	    alert("Please attach or paste your resume");
		return false; 
	  }	   	  
	}		
  }
  else if (document.frmSend.resume.value.length < 1)
  {
	alert("Please attach or paste your resume");
    return false; 
  }      
  else if (document.frmSend.attach1.value.length > 0)
  {
    var dot = document.frmSend.attach1.value.indexOf(".")
    var ext = document.frmSend.attach1.value.substring(dot+1, document.frmSend.attach1.value.length)

    ext = ext.toLowerCase();	
	
	if (!(ext == "jpg" || ext == "jpeg" || ext == "gif" || ext == "png" || ext == "bmp"))
    {    
      alert("Please attach an image of format .jpg, .jpeg, .gif, .bmp or .png");
	  return false;
    }
	else
	{
	  document.frmSend.Submit.disabled = true;	  
      return true;
	}	
  }   	
  //*** FILE ATTACHMENT NOT REQUIRED ***  
  //var formDOMObj = document.frmSend;
  
  //if (formDOMObj.attach1.value == "")
    //alert("Please press the browse button and pick a file.")
  //else
    //return true;
  
  document.frmSend.Submit.disabled = true;
  return true;
}

function validateSchedule() 
{        
  if (document.frmSend.name.value.length < 1)
  {
    alert("Please enter a schedule name");
	return false;
  }  
  else if (document.frmSend.attach1.value.length < 1)
  {
    alert("Please attach a schedule");
	return false; 
  }	   	  
  else
  {
	document.frmSend.upload.disabled = true;	  
    return true;
  }	  
}