function iBookSubmit(form){

	if(document.getElementById("TB_overlay") !== null)
	{
		return;
	}

	if (typeof document.body.style.maxHeight === "undefined") {//if IE 6
			jQuery("body","html").css({height: "100%", width: "100%"});
			jQuery("html").css("overflow","hidden");
			if (document.getElementById("TB_HideSelect") === null) {//iframe to hide select elements in ie6
				jQuery("body").append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
				jQuery("#TB_overlay").click(tb_remove);
			}
		}else{//all others
			if(document.getElementById("TB_overlay") === null){
				jQuery("body").append("<div id='TB_overlay'></div><div id='TB_window'></div>");
				jQuery("#TB_overlay").click(tb_remove);
			}
		}
		
		if(tb_detectMacXFF()){
			jQuery("#TB_overlay").addClass("TB_overlayMacFFBGHack");//use png overlay so hide flash
		}else{
			jQuery("#TB_overlay").addClass("TB_overlayBG");//use background and opacity
		}

		TB_WIDTH = 900;
		TB_HEIGHT = 600;
		ajaxContentW = TB_WIDTH - 30;
		ajaxContentH = TB_HEIGHT - 45;

		jQuery("#TB_window").append("<div id='TB_title' style='background: #f90;'><div id='TB_ajaxWindowTitle'></div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close' style='color: #ffffff;text-decoration: none'><img src='" + tb_closeImage + "' align='absmiddle' border='0' /></a></div></div><iframe frameborder='0' hspace='0' id='TB_iframeContent' name='TB_iframeContent' onload='tb_showIframe()' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' > </iframe>");

		jQuery("#TB_closeWindowButton").click(tb_remove);

		jQuery("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
		if ( !(jQuery.browser.msie && jQuery.browser.version < 7)) { // take away IE6
			jQuery("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
		}
		jQuery("#TB_window").css({display:"block"});
		//var AVP = document.getElementById("AVP");
		form.target = "TB_iframeContent";
		//AVP.submit();

	//jQuery("#blockMember").html("<br /><span style=\"color: #0000ff;\">Thank you for your subscription.</span><br /><br />");
	return true;
	
}

var maxDuration=30;
function GetFormElementByName(form, name)
{
	for(var i = 0; i < form.length; i ++)
	{
		var em = form.elements[i];
		if(em.name == name)
		{
			return em;
		}
	}

	return null;
}

function validate2(form)
{
	
	var tmp = GetFormElementByName(form, 'StayDateRangeSelector_arrivalDate').value;
	var arr = tmp.split("/");
	var y = arr[2];
	var m = arr[1];
	var d = arr[0];

	GetFormElementByName(form, 'arrivalDate').value = y + '-' + m + '-' + d;
	GetFormElementByName(form, 'nights').value = GetFormElementByName(form, 'StayDateRangeSelector_nights').value;
	form.submit();

}

function SubmitForm(ind)
{
	for(var i = 0; i < document.forms.length; i ++)
	{
		var form = document.forms[i];
		if(form.id == "AVP")
		{
			if(ind <= 0)
			{
				iBookSubmit(form);
				validate2(form);

				return;
			}

			ind --;
		}
	}
}

function SubmitForm2(ind, frameId)
{
	for(var i = 0; i < document.forms.length; i ++)
	{
		var form = document.forms[i];
		if(form.id == "AVP")
		{
			if(ind <= 0)
			{
				form.target = frameId;
				validate2(form);

				return;
			}

			ind --;
		}
	}
}

var start = 0;
var box = null;


jQuery(document).ready(function (){
	
	

	if(box == null)
	{
		box = new MultiBox('AVP_btn_check');
	}
});
