(function($){var currentState=0;var buttonStates=["&nbsp;&nbsp;&nbsp;",".&nbsp;&nbsp;","..&nbsp;","..."];var inputStates=['','.','..','...'];var intervalId=null;$.fn.animateSubmit=function(options){if(intervalId!==null){clearInterval(intervalId);currentState=0;}
settings=jQuery.extend({msg:"Loading"},options);this.each(function(){$(this).click(function(){currentState=0;if(this.tagName=='INPUT'){$(this).val(settings.msg+inputStates[currentState]);}else{$(this).html(settings.msg+buttonStates[currentState]);}
var parentContext=$(this);intervalId=setInterval(function(){if(parentContext[0].tagName=='INPUT'){parentContext.val(settings.msg+inputStates[currentState]);}else{parentContext.html(settings.msg+buttonStates[currentState]);}
currentState=(currentState==3)?0:currentState+1;},300);});});return this;};})(jQuery);function searchReady(url,catid){$('a[rel*=facebox]').facebox();$('#search').submit(function(){preSearch();$("#results").slideUp();$.getJSON(url,$(this).serialize(),function(data){$("#results").html(data.html).slideDown("normal");var resultsCount=data.resultsCount;if(resultsCount>0){if(isRst){isRst=false;$("#resultsCount").html('('+resultsCount+' '+itemsindatabase+')');}else{$("#resultsCount").html('('+resultsCount+' '+itemsfound+')');}}else{$("#resultsCount").html('('+noitemsfound+')');}
unblock();$('#results').fadeIn(500);$('a[rel*=facebox]').facebox();FB.Share.renderPass();$('#submit').removeAttr('disabled');$('#city').change(function(){$('#pageNo').attr('value',1);$('#search').trigger('submit');});if(local_auto_expand_items==1){$('#expandAll').click();}});return false;});initPriceRange();initPageLinks();bindItemDisplayControls();$("#searchBtn").click(function(){jumpToPage(1);});if($.browser.msie){$('#search').find('select').change(function(){$('#pageNo').attr('value',1);$('#search').trigger('submit');});}else{$('#search').change(function(){$('#pageNo').attr('value',1);$('#search').trigger('submit');});}
$('.addNotification').live("click",function(e){e.preventDefault();addNotification($("#search").serialize()+'&catId='+catid);});if(local_auto_expand_items==0){$('a.expandingItemTitle').each(function(){var itemDiv=$('#itemBox'+this.id);itemDiv.hide();$(this).find("img[src*=minus.png]").attr('src','/images/icons/plus.png');$(this).find("img[src*=minusp.png]").attr('src','/images/icons/plusp.png');});}
$("#rst").click(function(){isRst=true;$("#search select:not(#currency)").val('').find("option:first").attr("selected","selected");$("#search").change();$("select:not(#currency)").parent().css('background','');$("#country,#city,#model").parent().parent().css('background','');});$('#search select:not(#country,#city,#model,#currency)').change(function(){if($(this).val()==''||$(this).val()==0){$(this).parent().css('background','');}else{$(this).parent().css('background','yellow');}});$('#country,#city,#model').live('change',function(){if($(this).val()==''||$(this).val()==0){$(this).parent().parent().css('background','');}else{$(this).parent().parent().css('background','yellow');}});}
function initMoreOptions(){$('#showFewerOptions').hide();$('.advOption').hide();$('#showMoreOptions').click(function(){$('.advOption').each(function(){if($.browser.msie){$(this).show();}else{$(this).fadeIn("slow");}
$(this).find('td > select option:first').attr('selected','selected').parent('select');});$('#showMoreOptions').hide();$('#showFewerOptions').show();return false;});$('#showFewerOptions').click(function(){$('.advOption').each(function(){if($.browser.msie){$(this).hide();}else{$(this).fadeOut("fast");}
$(this).find('td > select option:first').attr('selected','selected').parent('select');});$('#showFewerOptions').hide();$('#showMoreOptions').show();return false;});}
function bindItemDisplayControls(){$('#expandAll').click(function(e){e.preventDefault();$("div[id^=itemBox]").fadeIn("slow");$("img[src*=plus.png]").attr('src','/images/icons/minus.png');$("img[src*=plusp.png]").attr('src','/images/icons/minusp.png');});$('#minAll').click(function(e){e.preventDefault();$("div[id^=itemBox]").slideUp();$("img[src*=minus.png]").attr('src','/images/icons/plus.png');$("img[src*=minusp.png]").attr('src','/images/icons/plusp.png');});$('#invert').click(function(e){e.preventDefault();$('a.expandingItemTitle').trigger("click");});$('a.expandingItemTitle').live("click",function(e){e.preventDefault();var el=$('#itemBox'+this.id);if(el.is(':visible')){el.slideUp();$(this).find("img[src*=minus]").attr('src','/images/icons/plusp.png');}else{el.fadeIn("normal")
$(this).find("img[src*=plus]").attr('src','/images/icons/minusp.png');}});}
$.fn.confirmRedirect=function(question,url){$(this).click(function(){var ans=confirm(question);if(ans){window.location.href=url;}
return false;});};var _popupTracker={}
var _popupCounter=0;$.fn.openPopupWindow=function(options)
{var defaults={height:600,width:600,toolbar:0,scrollbars:0,status:0,resizable:1,left:0,top:0,center:0,createnew:0,location:0,menubar:0};var options=$.extend(defaults,options);var obj=this;if(options.center==1)
{options.top=(screen.height-(options.height+110))/2;options.left=(screen.width-options.width)/2;}
var parameters="location="+options.location+",menubar="+options.menubar+",height="+options.height+",width="+options.width+",toolbar="+options.toolbar+",scrollbars="+options.scrollbars+",status="+options.status+",resizable="+options.resizable+",left="+options.left+",screenX="+options.left+",top="+options.top+",screenY="+options.top;var target=obj.attr("href");var popup=_popupTracker[target];if(options.createnew==0&&popup!==undefined&&!popup.closed)
{popup.focus();}
else
{var name="PopupWindow"+_popupCounter;_popupCounter++;popup=window.open(target,name,parameters);_popupTracker[target]=popup;_popupTracker[target].focus();}
return false;};function mainReady(){$('.countryMap').click(function(e){e.preventDefault();$('#search').val($(this).attr('title'));$('#searchButton').focus().click();});$('.error').closest('tr').css('background','#ffeeee');$('.selectedPageNumber').live("click",function(){return false;});$('#ad').click(function(e){e.preventDefault();var adURL=$('#ad').attr('href');var bid=$('#ad').attr('rel');window.open('/tracker/?bid='+bid+'&url='+adURL,'_blank');return false;});$("td.twit *").hover(function(){$(this).find("a:eq(1)").css("text-decoration","underline");},function(){$(this).find("a:eq(1)").css("text-decoration","none");});$.loginDiv=$("<div></div>");$("#btnLogin").click(function(){ajaxLogin();return false;});$("a[rel=contactSeller], a[rel=tellaFriend], .leftMenuSubCat[href$=/post], #favouritesWidget a, #myItemsWidget a, #notificationsWidget a, a[rel=buyCredits]").live("click",function(){ajaxLogin($(this).attr("href"));return false;});$("a[rel=twitLink]").live("click",function(){$(this).openPopupWindow(null);return false;});$("td.twit *").hover(function(){$(this).find("a:eq(1)").css("text-decoration","underline");},function(){$(this).find("a:eq(1)").css("text-decoration","none");});$('img:first').attr("border",0);if(lang=='Ar'){$('#'+section+'SectionIcon').attr('src','/images/banner/icon_'+$('#'+section+'SectionIcon').attr('rel')+'_text_ar.gif');}else{$('#'+section+'SectionIcon').attr('src','/images/banner/icon_'+$('#'+section+'SectionIcon').attr('rel')+'_text.gif');}
$('.catIcon:not('+'#'+section+'SectionIcon'+')').mouseover(function(){if(lang=='Ar'){$(this).attr('src','/images/banner/icon_'+$(this).attr('rel')+'_text_ar.gif');}else{$(this).attr('src','/images/banner/icon_'+$(this).attr('rel')+'_text.gif');}}).mouseout(function(){$(this).attr('src','/images/banner/icon_'+$(this).attr('rel')+'.gif');});$('.leftMenuMainCat').click(function(){var el=$('#'+this.id+'Menu');$(el).is(':hidden')?$(el).fadeIn("normal"):$(el).slideUp();});$('.leftMenuSubCatHighlight').hover(function(){$(this).css({"background":'#f5f5f5'});},function(){$(this).css({"background":''});});$('img[src*=notifyme]').mouseover(function(){if(lang=='Ar'){$(this).attr('src','/images/notifyme_ar_over.gif');}else{$(this).attr('src','/images/notifyme_over.gif');}}).mouseout(function(){if(lang=='Ar'){$(this).attr('src','/images/notifyme_ar.gif');}else{$(this).attr('src','/images/notifyme.gif');}});$("option:contains('Other')").css({'font-color':'blue','font-weight':'bolder','color':'blue'});if(lang=='Ar'){$("#content *[align='left']").attr("ref","toRight");$("#content *[align='right']").attr("align","left");$("#content *[ref='toRight']").attr("align","right");}
if($.browser.msie){$(document).bind("beforeReveal.facebox",function(){$("select").hide();});$(document).bind("close.facebox",function(){$("select").show();});if(lang=='Ar'){$("#content td[align!='center'][align!='left'][align!='right'][align!='justify']").attr("align","right");}}
$('.language').click(function(e){e.preventDefault();var currentURL=window.location.href;if(currentURL.search("lang")!=-1){if(lang=='En'){currentURL=currentURL.replace("lang=En","lang=Ar");}else{currentURL=currentURL.replace("lang=Ar","lang=En");}}else{if(currentURL.search("\\?")==-1){if(lang=='En'){currentURL=currentURL+"?lang=Ar";}else{currentURL=currentURL+"?lang=En";}}else{if(lang=='En'){currentURL=currentURL+"&lang=Ar";}else{currentURL=currentURL+"&lang=En";}}}
window.location=currentURL;});$(document).bind("reveal.facebox",function(){$("button").initUIButtons();});$('#googlemapsample, #caracing, #notifyMe, #instaweb, #instafeed').facebox();$("button, input[type=submit], input[type=button]").initUIButtons();}
$.fn.initUIButtons=function(){$(this).addClass("ui-state-default ui-corner-all").hover(function(){$(this).addClass("ui-state-hover");},function(){$(this).removeClass("ui-state-hover");});}
function checkAuth(){if(lang=='Ar'){var msg='<h1 dir="rtl">يرجى الانتظار...</h1>';}else{var msg='<h1>Please wait...</h1>';}
block(msg);var logged=(function(){var isLogged=null;$.ajax({'async':false,'global':false,'url':'/ajax/userlogged/','success':function(resp){unblock();isLogged=(resp==="1");}});return isLogged;})();return logged;}
function ajaxLogin(url){if(lang=='Ar'){var msg='<h1 dir="rtl">يرجى الانتظار...</h1>';}else{var msg='<h1>Please wait...</h1>';}
block(msg);$.get('/ajax/userlogged',function(resp){unblock();if(resp!=''){if(url!=null){window.location.href=url;}else{window.location.href=window.location.href;}}else{$.loginDiv.dialog({autoOpen:false,modal:true,bgiframe:true,width:450});$.loginDiv.dialog('open');if(lang=='Ar'){$.loginDiv.html("<h3 dir=\"rtl\">يرجى الانتظار...</h3><div align=\"center\"><img src=\"/images/loading.gif\"</div>");}else{$.loginDiv.html("<h3>Loading...</h3><div align=\"center\"><img src=\"/images/loading.gif\"</div>");}
if(url!=null){$.data($.loginDiv,"goto",url);}else{$.removeData($.loginDiv);}
var options={};if(url!==undefined){options={jump:url};}
$.getJSON("/login",options,function(json){if(json.status=='0'){$.loginDiv.html(json.html);$.loginDiv.dialog('option','title',json.title);}});}});}
function contactSeller(uname,type,id){window.location='/contact/?u='+uname+'&type='+type+'&id='+id;}
function tellAFriend(uname,type,id){window.location='/contact/tellafriend/?u='+uname+'&type='+type+'&id='+id;}
function confirmPrice(){var question;if(lang=='Ar'){question='بعض المشترين ربما لا ينظرون إلى هذه السلعة لأنها بدون سعر محدد.\n\nهل أنت متأكد أنك تريد إخفاء السعر؟';}else{question='Some buyers may ignore this item because there is no given price.\n\nAre you sure you would like to hide the price?';}
var answer=confirm(question);return answer;}
function selectPropertyType(selectId){var selected=$('#'+selectId+' option:selected');if(selected.val()!=10&&selected.val()!=''||selected.text()=='Other'||selected.text()=='آخر'){$("#buildingSection").show();$.each(["#buildingSection select","#buildingSection input"],function(i,val){$(val).attr('disabled',false);});$('#isBuilding').val('true');if(selected.val()==3||selected.val()==6||selected.val()==7){$("#basements").attr("disabled",true);$("#basements").parent().parent().hide();$('#td_landarea').html(landareaText+':');$("#builtUpArea").attr('disabled',false);$('#tr_builtuparea').show();if(selected.val()==3){$('#td_landarea').html(sizeText+':');$("#builtUpArea").attr('disabled',true);$('#tr_builtuparea').hide();}}else{$("#basements").attr("disabled",false);$("#basements").parent().parent().show();$('#td_landarea').html(landareaText+':');$("#builtUpArea").attr('disabled',false);$('#tr_builtuparea').show();}}else{$("#buildingSection").hide();$.each(["#buildingSection select","#buildingSection input"],function(i,val){$(val).attr('disabled',true);});$('#isBuilding').val('false');}}
function selectContractType(selectId){var selectedVal=$('#'+selectId+' option:selected').val();if(selectedVal=='2'){$('#rentaldurationSection').show();$.each(['#rentaldurationSection select','#rentaldurationSection input'],function(val){$(val).attr('disabled',false);});$('#td_sellingPrice').hide();$('#td_rentalPrice').show();}else{$('#rentaldurationSection').hide();$.each(['#rentaldurationSection select','#rentaldurationSection input'],function(val){$(val).attr('disabled',true);});$('#td_sellingPrice').show();$('#td_rentalPrice').hide();}}
function initDetailedView(tab){$tabs=$("#detailTabs").tabs();if(tab!=null&&tab!=''){$tabs.tabs('select','#'+tab);}else{$tabs.tabs('select',0);}
$('a.imgThumbLink > img').mouseover(function(){$(this).addClass("hilight");}).mouseout(function(){$(this).removeClass("hilight");});$("a.imgThumbLink").click(function(){$("a.imgThumbLink > img").removeClass("selected");$(this).find("img").addClass("selected");var parent=$(this);if($(".bigImage").is(":visible")){var options={message:'<img src="'+'/images/loading.gif"/> ',css:{border:'none',opacity:0.5,backgroundColor:'#fff',width:'auto'},overlayCSS:{opacity:0.1}};$("#photoView").block(options);}else{$("#photoView").html('<img src="'+'/images/loading.gif"/>').show();}
loadPhoto(parent.attr("href"));return false;});$("#addComment").click(function(){if(checkAuth()){$tabs.tabs('select','#comments');}else{if(lang=='Ar'){block('<h1 dir="rtl">يجب أن تدخل لتتمكن من إضافة تعليق</h1>',3000);}else{block('<h1>You must be Signed In to post a comment</h1>',3000);}}
return false;});$("#postComment").live("click",function(){if(checkAuth()){var data=$("#addComment").attr("rel").split("_");$.post('/posts/comments',{item:$("#addComment").attr("rel"),text:$('#commentTA').val()},function(json){$tabs.tabs('option','disabled',[]);if(json.status==1){$.get('/posts/comments',{action:'refresh',categoryid:data[0],itemid:data[1]},function(html){$("#comments").html(html);});}else if(json.status==0){$(".error").html(json.error);}},"json");}else{if(lang=='Ar'){block('<h1 dir="rtl">يجب أن تدخل لتتمكن من إضافة تعليق</h1>',3000);}else{block('<h1>You must be Signed In to post a comment</h1>',3000);}}
return false;});if(tab=='photos'){$('#photos a.imgThumbLink:first').click();}
$("a[href=#photos]").click(function(){if(!$("#photoView .bigImage").length){$('#photos').find("a.imgThumbLink:first").click();}});$('#summary a.imgThumbLink').click(function(){$("a[href=#photos]").click();});return false;}
function loadPhoto(url)
{var img=(function(){var img=null;$.ajax({'async':false,'global':false,'url':'/ajax/img/?img='+url,'success':function(data){img=data;}});return img;})();$(img).load(function(){if($("#photoView > .bigImage").is(":visible")){$(".bigImage").fadeTo("fast",0.33,function(){$("#photoView").html(img).find(".bigImage").fadeIn("normal");});}else{$("#photoView").html(img).find(".bigImage").fadeIn("slow");}
$('#photoView').unblock();});}
function initPriceRange(){$('#minPrice').change(function(){var minPrice=parseInt($('#minPrice').val());var maxPrice=parseInt($('#maxPrice').val());if(minPrice>maxPrice){return false;}});$('#maxPrice').change(function(){var minPrice=parseInt($('#minPrice').val());var maxPrice=parseInt($('#maxPrice').val());if(minPrice>maxPrice){return false;}});}
function initPageLinks(){$('.pageNumber').live("click",function(e){e.preventDefault();var pageNo=$(this).text();$('#pageNo').val(pageNo);jumpToPage(pageNo);});$('.prevBtn').live("click",function(e){e.preventDefault();var pageNo=parseInt($('#pageNo').val());pageNo--;$('#pageNo').val(pageNo);jumpToPage(pageNo);});$('.nextBtn').live("click",function(e){e.preventDefault();var pageNo=parseInt($('#pageNo').val());pageNo++;$('#pageNo').val(pageNo);jumpToPage(pageNo);});$('.firstBtn').live("click",function(e){e.preventDefault();var pageNo=$(this).text();$('#pageNo').val(pageNo);jumpToPage(pageNo);});$('.lastBtn').live("click",function(e){e.preventDefault();var pageNo=$(this).text();$('#pageNo').val(pageNo);jumpToPage(pageNo);});}
function jumpToPage(pageNo){var pageToShow=pageNo;var currentPage=parseInt($('#pageNo').val());if(pageToShow=='prev'&&currentPage>1){pageToShow=currentPage-1;}
if(pageToShow=='next'){pageToShow=currentPage+1;}
$('#pageNo').attr('value',pageToShow);$('#search').trigger('submit');}
function block(msg,timeout){if(msg.length==3){if(lang=='Ar'){mess='<h1 dir="rtl">الرجاء الانتظار...</h1>';}else{mess='<h1>Please wait...</h1>';}}else{mess=msg;}
var options={message:mess,showOverlay:false,css:{border:'3px solid #0066CC',padding:'15px',backgroundColor:'#000','-webkit-border-radius':'10px','-moz-border-radius':'10px',opacity:'0.8',color:'#0066CC'}};if(timeout){options.timeout=timeout;}
$.blockUI(options);}
function unblock(){$.unblockUI();}
function addFavourite(itemId,catId){if(lang=='Ar'){block('<h1 dir="rtl">جاري إضافة السلعة إلى سلعي المفضلة...</h1>');}else{block('<h1>Adding Item to My Favourites...</h1>');}
$.get('/ajax/userlogged',function(resp){if(resp==''){ajaxLogin();}else{$.ajax({type:"POST",url:"/favourites/proxy",data:"itemid="+itemId+"&catid="+catId+"&action=add",success:function(resp){$('#favouritesWidget').html(resp).fadeOut("fast").fadeIn("fast").fadeOut("fast").fadeIn("fast");$('.leftMenuSubCatHighlight').hover(function(){$(this).css({"background":'#f5f5f5'});},function(){$(this).css({"background":''});});unblock();}});}});}
function deleteFavourite(id){if(lang=='Ar'){block('<h1 dir="rtl">جاري حذف السلعة من سلعي المفضلة...</h1>');}else{block('<h1>Removing Item from My Favourites...</h1>');}
$.ajax({type:"POST",url:"/favourites/proxy",data:"id="+id+"&action=delete",success:function(resp){refreshFavourites();$('#favouritesWidget').html(resp).fadeOut("fast").fadeIn("fast").fadeOut("fast").fadeIn("fast");$('.leftMenuSubCatHighlight').hover(function(){$(this).css({"background":'#f5f5f5'});},function(){$(this).css({"background":''});});unblock();}});return false;}
function deleteFavouriteItem(id,catId){if(lang=='Ar'){block('<h1 dir="rtl">جاري حذف السلعة من سلعي المفضلة...</h1>');}else{block('<h1>Removing Item from My Favourites...</h1>');}
$.get('/ajax/userlogged',function(resp){if(resp==''){ajaxLogin();}else{$.ajax({type:"POST",url:"/favourites/proxy",data:"itemid="+id+"&catid="+catId+"&action=deleteItem",success:function(resp){$('#favouritesWidget').html(resp).fadeOut("fast").fadeIn("fast").fadeOut("fast").fadeIn("fast");$('.leftMenuSubCatHighlight').hover(function(){$(this).css({"background":'#f5f5f5'});},function(){$(this).css({"background":''});});unblock();}});}});return;}
function refreshFavourites(){$.ajax({type:"POST",url:"/favourites/proxy",data:"action=refresh",success:function(resp){$('#content').html(resp);}});return false;}
function markAsReadMessage(id){$.ajax({type:"POST",url:"/messages/proxy",data:"id="+id+"&action=read",success:function(){}});return false;}
function deleteMessage(id,pageNo){if(lang=='Ar'){block('<h1 dir="rtl">جاري حذف الرسالة...</h1>');}else{block('<h1>Deleting Message...</h1>');}
$.ajax({url:'/messages/proxy',type:'post',data:{id:id,action:'delete',page:pageNo},dataType:'json',success:function(json){$("#messages").html(json.content);$("#pageLinks").html(json.pageLinks);$('div.contentInfo table[id*=message]:even').css('background','#f5f5f5');$('div.contentInfo table[id*=message]:odd').css('background','');unblock();}});return false;}
function deleteSelectedMessages(idArr,pageNo){if(idArr.length){if(lang=='Ar'){block('<h1 dir="rtl">جاري حذف الرسائل...</h1>');}else{block('<h1>Deleting Messages...</h1>');}
var idString=idArr.join(",");$.ajax({url:'/messages/proxy',type:'post',data:{ids:idString,action:'deleteSelected',page:pageNo},dataType:'json',success:function(json){$("#messages").html(json.content);$("#pageLinks").html(json.pageLinks);$('div.contentInfo table[id*=message]:even').css('background','#f5f5f5');$('div.contentInfo table[id*=message]:odd').css('background','');unblock();}});}
return false;}
function markAsUnreadSelectedMessages(idArr){if(idArr.length){if(lang=='Ar'){block('<h1 dir="rtl">جاري حذف الرسائل...</h1>');}else{block('<h1>Please wait...</h1>');}
var arrayString=idArr.join(",");$.ajax({type:"POST",url:"/messages/proxy",data:"ids="+arrayString+"&action=unreadSelected",success:function(){for(var i=0;i<idArr.length;i++){$('#message_'+idArr[i]).find("img[src*=message]").attr('src','/images/icons/newmessage.png');$('#message_'+idArr[i]+' div.expandableDiv').hide();}
unblock();}});}
return false;}
function addNotification(params){$.get('/ajax/userlogged',function(resp){if(resp!=''){if(lang=='Ar'){block('<h1 dir="rtl">جاري إضافة الملاحظة...</h1>');}else{block('<h1>Adding Notification...</h1>');}
$.ajax({type:"POST",url:"/notifications/add",data:params,success:function(html){unblock();if(html=='2'){if(lang=='Ar'){block('<h1 dir="rtl">توجد ملاحظة بنفس المعايير قد أضيفت مسبقا</h1>',3000);}else{block('<h1>A notification matching your selected criteria<br />has already been added</h1>',3000);}}else if(html=='-1'){if(lang=='Ar'){block('<h1 dir="rtl">يجب أن تختار معيار <i>واحد</i> على الأقل</h1>',3000);}else{block('<h1>You must select at least <i>one</i> criterion</h1>',3000);}}else{if(lang=='Ar'){block('<h1 dir="rtl">تم إضافة الملاحظة</h1>',1000);}else{block('<h1>Notification added</h1>',1000);}
$('#notificationsWidget').html(html).fadeOut("fast").fadeIn("fast").fadeOut("fast").fadeIn("fast");}}});}else{ajaxLogin();}});}
function deleteNotification(id){if(lang=='Ar'){block('<h1 dir="rtl">جاري حذف الملاحظة...</h1>');}else{block('<h1>Removing Notification...</h1>');}
$.get('/ajax/userlogged',function(resp){if(resp!=''){$.ajax({type:"POST",url:"/notifications/delete",data:"id="+id,success:function(resp){refreshNotifications();$('#notificationsWidget').html(resp).fadeOut("fast").fadeIn("fast").fadeOut("fast").fadeIn("fast");if(lang=='Ar'){block('<h1 dir="rtl">تم حذف الملاحظة</h1>',1000);}else{block('<h1>Notification Deleted</h1>',1000);}}});}else{ajaxLogin();}});}
function refreshNotifications(){$('#content').load('/notifications/refresh');}
function preSearch(){if(lang=='Ar'){block('<h1 dir="rtl">يرجى الانتظار...</h1>');}else{block('<h1>Loading...</h1>');}
$('#submit').attr('disabled',true);}
function brandModelsInit(catId,isPostForm)
{$('#brand').change(function(){if(!$(this).val()){if($(this).find('option:last').is(':selected')){$('#ob').show();$('#otherBrand').removeAttr("disabled");$('#om').show();$('#otherModel').removeAttr("disabled");$('#models').hide();$('#model').attr('disabled',true);}else{$('#ob').hide();$('#otherBrand').attr('disabled',true);$('#om').hide();$('#otherModel').attr('disabled',true);$('#models').show();$('#model').attr('disabled',true);}}else{getModels(catId,$(this).val(),isPostForm);if(isPostForm){$('#ob').hide();$('#otherBrand').attr('disabled',true);$('#om').hide();$('#otherModel').attr('disabled',true);$('#models').show();$('#model').removeAttr("disabled");}}});}
function getModels(catId,brandId,isPostForm){var strmsg;if(lang=='Ar'){strmsg='<font dir="rtl" style="font-weight:bold;color:#3399FF">يرجى الانتظار...</font>';}else{strmsg='<font style="font-weight:bold;color:#3399FF">Loading Models...</font>';}
var loadingMessage=strmsg;$('#models').html(loadingMessage);var params='catId='+catId+'&'+'brand='+brandId;if(isPostForm){params+='&isPostForm=true';}
params+='&callerId=models';$.ajax({type:"POST",url:'/ajax/brandmodels/',data:params,dataType:'json',success:function(msg){$('#'+msg.callerId).html(msg.innerHTML);$("#model").change(function(){if($(this).find("option:last").is(':selected')){$('#om').show();$('#om').find("input").attr('disabled',false);}else{$('#om').hide();$('#om').find("input").attr('disabled',true);}});}});}
function countryCityInit(showOther)
{$('#country').change(function(){if(!$('#country').val()){$('#city').attr('disabled',true);$('#oc').hide();$('#otherCity').attr('disabled',true);}
else{getCities($('#country option:selected').val(),showOther);if(showOther){$('#oc').hide();$('#otherCity').attr('disabled',true);}}});}
function getCities(countryCode,showOtherOption){var strmsg;if(lang=='Ar'){strmsg='<font dir="rtl" align="right" style="font-weight:bold;color:#3399FF">يرجى الانتظار...</font>';}else{strmsg='<font style="font-weight:bold;color:#3399FF">Loading Cities...</font>';}
var loadingMessage=strmsg;var inputDiv=$('#oc');$('#cities').html(loadingMessage);var params='country='+countryCode;if(showOtherOption){params+='&showOtherOption=true';}
var post=params+'&callerId=cities';$.ajax({type:"POST",url:'/ajax/countrycities/',data:post,dataType:'json',success:function(msg){$('#'+msg.callerId).html(msg.innerHTML);$('#city').change(function(){if($('#'+this.id+' option:last').is(':selected')){inputDiv.show();inputDiv.find("input").attr('disabled',false);}else{inputDiv.hide();inputDiv.find("input").attr('disabled',true);}});}});}
function toggleOtherEnabledField(obj){$.each(obj,function(i,val){var sel=$('#'+val);var inputDiv=$('#'+i);if((inputDiv).is(':visible')){inputDiv.find("input").attr('disabled',false);}
sel.change(function(){if($(this).find("option:last").is(':selected')){inputDiv.show();inputDiv.find("input").attr('disabled',false);}else{inputDiv.hide();inputDiv.find("input").attr('disabled',true);}});});}
function toggleControl(srcElementId,elementId){var control=$('#'+srcElementId);var targetElement=$('#'+elementId)[0];if(targetElement.style.display=='none'){$(targetElement).show();$(targetElement).effect("highlight",{},1000);control.css({"font-weight":"bold"});}else{control.css({"font-weight":"normal"});$(targetElement).fadeOut(500);}}