var Suppliers=null;var sArray=new Array();var popupTest=false;var popEnabled=false;var oSearch;var ndx=1;var topX=0;var topY=0;var SupImgArr=new Array();var TopClicked=false;CompareSearch.prototype.InitializeTestPopup=function(){if(popupTest){return}try{strOptions="height="+top.screen.availHeight+",width="+top.screen.availWidth+",left=0,top=0,toolbar,menubar,scrollbars,resizable,location";var a=window.open("about:blank","testPup",strOptions);a.close();popupTest=true;popEnabled=true;if(!oSearchP.EnebleAjax){$("#btnCompareTop").show()}}catch(b){}};CompareSearch.prototype.Supplier=function(a,e,b,d,f){this.Id=a;this.Name=e;this.Img=b;this.IsSpotlight=d;this.win="";this.Query="?SupID="+this.Id+"&ClickID="+$("#hdClickID").val();this.addText=f};CompareSearch.prototype.Render=function(){var e;for(e=0;e<3;++e){$("div#compareBody #p"+e.toString()+" p").html("").unbind("click");$("div#compareBody div#btn"+e.toString()+" a").attr("href","").hide()}var a=$("#hdClickID").val();for(e=0;e<sArray.length;++e){$("div#compareBody #p"+e.toString()+" p").html('<a id="'+sArray[e].Id+'" alt="Show Price" href="javascript:oSearch.View(\''+sArray[e].Name+"')\"></a>").click(function(){var g=$(this).find("a").attr("id");var f=oSearchP.SearchURL+"?SupID="+g+"&ClickID="+a;window.open(f);return false});$("div#compareBody #p"+e.toString()+" p a").html(sArray[e].Img);$("div#compareBody div#btn"+e.toString()+" a").attr("href","javascript:oSearch.remove('"+sArray[e].Id+"',this)").show()}if(e<=1){$("#btnCompareAll").hide()}else{$("#btnCompareAll").show()}if(e<1&&popEnabled&&!TopClicked){$("#btnCompareTop").show()}else{$("#btnCompareTop").hide()}for(;e<3;++e){$("div#compareBody #p"+e.toString()+" p").html((e+1).toString()+": Pick a Site")}var d;switch(3-sArray.length){case 3:d=this.text1;break;case 2:d=this.text2;break;case 1:d=this.text3;break}var b=document.getElementById("stepTitle");if(sArray.length<3){$(b).html(d)}else{$(b).html(this.text4)}};CompareSearch.prototype.popBlankWin=function(d){if(sArray[d].win&&!sArray[d].win.closed){return}var g="win_"+ndx++;var h=100;var e=100;var f=0;var b=oSearchP.BaseURL+"Searching.html";strOptions="toolbar,menubar,scrollbars,resizable,location,screenX="+f+",screenY=0,left="+f+",top=0,height="+e+",width="+h;var a=window.open(b+"?s="+sArray[d].Id,g,strOptions);sArray[d].win=a;a.blur();window.focus()};CompareSearch.prototype.getArrayIndex=function(a){for(var b=0;b<sArray.length;++b){if(sArray[b].Id==a){return b}}return -1};CompareSearch.prototype.add=function(b){if(sArray.length<3){sArray.push(b);var a=sArray.length-1;if(!popEnabled){if(sArray[a].IsSpotlight==0){oSearch.popBlankWin(a);sArray[a].IsSpotlight=1}}this.Render();return true}else{return false}};CompareSearch.prototype.remove=function(b,a){var f=this.getArrayIndex(b);if(f==-1){return}$("ul#uxSupList li a#"+b).click(SupClickHandle).removeClass("selected").fadeTo("fast",1).attr("href","javascript:AddCompare('"+sArray[f].Name+"');");$("ul#uxSupList li a#"+b).parent().find("div.addText").html(sArray[f].addText).find("a").click(function(){$(this).parent().parent().find("a.imgSup").trigger("click")});if(sArray[f].win){try{if(!document.all){sArray[f].win.onunload=null;sArray[f].win.onbeforeunload=null}else{sArray[f].win.document.body.onunload=null;sArray[f].win.document.body.onbeforeunload=null}sArray[f].win.close()}catch(d){}}sArray.splice(f,1);this.Render()};CompareSearch.prototype.ClearAllSelected=function(){topX=0;topY=0;sArray=new Array();this.Render()};CompareSearch.prototype.CompareAll=function(){if(!popEnabled){this.compareAllBlank()}else{for(n=sArray.length-1;n>-1;n--){this.popStacked(n)}topX=0;topY=0}this.ClearAllSelected()};CompareSearch.prototype.CompareTop=function(){$("ul#uxSupList li a.imgSup:lt(3)").each(function(){$(this).trigger("click")});oSearch.CompareAll();TopClicked=true;this.ClearAllSelected()};CompareSearch.prototype.popStacked=function(f){strOptions="toolbar,menubar,scrollbars,resizable,location,height="+200+",width="+200+",left="+topX+",top="+topY+",screenX="+topX+",screenY="+topY;var b=oSearchP.SearchURL+sArray[f].Query;var a=window.open(b,"win_"+f,strOptions);var e=top.screen.availWidth*0.8;var d=top.screen.availHeight*0.7;a.resizeTo(e,d);a.focus;topX+=top.screen.availWidth*0.1;topY+=top.screen.availHeight*0.15};CompareSearch.prototype.compareAllBlank=function(){var d=((top.screen.availWidth)*0.8);var a=(top.screen.availHeight*0.7);for(i=sArray.length-1;i>-1;i--){if(sArray[i].win){try{if(!document.all){sArray[i].win.onunload=null;sArray[i].win.onbeforeunload=null}else{sArray[i].win.document.body.onunload=null;sArray[i].win.document.body.onbeforeunload=null}sArray[i].win.location.href=oSearchP.SearchURL+sArray[i].Query;sArray[i].win.moveTo(topX,topY);sArray[i].win.resizeTo(d,a);sArray[i].win.focus();topX+=top.screen.availWidth*0.1;topY+=top.screen.availHeight*0.15}catch(b){}}}};function CompareSearch(e,d,b,a){this.text1=e;this.text2=d;this.text3=b;this.text4=a}function SupClickHandle(){$(this).unbind("click");var e=$("ul#uxSupList li").index($(this).parent());$(this).fadeTo("fast",0.2);var g=$(this).attr("id");var d=$(this).find("img").attr("alt");var b=new Image();b.src=$(this).find("img").attr("src");b.alt="Go to "+d;$(b).addClass("sup");var a=$(this).parent().find("div.addText").html();var f=new oSearch.Supplier(g,d,b,0,a);if(oSearch.add(f)){$(this).addClass("selected").attr("href","javascript:void(0);");$(this).parent().find("div.addText").html(d)}else{$(this).fadeTo("fast",1).click(SupClickHandle)}return false}$(window).unload(function(){for(i=0;i<sArray.length;i++){if(sArray[i].win){try{if(!document.all){sArray[i].win.onunload=null;sArray[i].win.onbeforeunload=null}else{sArray[i].win.document.body.onunload=null;sArray[i].win.document.body.onbeforeunload=null}sArray[i].win.close()}catch(a){}}}});$(document).ready(function(){var a=new Date();a.setDate(a.getDate()+1);$("#dFrom").datepicker({minDate:a,onSelect:fnDateSelected,hideIfNoPrevNext:true,duration:"fast"});$("#dTo").datepicker({minDate:a,hideIfNoPrevNext:true,duration:"fast"});if(oSearchP.EnebleAjax){oSearch=new CompareSearch(oSearchP.Text1,oSearchP.Text2,oSearchP.Text3,oSearchP.Text4);oSearch.InitializeTestPopup();$("#supList li").click(SupClickHandle);var b=$("<img>").attr("src","/images/indicator.gif").attr("alt","Loading....").attr("class","imgWait");$("#btnSearch").click(function(){if(!validateDate($("#dFrom").get(0))){return false}if(!validateDate($("#dTo").get(0))){return false}if(!DataCompare($("#dFrom").val(),$("#dTo").val())){alert("Check-In date must less than Check-Out date.");return false}var d=$("#frmSearch").serialize();$("#chooseS1 div.contentL").show();$("ul#uxSupList").html(b);SupImgArr=[];$.ajax({type:"GET",contentType:"text/json; charset=utf-8",url:oSearchP.BaseURL+"SearhSupplierForHotel.ashx",data:d,dataType:"json",success:function(g){oSearch.ClearAllSelected();Suppliers=g;$("ul#uxSupList").html("");if(g.Error){alert(g.Error)}else{if(!(g.ClickID)){$("ul#uxSupList").html(oSearchP.NotFoundSupplier)}else{$("#optionsTable p.title").show();var h="";$("#hdClickID").val(g.ClickID);for(c in g.Datas){var f=g.Datas[c];var e=new Image();e.src=oSearchP.imageUrlL+f.Img.replace(/100x30/i,"200x60");e.alt=f.Name;$(e).addClass("sup");SupImgArr.push(e);h+="<li>";h+='<a id="'+f.ID+'" href="javascript:AddCompare(\''+f.Name+'\');" class="imgSup"></a>';h+='<div class="addText"><a href="javascript:AddCompare(\''+f.Name+"');\">"+f.Name+"</a></div></li>"}$("ul#uxSupList").html(h);$("ul#uxSupList li a.imgSup").each(function(j){$(this).html(SupImgArr[j])});BindClickSup();$("#chooseS1 div.contentR").show()}}},error:function(g,e,f){}});return false})}else{$("#btnSearch").click(function(){if(!validateDate($("#dFrom").get(0))){return false}if(!validateDate($("#dTo").get(0))){return false}if(!DataCompare($("#dFrom").val(),$("#dTo").val())){alert("Check-In date must less than Check-Out date.");return false}$("#frmSearch").append('<input name="Search" type="hidden" value="1" />');$("#frmSearch").trigger("submit")});if($("#uxSupList li").length>0){oSearch=new CompareSearch(oSearchP.Text1,oSearchP.Text2,oSearchP.Text3,oSearchP.Text4);oSearch.InitializeTestPopup();BindClickSup()}}});function AddCompare(a){}function BindClickSup(){$("ul#uxSupList li a.imgSup").click(SupClickHandle);$("ul#uxSupList li div.addText a").click(function(){$(this).parent().parent().find("a.imgSup").trigger("click")})}function SayHi(){alert("Hi")};