/**
  DigitalImogen-specific code
  ====================

*/
//$Log$


function commocouInit()
{
  //any initialisation ...
  writeLog("Live : " + gLive);
  writeLog("IP Address : " + gRemoteAddr); 
}

function contactForm()
{
  
  //make a new layer for the contact form
  //=====================================
  
  if (Layers["commocou_contact_us"] != null)
  {
	if (Layers["commocou_contact_us"].state == 'minimised')
	{
	  moveObjectTo("commocou_contact_us", 220, 40);
	  var shadow = Layers["commocou_contact_us"].shadowLayer;
	  if (shadow != null)
	  {
			  //syncXYCoords(shadow.id, dragObj.id, 0, 0);
			  moveObjectTo(shadow.id, 220 + shadowWidth, 40 + shadowWidth);
	  }
	  Layers["commocou_contact_us"].minimise_foo();
	}
	return;
  }
  
  new layer("commocou_contact_us", document.body.id,
			"Contact Digital Imogen",
			500, 460,
			220, 40,
			"center", "middle",
			"",
			"",
			"fefeff",
			"555555",
			"f9f9ff",
			"images/logos/commocougen_g_20.gif",
			"images/icons/greyscale_minimise.gif",
			"",
			"images/icons/greyscale_multiply.gif",
			null,
			true);
  
  //Form goes here ...
  var clientArea  = findObj("commocou_contact_us_client");
  
  var formDiv = document.createElement("div");
  formDiv.style.width = "96%";
  clientArea.appendChild(formDiv);
  
  var formLabelsDiv = document.createElement("div");
  formLabelsDiv.style.cssFloat = "left";
  formLabelsDiv.style.textAlign = "right";
  formLabelsDiv.style.lineHeight = "1.7em";
  formLabelsDiv.style.width = "30%";
  formLabelsDiv.innerHTML = "Name :<br>Phone :<br>Organisation :<br>Email :";
  formDiv.appendChild(formLabelsDiv);
  
  var formControlsDiv = document.createElement("div");
  formControlsDiv.style.width = "66%";
  formControlsDiv.style.cssFloat = "right";
  formControlsDiv.style.textAlign = "left";
  formControlsDiv.innerHTML = "<input type='text' id='commocou_contact_us_name'>"
							+ "<br><input type='text' id='commocou_contact_us_phone'>"
							+ "<br><input type='text' id='commocou_contact_us_organisation'>"
							+ "<br><input type='text' id='commocou_contact_us_email'>"
							;
  formDiv.appendChild(formControlsDiv);
  formDiv.style.clear = "both";
  clientArea.appendChild(formDiv);
  
  var commentDivContainer = document.createElement("div");
  commentDivContainer.style.clear = "both";
  var commentDivButtons = document.createElement("div");
  commentDivButtons.style.cssFloat = "left";
  commentDivButtons.innerHTML = "<br><button id=\"commocou_contact_us_submit\">"
							+ "send"
							+ "</button>"
							+ "<br><button id=\"commocou_contact_us_clear\">"
							+ "clear"
							+ "</button>";
  
  var commentDivMessage = document.createElement("div");
  commentDivMessage.innerHTML = "Message<textarea id=\"commocou_contact_us_message\""
							+ "cols=\"52\" rows=\"16\" "
							+ "style=\"background-image : url(images/9780_paper_plane_400.jpg);\""
							+ ">"
							+ "</textarea>";
  
  commentDivContainer.appendChild(commentDivButtons);
  commentDivContainer.appendChild(commentDivMessage);
  clientArea.appendChild(commentDivContainer);
  
  var clearAll = function() {
		setObjValue('commocou_contact_us_name', '');
		setObjValue('commocou_contact_us_phone', '');
		setObjValue('commocou_contact_us_organisation', '');
		setObjValue('commocou_contact_us_email', '');
		setObjValue('commocou_contact_us_message', '');
	}
	
  if (dom_event_handler)
  {
	  findObj('commocou_contact_us_clear').addEventListener('click', clearAll, true);
  }
  else if (ie_event_handler)
  {
	  findObj('commocou_contact_us_clear').attachEvent('onclick', clearAll);
  }

var sendMessage = function() {
		
		//to be written - needs to use ajax
		writeLog("Sending message ...");
		
	}
	
  if (dom_event_handler)
  {
	  findObj('commocou_contact_us_submit').addEventListener('click', sendMessage, true);
  }
  else if (ie_event_handler)
  {
	  findObj('commocou_contact_us_submit').attachEvent('onclick', sendMessage);
  }

}
