document.write("<iframe name='callmeFormFrame' id='callmeFormFrame' width='1' height='1' style='display:none'></iframe>");

var callmeFormActive = null;

function callmeForm_hide(id){
	var a = document.getElementById("amf2"+id);
	var b = document.getElementById("amf3"+id);

	a.style.display		= "none";
	a.style.visibility	= "hidden";
	a.style.zIndex		= "1";

	b.style.display		= "none";
	b.style.visibility	= "hidden";
	b.style.zIndex		= "2";
	callmeFormActive	= null;
	return false;
}

function callmeForm(type,subject,link){
	
	if(subject == null){
		subject = "General Enquiry";
		type	= "enquiry";
		link	= "E-mail enquiry";
	}
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = 5;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	document.write("<div id='amf"+randomstring+"' style='z-index:1; width: 130px; text-align: center;'><a href='javascript:void(0)' title='Call Me' onclick=\"callmeFormC('"+randomstring+"','"+subject+"','"+type+"')\" style='text-decoration:none;color:#0000cc;background:#ffffff'><img src='/call_me/callmegreen.png' width='128' height='79' style='border:0;padding:0;' alt='Call Me' /></a></div>");


}
function callmeFormC(id,subject,type){
	obj				=	document.getElementById("amf"+id);
	obj.style.position		=	"relative";
	
	//Close Active?
	if(callmeFormActive != null){
		callmeForm_hide(callmeFormActive);
	}

	//Set active ID
	callmeFormActive		= id;

	if(!document.getElementById("amf2"+id)){
		var a				=	document.createElement("div");	
		a.id				=	"amf2"+id;
		a.style.width			=	"210px";
		a.style.height			=	"240px";
		a.style.position		=	"absolute";
		a.style.top			=	"-210px";
		a.style.left			=	"100px";
		a.style.fontSize		=	"11px";
		a.style.fontFamily		=	"Arial,Verdana,sans-serif";
		a.style.color			=	"#ffffff";
		a.style.backgroundColor		=	"#888888";
		a.style.padding			=	"5px";
		a.style.filter			=	"alpha(opacity=50)";
		a.style.Mozopacity		=	"0.5";
		a.style.opacity			=	"0.5";
		a.style.zIndex			=	"98";

		var b				=	document.createElement("div");
		b.id				=	"amf3"+id;
		b.style.color			=	"#000000";
		b.style.backgroundColor		=	"#ffffff";
		b.style.width			=	"210px";
		b.style.height			=	"240px";
		b.style.padding			=	"5px";
		b.style.border			=	"1px solid #666666";
		b.style.position		=	"absolute";
		b.style.top			=	"-215px";
		b.style.left			=	"95px";
		b.style.zIndex			=	"99";
		
		
	} else {
		var a				= document.getElementById("amf2"+id);
		var b				= document.getElementById("amf3"+id);
			a.style.display		= "block";
			a.style.visibility	= "visible";
			a.style.zIndex		= "98";
			b.style.display		= "block";
			b.style.visibility	= "visible";
			b.style.zIndex		= "99";
	}

	b.innerHTML	=	""
				+	"<form method='post' target='callmeFormFrame' action='/call_me/index.php' style='margin:0px;padding:0px'>"
				+	"<input type='hidden' name='amf_id' value='"+id+"' />"
				+	"<input type='hidden' name='amf_url' value='"+location.href+"' />"
				+	"<input type='hidden' name='amf_subj' value='"+subject+"' />"
				+	"<input type='hidden' name='amf_type' value='"+type+"' />"
				+	"<div style='font-weight:bold;color:#ffffff;background-color:#000000;padding:5px'>"
				+	"<button style='border:1px solid #aa0000;color:#ffffff;background-color:#cc0000;float:right;position:relative;cursor:pointer;top:-4px;right:-4px;padding:0px 3px 0px 3px' onclick=\"callmeForm_hide('"+id+"')\">x</button>"
				+	"Callback Request</div>"
				+	"<div style='padding:5px'>"
				+	"<label>Your Name:</label><br />"
				+	"<input type='text' name='amfn"+id+"' id='amfn"+id+"' style='width:184px' /><br />"
				+	"<label>Telephone:</label><br />"
				+	"<input type='text' name='amfe"+id+"' id='amfe"+id+"' style='width:184px' /><br />"
				+	"<label>Comments:</label><br />"
				+	"<textarea style='font-family:Arial,Verdana,sans-serif;font-size:11px' name='amft"+id+"' id='amft"+id+"' cols='30' rows='4' style='width:184px'></textarea><br />"
				+	"<input type='submit' name='amfsubmit' value='Request Callback' />"
				+	"</div>"
				+	"</form>"
	;
	obj.appendChild(a);
	obj.appendChild(b);
}