function Querystring(qs) { // optionally pass a querystring to parse
	this.params = {};
	
	if (qs == null) qs = location.search.substring(1, location.search.length);
	if (qs.length == 0) return;

	qs = qs.replace(/\+/g, ' ');
	var args = qs.split('&'); // parse out name/value pairs separated via &
	
	for (var i = 0; i < args.length; i++) {
		var pair = args[i].split('=');
		var name = decodeURIComponent(pair[0]);
		
		var value = (pair.length==2)
			? decodeURIComponent(pair[1])
			: name;
		
		this.params[name] = value;
	}
}

Querystring.prototype.get = function(key, default_) {
	var value = this.params[key];
	return (value != null) ? value : default_;
}

Querystring.prototype.contains = function(key) {
	var value = this.params[key];
	return (value != null);
}

//////////////////////////////
//

function createBooking(w, h, code) {

// Create the iframe on the fly 

	var sub = "www";
	document.write("<iframe width="+w+" height="+h+" frameborder=0 scrolling=auto id=booking> Iframe is not compatible with your system. Please upgrade your browser to the latest version. in the meantime, use our <a href=\"javascript:void(window.open( 'http://"+sub+".letsholidaydirect.com/?c=cal&amp;prop="+code+"', 'cal', 'resizable=no, location=no, menubar=no, scrollbars=no, status=no, toolbar=no, fullscreen=no, dependent=no, width=600, height=500'))\">booking link</a></iframe>");

// Now check the source for the queryString
	var qs = new Querystring();
	var action = qs.get("action","none");
	if ( action == "paymade") {
		// alert("Payment : " + qs.get("payment") + " " + qs.get("ref") );
		document.getElementById("booking").src="http://"+sub+".letsholidaydirect.com/?c=cal&prop="+code+"&action=paymade&payment="+qs.get("payment","failure")+"&ref="+qs.get("ref");
	} else {
		document.getElementById("booking").src="http://"+sub+".letsholidaydirect.com/?c=cal&prop="+code;
	}

}



