if(typeof (IXIGO)=="undefined"){IXIGO={}}IXIGO.HotelPartnerProfile=function(){var A=this;this.manageProps;
this.keeptabs;this.clean=false;this.tabs=["login","properties"];this.init=function(){this.manageProps=new IXIGO.OfflineProperties();
this.manageProps.init();$.each(this.tabs,function(B,C){$("#"+C).click(function(D){A.tabClick(this,D)})
});this.keeptabs="properties";if(window.location.hash!==""){this.keeptabs=window.location.hash.substring(1);
$("html, body").attr("scrollTop",0)}this.switchTo($("#form\\:whichpage").val()||this.keeptabs)};this.tabClick=function(E,B){var C="";
var D=B.target;while(D!=E&&!D.getAttribute("action")){D=D.parentNode}if(!this.clean){$.each(this.tabs,function(F,G){A.revert("#"+G)
});this.clean=true}this.revert("#"+this.keeptabs);this.keeptabs=D.id;this.switchTo(this.keeptabs);this.removeMessages()
};this.removeMessages=function(){$("div#infoContent .error").hide()};this.revert=function(B){$(B).attr("class","");
$(B+"_form").hide()};this.switchTo=function(C){var B="#"+C;$(B).attr("class","link");$(B+"_form").show();
$("#form\\:whichpage").val(C)}};IXIGO.OfflineHotel=function(){var A=null;this.pictureComponent=new IXIGO.PictureComponent();
this.amenitiesJson=null;this.amenitiesMap={"1":"internetAccess","2":"parking","3":"swimmingPool","4":"barOrLounge","5":"spa","6":"fitnessRoom"};
this.init=function(){if(!document.forms.offlineHotelForm){return }A=this;this.pictureComponent.init();
$("#registerButton").mouseover(function(B){IXIGO.Utils.onHoverButton("#registerButton","b-","-bg-2")}).mouseout(function(B){IXIGO.Utils.onHoverButton("#registerButton","b-","-bg-2")
});$("#cancelButton").click(function(){window.location.href="/secure/hotel/myixigo.ixi#properties"}).mouseover(function(B){IXIGO.Utils.onHoverButton("#cancelButton","b-","-bg-2")
}).mouseout(function(B){IXIGO.Utils.onHoverButton("#cancelButton","b-","-bg-2")});$("#offlineHotelForm\\:registerOfflineHotel").click(function(){A.fill()
});$("#offlineHotelForm\\:htl_where").keypress(function(B){return B.keyCode!=13});$("input:radio","#partnerAuthBox").click(function(){$("#agreeBox").css("display",(this.value==1?"block":"none"))
});$("#offlineHotelForm\\:htl_where").autocomplete({source:function(C,B){IXIGO.Ajax.getJson("/secure/action/content/city?searchFor=hotelCity&value="+C.term,function(E){var D=[];
jQuery.each(E.r,function(F,G){D[D.length]={label:G.c,value:G.c}});B(D)})},secure:true,minLength:3,minWidth:227,cache:null});
$("#offlineHotelForm\\:referrer").val(document.referrer);$('input:radio[value="'+$("#offlineHotelForm\\:registerOrLogin").val()+'"]',"#partnerAuthBox").trigger("click");
$.each($("#offlineHotelForm\\:hotelAmenities").val(),function(C,B){if(C<6){$("#offlineHotelForm\\:"+A.amenitiesMap[C+1])[0].checked=(B==1)
}else{return false}});$.getJSON("/secure/action/content/hotel?searchFor=amenities",function(B){A.amenitiesJson=B
})};this.fill=function(){$("#offlineHotelForm").attr({"enctype":"application/x-www-form-urlencoded","encoding":"application/x-www-form-urlencoded","target":"_self","action":"/secure/hotel/registerOfflineHotels.ixi"});
var B=this.pictureComponent.getUploads();$("#offlineHotelForm\\:pictures").val(B[0]);$("#offlineHotelForm\\:pictureNames").val(B[1]);
$("#offlineHotelForm\\:registerOrLogin").val($("input:radio[checked]","#partnerAuthBox").val());var C=[];
$.each(this.amenitiesJson,function(E,D){if(A.amenitiesMap[E]){C[C.length]=($("#offlineHotelForm\\:"+A.amenitiesMap[E])[0].checked?1:0)
}else{C[C.length]=0}});$("#offlineHotelForm\\:hotelAmenities").val(C.join(""))};this.dopictureupload=function(B){this.pictureComponent.upload(B)
};this.onpictureupload=function(B){this.pictureComponent.callback(B)};this.onpictureunselect=function(C,B){this.pictureComponent.onunselect(C,B)
}};IXIGO.PictureComponent=function(){var A=this,B=",";A.count=0;A.sid=0;A.uploads={};A.uploadmutex=true;
A.init=function(){$("#picAttachOne, #picAttachAnother").click(function(){A.addInputComponent()});A.readPastUploads()
};A.readPastUploads=function(){var E=$("#offlineHotelForm\\:pictures").val(),D=$("#offlineHotelForm\\:pictureNames").val(),C;
if(E&&D){C=[E.split(B),D.split(B)];$.each(C[0],function(H,F){var I=A.rnd(),G={"name":F,"filename":C[1][H],"modifiedFileName":F};
A.addFileUploaded(I,G);A.count=A.count+1});A.afterDisplay()}};A.createNewInputFile=function(D){var C=document.createElement("input");
C.setAttribute("id","input_"+D);C.setAttribute("name","input_"+D);C.setAttribute("type","file");C.setAttribute("size","28");
C.setAttribute("readonly","true");C.setAttribute("style","float: left; margin-top: 0px;");return C};A.addInputComponent=function(){var D=A.rnd();
var C=""+'<div id="remove_'+D+'" class="link lfloat no-deco" style="font-size:80%; padding: 5px;">remove</div>'+'<div id="progress_'+D+'" class="hide lfloat" style="padding: 5px 0;"><img src="'+IXIGO.Utils.getStaticPath()+'/img/progress-bg.gif" /></div>'+'<div class="clear" />'+'<div id="error_'+D+'" class="hide" style="margin:0px 1px 0px 15px;width:350px;"></div>';
$('<div id="'+D+'" />').append($(A.createNewInputFile(D))).append(C).appendTo("#picContainer");$("#input_"+D).change(function(E){A.upload(D)
});$("#remove_"+D).click(function(E){A.removeInputComponent(D)});A.count=A.count+1;A.afterDisplay()};
A.removeInputComponent=function(C){$("#"+C+", #frame_"+C).remove();A.count=A.count-1;A.afterDisplay()
};A.afterDisplay=function(){if(A.count>0){$("#picAttachOne").hide();$("#picAttachAnother").css("display",(A.count<5)?"inline":"none")
}else{A.count=0;$("#picAttachOne").show();$("#picAttachAnother").hide()}};A.upload=function(C){if(A.uploadmutex){A.uploadmutex=false;
A.sid=C;$("#error_"+C).hide();if(!$("#frame_"+C)[0]){$("#frameContainer").append(["<iframe",'id="frame_'+C+'"','name="frame_'+C+'"','src="/secure/blank.ixi"','style="border: 0; height: 0; width: 0; padding: 0; position: absolute;"',"/>"].join(" "))
}$("#offlineHotelForm").attr({"enctype":"multipart/form-data","encoding":"multipart/form-data","method":"post","target":"frame_"+C,"action":"/secure/action/upload"});
$("#progress_"+C).show();$("#offlineHotelForm")[0].submit()}else{setTimeout(function(){A.upload(C)},7000)
}};A.callback=function(D){try{var C=IXIGO.JSON.parse(D),E=(C.name?C.name.split("_")[1]:null);$("#progress_"+E).hide();
if(!C["error"]){A.addFileUploaded(E,C)}else{if(!E){E=A.sid}$("#input_"+E).remove();$(A.createNewInputFile(E)).insertBefore("#remove_"+E);
$("#input_"+E).change(function(F){A.upload(E)});$("#error_"+E).html('<div class="error" style="" id="messages"><ul><li>'+C["msg"]+"</li></ul></div>").show()
}}finally{A.uploadmutex=true}};A.addFileUploaded=function(E,C){var D=""+'<div id="box_'+E+'">'+'<span><input id="check_'+E+'" name="check_'+E+'" type="checkbox" checked="true" value="'+C["name"]+'" class="checkBox" /></span>'+"<span> "+C["filename"]+(C["type"]?" ("+C["type"]+")":"")+"</span>"+"</div>";
$("#picUploaded").append(D);$("#"+E+", #frame_"+E).remove();A.uploads[C["modifiedFileName"]]=C["filename"];
$("#check_"+E).click(function(){setTimeout("window.offlineHotel.onpictureunselect('check_"+E+"', '"+C["modifiedFileName"]+"')",100)
})};A.onunselect=function(D,C){if(!($("#"+D).attr("checked"))){$("#"+D.replace(/check/,"box")).remove();
A.uploads[C]=null;A.count=A.count-1;A.afterDisplay()}};A.getUploads=function(){var D=[],C=[];$.each(A.uploads,function(F,E){if(E){D.push(F);
C.push(E)}});return[D.join(B),C.join(B)]};A.rnd=function(){return String((new Date()).getTime()).replace(/\D/gi,"")
}};IXIGO.OfflineProperties=function(){var B=null;var A,C;var D;this.init=function(){B=this;D=$("table.ixi-grid");
this.form=document.forms.form;A=$("#propertyMsgBox");C=$("#propertyMsg");if(C.html()){A.show()}D.find("thead th:first input.checkBox").click(function(){var E=this.checked;
D.find("tbody tr").each(function(){$(this).find("td:first input.checkBox")[0].checked=E})});D.find("tbody tr").click(function(E){B.onClickProperty(this,E)
}).end().find(".ixi-paynow").each(function(){var E=$(this);E.mouseover(function(){IXIGO.Utils.onHoverButton("#"+this.id,"","")
}).mouseout(function(){IXIGO.Utils.onHoverButton("#"+this.id,"","")})});$("#addProperty").click(function(){window.location.href="/secure/hotel/registerOfflineHotels.ixi"
}).mouseover(function(E){IXIGO.Utils.onHoverButton("#addProperty","","")}).mouseout(function(E){IXIGO.Utils.onHoverButton("#addProperty","","")
});$("#delProperty").click(function(E){B.onClickDelete(E)}).mouseover(function(E){IXIGO.Utils.onHoverButton("#delProperty","","")
}).mouseout(function(E){IXIGO.Utils.onHoverButton("#delProperty","","")});$("#buySubscription").click(function(E){B.onClickBulkBuy(E)
}).mouseover(function(E){IXIGO.Utils.onHoverButton("#buySubscription","","")}).mouseout(function(E){IXIGO.Utils.onHoverButton("#buySubscription","","")
})};this.showInfo=function(E){C.html(E);A.css({"background-color":"#FAD55A","color":"#444"}).show()};
this.showError=function(E){C.html(E);A.css({"background-color":"#FBE3D4","color":"#D12E18"}).show()};
this.resetError=function(){A.hide();D.find("tbody tr").each(function(){$(this).removeClass("error")})
};this.onClickProperty=function(I,G){var E=G.target;while(E!==I&&!E.getAttribute("invoke")){E=E.parentNode
}var F=E.getAttribute("invoke");if(F){this.resetError();args=E.id.split("-");if(F=="delete"){IXIGO.Alert.show({type:"warn",msg:"your property will be deleted permanently?",buttons:["ok","cancel"]},function(J){if(J=="ok"){window.location.href="/secure/offline?q=delete-"+args[1]
}})}else{if(F=="pay"){var H=E.id.substring(6);IXIGO.Alert.show({type:"info",msg:B.getPrePayConfirmMsg([{"name":E.getAttribute("propName"),"city":E.getAttribute("ct"),"country":E.getAttribute("cc")}]),buttons:["ok","cancel"],width:"520px"},function(J){if(J=="ok"){window.location.href="/secure/offline?q=pay-"+H
}})}}}G.stopPropagation()};this.onClickDelete=function(G){this.resetError();var F=[];var E=D.find("td input:checkbox[checked]");
if(E.length>0){E.each(function(){F[F.length]=this.value});IXIGO.Alert.show({type:"warn",msg:"your "+(F.length==1?"property":"properties")+" will be deleted permanently?",buttons:["ok","cancel"]},function(H){if(H=="ok"){window.location.href="/secure/offline?q=delete-"+F.join("-")
}})}else{this.showError(i18n_dictionary.offlineDelete)}G.stopPropagation()};this.onClickBulkBuy=function(I){this.resetError();
var H=[];var F=[];var G=D.find("td input:checkbox[checked]");if(G.length>0){var E=0;G.each(function(){var J=parseInt(this.getAttribute("status"),10);
if(!isNaN(J)&&J>2){$(this).parent().parent().addClass("error");E++}else{H[H.length]=this.value;F[F.length]={"name":this.getAttribute("propName"),"city":this.getAttribute("ct"),"country":this.getAttribute("cc")}
}});if(E===0){IXIGO.Alert.show({type:"info",msg:B.getPrePayConfirmMsg(F),buttons:["ok","cancel"],width:"520px"},function(J){if(J=="ok"){window.location.href="/secure/offline?q=pay-"+H.join("-")
}})}else{this.showError("you have already subscribed to the following selected "+(E==1?"property":"properties")+".")
}}else{this.showError(i18n_dictionary.offlineSubscribe)}I.stopPropagation()};this.getPrePayConfirmMsg=function(F){var E=F.length;
var G=""+'<table id="propertiesInvoice" cellspacing="0" cellpadding="0">'+'<tr><th></th><th>Description</th><th class="txt-r">Amount in INR</th></tr>'+'<tr class="spacer"><td colspan="3"></td></tr>'+'<tr class="sep-b"><td>&#160;</td><td>Subscription Fee to list below mentioned '+(E>1?"properties":"property")+" on iXiGO.com for a period of 12 months</td><td>&#160;</td></tr>";
var I=0;for(var H=0;H<E;H++){G+='<tr class="spacer"><td colspan="3"></td></tr>'+"<tr"+(F[H].country=="IN"?"":' class="sep-b"')+"><td>"+(H+1)+".</td><td><strong>"+F[H].name+", "+F[H].city+'</strong></td><td class="sep-r txt-r">5000</td></tr>';
I+=5000;if(F[H].country=="IN"){G+='<tr class="sep-b"><td>&#160;</td><td class="txt-r">Service Tax</td><td class="sep-r txt-r">515</td></tr>';
I+=515}}G+=""+'<tr class="spacer"><td colspan="3"></td></tr>'+'<tr class="sep-b"><td>&#160;</td><td><strong>Total</strong></td><td class="txt-r"><strong>'+I+"</strong></td></tr>"+'<tr><td colspan="3">note: 10.3% service tax applicable for hotels within India</td></tr>'+"</table>";
return G}};
