function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function explode (delimiter, string, limit) {
			var emptyArray = { 0: '' };
			if ( arguments.length < 2 ||
				typeof arguments[0] == 'undefined' ||
				typeof arguments[1] == 'undefined' ) {
				return null;
			}
		 
			if ( delimiter === '' ||
				delimiter === false ||
				delimiter === null ) {
				return false;
			}
		 
			if ( typeof delimiter == 'function' ||
				typeof delimiter == 'object' ||
				typeof string == 'function' ||
				typeof string == 'object' ) {
				return emptyArray;
			}
		 
			if ( delimiter === true ) {
				delimiter = '1';
			}
			
			if (!limit) {
				return string.toString().split(delimiter.toString());
			} else {
				var splitted = string.toString().split(delimiter.toString());
				var partA = splitted.splice(0, limit - 1);
				var partB = splitted.join(delimiter.toString());
				partA.push(partB);
				return partA;
			}
		}

		function available(frmObj){
			var form = document.getElementById(frmObj);
			form.setAttribute("method", "post");
			form.setAttribute("action", "https://secure.widediscovery.com/v2.1/wdsystem.php");

			var HotelhiddenField = document.createElement("input"); 
			HotelhiddenField.setAttribute("type", "hidden");
			HotelhiddenField.setAttribute("id", "hotel");
			HotelhiddenField.setAttribute("name", "hotel");
			HotelhiddenField.setAttribute("value", "00041");
			form.appendChild(HotelhiddenField);

			var HotelhiddenField = document.createElement("input"); 
			HotelhiddenField.setAttribute("type", "hidden");
			HotelhiddenField.setAttribute("id", "relateoldversion");
			HotelhiddenField.setAttribute("name", "relateoldversion");
			HotelhiddenField.setAttribute("value", "Y");
			form.appendChild(HotelhiddenField);

			var HotelhiddenField = document.createElement("input"); 
			HotelhiddenField.setAttribute("type", "hidden");
			HotelhiddenField.setAttribute("id", "textrandom");
			HotelhiddenField.setAttribute("name", "textrandom");
			HotelhiddenField.setAttribute("value", "");
			form.appendChild(HotelhiddenField);

			var startDate = explode("/", $('#indate').val());
			var endDate = explode("/", $('#outdate').val());

			var HotelhiddenField = document.createElement("input"); 
			HotelhiddenField.setAttribute("type", "hidden");
			HotelhiddenField.setAttribute("id", "arrival1");
			HotelhiddenField.setAttribute("name", "arrival1");
			HotelhiddenField.setAttribute("value", startDate[1]);
			form.appendChild(HotelhiddenField);

			var HotelhiddenField = document.createElement("input"); 
			HotelhiddenField.setAttribute("type", "hidden");
			HotelhiddenField.setAttribute("id", "arrival2");
			HotelhiddenField.setAttribute("name", "arrival2");
			HotelhiddenField.setAttribute("value", startDate[0]);
			form.appendChild(HotelhiddenField);

			var HotelhiddenField = document.createElement("input"); 
			HotelhiddenField.setAttribute("type", "hidden");
			HotelhiddenField.setAttribute("id", "arrival3");
			HotelhiddenField.setAttribute("name", "arrival3");
			HotelhiddenField.setAttribute("value", startDate[2]);
			form.appendChild(HotelhiddenField);

			var HotelhiddenField = document.createElement("input"); 
			HotelhiddenField.setAttribute("type", "hidden");
			HotelhiddenField.setAttribute("id", "depart1");
			HotelhiddenField.setAttribute("name", "depart1");
			HotelhiddenField.setAttribute("value", endDate[1]);
			form.appendChild(HotelhiddenField);

			var HotelhiddenField = document.createElement("input"); 
			HotelhiddenField.setAttribute("type", "hidden");
			HotelhiddenField.setAttribute("id", "depart2");
			HotelhiddenField.setAttribute("name", "depart2");
			HotelhiddenField.setAttribute("value", endDate[0]);
			form.appendChild(HotelhiddenField);

			var HotelhiddenField = document.createElement("input"); 
			HotelhiddenField.setAttribute("type", "hidden");
			HotelhiddenField.setAttribute("id", "depart3");
			HotelhiddenField.setAttribute("name", "depart3");
			HotelhiddenField.setAttribute("value", endDate[2]);
			form.appendChild(HotelhiddenField);

			var HotelhiddenField = document.createElement("input"); 
			HotelhiddenField.setAttribute("type", "hidden");
			HotelhiddenField.setAttribute("id", "chknoofroom");
			HotelhiddenField.setAttribute("name", "chknoofroom");
			HotelhiddenField.setAttribute("value", $('#chknoofroom :selected').val());
			form.appendChild(HotelhiddenField);
			
			form.submit();
		}
