// JavaScript Document

// EDIT THESE VALUES IF REQUIRED
var alertText = 'Are you sure you wish to perform this action' + "\n"; //DEFAULT TEXT DISPLAYED ON CONFIRM BUTTONS/LINKS WHEN NO ALT/TITLE
var newWindowLink = false; //OPEN EXTERNAL LINKS BY DEFAULT IN A NEW WINDOW (TRUE/FALSE)?


function updatePreview() {
	
	var theForm = document.getElementById('recommendForm');
	var prevArea = document.getElementById('preview');
	
	prevArea.style.display='block';
	
	if (theForm.y_name.value && theForm.f_name.value && theForm.f_email.value) {
	
		var html = '<p>To: <strong>' + theForm.f_email.value + '</strong><br />From: <strong>' + theForm.y_name.value + '</strong></p>';
		
		html += '<p><strong>' + theForm.f_name.value + '</strong>, </p>';
		html += '<p>I recommend you visit www.petfireworkfear.co.uk to find out how to look after your pets during fireworks.</p>';
		
		if (theForm.message.value) {
			html += '<p><strong>' + theForm.message.value + '</strong></p>';
		}
		
		html += '<p><strong>' + theForm.y_name.value + '</strong></p>';
	
	} else {
		
		var html = '<p>Complete the fields to see a preview here...</p>';
		
	}
	
	prevArea.innerHTML = html;
	
}

function searchInput(elmt) {
	
	if (elmt.value == '') {
		elmt.style.color = '#999';
		elmt.value = 'keyword search';
	} else if (elmt.value == 'keyword search') {
		elmt.style.color = '#000';
		elmt.value = '';
	}
	
}


var woms = new Array(); //CREATE ARRAY OF FUNCTIONS TO LAUNCH ONLOAD

//ONLOAD MANAGER
function womOn(){
  window.onload = womGo;
}

function womGo(){
  document.getElementById('searchinput').style.color = '#999';
  for(var i = 0;i < woms.length;i++)
    eval(woms[i]);
}

function womAdd(func){
  woms[woms.length] = func;
}

function CreateBookmarkLink() {

	title = document.title;
	url = window.location.href;
	
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,"");
	} else if(window.external) {
		window.external.AddFavorite( url, title); 
	} else if(window.opera && window.print) {
		return true;
	}
	
}

function objToggle(obj) { 

	var obj = document.getElementById(obj);

	if(obj.style.display == "block") { 
		obj.style.display = "none";
	} else { 
		obj.style.display = "block";
	}

}