function AddClickTaleTag(Tag)
{   
   if (window.ClickTaleTag){

   ClickTaleTag(Tag);
  }

}
// a really awful function for sending them to the destination page when they select something
function hijack_search(f, u) {
	d = f[f.selectedIndex].value;
	if((d != "") && (d != "london")) {
		document.location = "http://" + d + u;
	}
	return false;
}

// resets a form X, default of 0
function reset(x) {
	if(isNaN(x)) {
		x = 0;
	}
	document.forms[x].reset();
}

// submits a form X, default of 0
function submit(x) {
	if(isNaN(x)) {
		x = 0;
	}
	document.forms[x].submit();
}

// a basic function to open a basic window with user specified url, width and heights.
function popup(url, width, height) {
	featurestr = "directories=0,height=" + height + ",location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0,width=" + width;
	open(url, "_blank", featurestr);
}

// pops up a window for selecting a date
function get_date(month, year, form_no, fields) {
	month = month[month.selectedIndex].value;
	year = year[year.selectedIndex].value;
	url = "get_date.php?month=" + month + "&year=" + year + "&form=" + form_no + "&fields=" + escape(fields);
	popup(url, 250, 200);
}

// this function toggles the visibility of a DIV "id" to "toggle"
function div_toggle(id, toggle) {
	if(document.getElementById) {
		document.getElementById(id).style.visibility = toggle ? "visible" : "hidden";
	}
}

function div_toggle_flip(id) {
alert(document.getElementById("link_1").innerhtml);
	if(document.getElementById) {
		if(document.getElementById(id).style.visibility == "visible"){
document.getElementById(id).style.visibility = "hidden";
}else{
		document.getElementById(id).style.visibility = "visible";
		}
	}
}

// this one is a function that makes sure that a field (this) is an integer.
function make_int(field) {
	if(isNaN(field.value) || (field.value == "") || (field.value < 0)) {
		field.value = "0";
	}
	else {
		field.value = Math.round(field.value);
	}
}

// makes sure a given number is a tidy currency formatted string
function money(num) {
	if(isNaN(num)) {
		num = "0.00";
	}
	else {
		num = Math.round(num * 100) / 100;
		num = num.toString();
		dot = num.indexOf(".");
		if(dot < 0) {
			num += ".00";
		}
		else if((num.length - dot) == 2) {
			num += "0";
		}
	}
	return num;
}

// uses the above function and applies it to a form field
function make_money(field) {
	field.value = money(field.value);
}

// a fairly basic e-mail validating function that isn't as extensive as the old one, but cleaner.
function is_email(email) {
	var email_re = "^[^@]+@[^@]+[\.][^@]+$";
	return email.match(email_re) ? true : false;
}

// clears a text field if it's currently displaying its default value
function cleardefault(f) {
	if(f.value == f.defaultValue) {
		f.value = "";
	}
}

// changes the style of a given thingy
function changeclass(thingy, classname) {
	thingy.className = classname;
}

//Set a cookie using Javascript
function setCookie(c_name,value,expiredays)
{
    var exdate=new Date();
    exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+ 
    ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}


