/*
Title:			Charm Travel Agency
Author:			D Edwards-Onoro
Created:		25 July 2006
Last Updated:	25 July 2006
*/

window.onload = init;

/* check for DOM */
var W3CDOM = (document.getElementById && document.getElementsByTagName);


/* get all objects */
function getObj(idvalue) {
	return document.getElementById(idvalue);
}


/* get all tags */
function getTag(tag) {
	return document.getElementsByTagName(tag);
}


/* form field style changes when focus and lost focus */
function getFocus(element) {
	for (i=0; i<element.length; i++)  {
		element[i].onfocus = function() {
			this.className += " focus";
		};
		element[i].onblur = function() {
			this.className = this.className.replace(/\bfocus\b/, "");
		}
	}		
}


/* gather form elements for focus change */
function initFormElements() {
	var input = getTag('input');
	var textarea = getTag('textarea');
	
	getFocus(input);
	getFocus(textarea);
}

function doPopups() {
	var links=document.getElementsByTagName("a"); /* get all anchors on the page */
	for (var i=0; i < links.length; i++) {
    	if (links[i].className.match("popup")) { /* find anchors with class of popup */
      		links[i].onclick=function() {
        		window.open(this.href, "","top=40,left=40,status=1,location=1,resizable=1,scrollbars=1,width=520,height=500");
        		return false;
      		}
    	} /* end if */
	} /* end for */
}

function init() {
	if (!W3CDOM) return;
    initFormElements();
	doPopups();
	
}