function getElementsByClass(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp('(^|\\\\s)'+searchClass+'(\\\\s|$)');
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

function getItem(name)
{
	return document.getElementById(name).innerHTML / 1.0;
}


function setItem(name,value)
{
	document.getElementById(name).innerHTML = Number(value).toFixed(2);
}


function updateTotal(sel)
{
	var mul = 0.02;
	if(sel.value == 'American Express')
		mul = 0.025;

	var subtotal = getItem('joining_fee') + getItem('initial_deposit') + getItem('vat');
	var cc_surcharge = subtotal * mul;
	var total_charge = subtotal + cc_surcharge;
	setItem('cc_surcharge', cc_surcharge);
	setItem('total_charge', total_charge);
}


function calcFee(frm)
{
	var fee = 2000;
	switch(frm['member[duration]'].value)
	{
		case '1' : fee = 1000;
			break;
		case '2' : fee = 1500;
			break;
		case '3' : fee = 2500;
			break;
	}
	frm['member[fee]'].value = fee;
}


function openWin(myUrl,myName,myParams)
{
	if (!myUrl) window.alert('Error: cannot open window: no page specified');
	if (!myName) myName = 'vuPopup';
	if (!myParams) myParams = 'top=50,left=50,height=340,width=550,toolbar=no,scrollbars=yes,status=yes,resizable=yes';
	myPopup = window.open(myUrl,myName,myParams);
	myPopup.focus();
}


function inputFocus(obj) {
	obj.style.background = "#fff";
}


function inputBlur(obj,style) {
	if (obj.value == "") {
		obj.style.background = style;
	}
}




function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {createCookie(name,"",-1);}

function dropDown(did) {
	if ($(did).css('height') == '65px') {
		$(did).animate({height: "100%"}, 200 );
		$(did+'-txt').html('LESS INFO');
	} else {
		$(did).animate({height: "65px"}, 200 );
		$(did+'-txt').html('MORE INFO');
	}
}
