$(document).ready(function()
{tooltip();});function tooltip()
{$("img.tooltip").mouseover
(function(event)
{var text=this.name;$(this).removeAttr("title");old_title=text;x=event.pageX+5;y=event.pageY+5;$("body").append("<div id='tooltip'>"+text+"</div>");$("#tooltip").css("left",x).css("top",y);});$("span.tooltip").mouseover
(function(event)
{var text=this.id;x=event.pageX+5;y=event.pageY+5;$("body").append("<div id='tooltip'>"+text+"</div>");$("#tooltip").css("left",x).css("top",y);});$("input.tooltip").mouseover
(function(event)
{var text=this.title;$(this).removeAttr("title");old_title=text;x=event.pageX+5;y=event.pageY+5;$("body").append("<div id='tooltip'>"+text+"</div>");$("#tooltip").css("left",x).css("top",y);});$("img.tooltip").mouseout(function(event)
{$("#tooltip").remove();$(this).attr("title",old_title);});$("span.tooltip").mouseout(function(event)
{$("#tooltip").remove();});$("input.tooltip").mouseout(function(event)
{$("#tooltip").remove();$(this).attr("title",old_title);});}
function n_window(theurl,w,h)
{var the_width=w;var the_height=h;var from_top=200;var from_left=200;var has_toolbar='no';var has_location='no';var has_directories='no';var has_status='no';var has_menubar='no';var has_scrollbars='yes';var is_resizable='yes';var the_atts='width='+the_width+'show,height='+the_height+',top='+from_top+',screenY='+from_top+',left='+from_left+',screenX='+from_left;the_atts+=',toolbar='+has_toolbar+',location='+has_location+',directories='+has_directories+',status='+has_status;the_atts+=',menubar='+has_menubar+',scrollbars='+has_scrollbars+',resizable='+is_resizable;window.open(theurl,'',the_atts);}
function myConfirm(msg)
{if(!confirm(msg))return false;return true;}
function doSel(obj)
{for(i=0;i<obj.length;i++)
if(obj[i].selected==true)
eval(obj[i].value);}
function changeLoc(obj,base,field,param){for(i=0;i<obj.length;i++)
if(obj[i].selected==true)
location.href=base+"?"+param+"&"+field+"="+obj[i].value;}
function getxmlhttp(){var xmlhttp=false;try{xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");}catch(e){try{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}catch(E){xmlhttp=false;}}
if(!xmlhttp&&typeof XMLHttpRequest!='undefined'){xmlhttp=new XMLHttpRequest();}
return xmlhttp;}
function CountTitleLeft(field,max){if(field.value.length>max)
field.value=field.value.substring(0,max);}
function splitMapsCoord(str){if(!str)return 0;var split_str=str.split(",");var no=split_str.length;if(no!=3)return 0;return split_str;}
function PreloadImages(str){a=str.split(",");var d=document;if(d.images){if(!d.MM_p)d.MM_p=new Array();var i,j=d.MM_p.length;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 SwapImagesThick(str){document.getElementById('bigImg').innerHTML=str;document.getElementById('galleryVideo').style.display="none";document.getElementById('bigImg').style.display="block";tb_init('a.thickbox, area.thickbox, input.thickbox');}
function CountTextLeft(myForm,field,count){if(typeof myForm.no_words=='undefined')return;var text=field.value+" ";var no_words=myForm.no_words.value;if(no_words>0)
{var counter,i,cutPos;counter=0;for(i=0;i<text.length;i++){while(text.charAt(i)==' '||text.charAt(i)=='\n'||text.charAt(i)==','||text.charAt(i)=='.')i++;if((text.charAt(i+1)==' '||text.charAt(i+1)=='\n'||text.charAt(i+1)==','||text.charAt(i+1)=='.'||text.charCodeAt(i+1)>255||i==text.length-1)&&text.charCodeAt(i)<=255)counter++;if(text.charCodeAt(i)>255){if(i>0&&text.charAt(i-1)!=' '||text.charAt(i-1)!='\n'||text.charAt(i-1)!=','||text.charAt(i-1)!='.')
counter++;}
if(counter==no_words)cutPos=i;}
words_left=no_words-counter;if(words_left<0){text=text.substring(0,cutPos);field.value=text;words_left=0;}
count.value=words_left;}}
function strchlen(str){var counter,i;counter=0;for(i=0;i<str.length;i++){if(str.charCodeAt(i)>255){counter++;}}
return counter;}
function strenlen(str){var counter,i;counter=0;for(i=0;i<str.length;i++){while(str.charAt(i)==' '||str.charCodeAt(i)>255||str.charAt(i)=='\n')i++;if(str.charAt(i+1)==' '||str.charAt(i+1)=='\n'||str.charCodeAt(i+1)>255||i==str.length-1)counter++;}
return counter;}
function clickBanner(id,url){url_str="include/get_info.php?type=banner&id="+id;var xmlhttp=getxmlhttp();xmlhttp.open("GET",url_str);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4&&xmlhttp.status==200){location.reload(false);}}
window.location.href=url;}
function onDelete(id,str,obj_type)
{if(myConfirm(str)==false)return;var url_str="include/actions.php?action=delete&object="+obj_type+"&id="+id;xmlhttp=getxmlhttp();xmlhttp.open("GET",url_str);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4&&xmlhttp.status==200){location.reload(true);}}
xmlhttp.send(null);}
function onSold(id,obj_type){var url_str="include/actions.php?action=sold&object="+obj_type+"&id="+id;var xmlhttp=getxmlhttp();xmlhttp.open("GET",url_str);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4&&xmlhttp.status==200){location.reload(true);}}
xmlhttp.send(null);}
function onUnsold(id,obj_type){var url_str="include/actions.php?action=unsold&object="+obj_type+"&id="+id;var xmlhttp=getxmlhttp();xmlhttp.open("GET",url_str);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4&&xmlhttp.status==200){location.reload(true);}}
xmlhttp.send(null);}
function onRented(id,obj_type){var url_str="include/actions.php?action=rented&object="+obj_type+"&id="+id;var xmlhttp=getxmlhttp();xmlhttp.open("GET",url_str);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4&&xmlhttp.status==200){location.reload(true);}}
xmlhttp.send(null);}
function onUnrented(id,obj_type){var url_str="include/actions.php?action=unrented&object="+obj_type+"&id="+id;var xmlhttp=getxmlhttp();xmlhttp.open("GET",url_str);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4&&xmlhttp.status==200){location.reload(true);}}
xmlhttp.send(null);}
function add_to_fav(id,confirm_str,done_str,site_url){if(confirm_str!=""&&myConfirm(confirm_str)==false)return;var url_str=site_url+"/include/actions.php?action=favourite&object=listing&id="+id;var xmlhttp=getxmlhttp();xmlhttp.open("GET",url_str);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4&&xmlhttp.status==200){alert(done_str);location.reload(true);}}
xmlhttp.send(null);}
function checkOther(elem,val){var selected_index=elem.selectedIndex;var selected_val=elem.options[selected_index].value;if(selected_val=="-1")
document.getElementById("span_"+val+"_other_val").style.display="block";else
document.getElementById("span_"+val+"_other_val").style.display="none";}
function selDepending(field_no,caption1,caption2,dep_id,categ_id,other_val,other_str){var selected_index=document.getElementById(caption1).selectedIndex;var sel_value=document.getElementById(caption1).options[selected_index].value;if(other_val){if(sel_value=="-1"){document.getElementById("span_"+caption1+"_other_val").style.display="block";document.getElementById("span_"+caption2+"_other_val").style.display="block";document.getElementById(caption2).disabled=false;document.getElementById(caption2).options.length=1;document.getElementById(caption2).options[1]=new Option(other_str,"-1");document.getElementById(caption2).selectedIndex=1;}else{document.getElementById("span_"+caption1+"_other_val").style.display="none";document.getElementById("span_"+caption2+"_other_val").style.display="none";}}
document.getElementById(caption2).disabled=false;url_str="include/get_info.php?type=depending&field="+dep_id+"&dep="+sel_value+"&field_no="+field_no+"&cat="+categ_id;var xmlhttp=getxmlhttp();xmlhttp.open("GET",url_str);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4&&xmlhttp.status==200){var dep_str=xmlhttp.responseText;var split_dep=dep_str.split(":");var no=split_dep.length;document.getElementById(caption2).options.length=0;var depIndex=0;document.getElementById(caption2).options[depIndex]=new Option(split_dep[0],"");depIndex++;if(other_val){document.getElementById(caption2).options[depIndex]=new Option(other_str,"-1");if(sel_value==-1)document.getElementById(caption2).selectedIndex=1;depIndex++;}
for(var j=5;j<no;j++){split_d=split_dep[j].split(',');var dep_id=split_d[0];var dep_name=split_d[1];document.getElementById(caption2).options[depIndex]=new Option(dep_name,dep_name);depIndex++;}
var next_caption1=split_dep[1];var next_caption2=split_dep[2];var next_top_str1=split_dep[3];var next_top_str2=split_dep[4];if(next_caption1){document.getElementById(next_caption1).options.length=0;document.getElementById(next_caption1).options[0]=new Option(next_top_str1,"");document.getElementById(next_caption1).disabled=true;if(other_val){if(sel_value=="-1"){document.getElementById("span_"+next_caption1+"_other_val").style.display="block";document.getElementById(next_caption1).disabled=false;document.getElementById(next_caption1).options.length=1;document.getElementById(next_caption1).options[1]=new Option(other_str,"-1");document.getElementById(next_caption1).selectedIndex=1;}else{document.getElementById("span_"+next_caption1+"_other_val").style.display="none";}}}
if(next_caption2){document.getElementById(next_caption2).options.length=0;document.getElementById(next_caption2).options[0]=new Option(next_top_str2,"");document.getElementById(next_caption2).disabled=true;if(other_val){if(sel_value=="-1"){document.getElementById("span_"+next_caption2+"_other_val").style.display="block";document.getElementById(next_caption2).disabled=false;document.getElementById(next_caption2).options.length=1;document.getElementById(next_caption2).options[1]=new Option(other_str,"-1");document.getElementById(next_caption2).selectedIndex=1;}else{document.getElementById("span_"+next_caption2+"_other_val").style.display="none";}}}}}
xmlhttp.send(null);}
function oldDepending(field_no,caption1,caption2,dep_id,sec_val,other_val,other_str){var selected_index=document.getElementById(caption1).selectedIndex;var id=document.getElementById(caption1).options[selected_index].value;if(other_val){if(id=="-1"){document.getElementById("span_"+caption1+"_other_val").style.display="block";document.getElementById("span_"+caption2+"_other_val").style.display="block";document.getElementById(caption2).disabled=false;document.getElementById(caption2).options.length=1;document.getElementById(caption2).options[1]=new Option(other_str,"-1");document.getElementById(caption2).selectedIndex=1;return;}else{document.getElementById("span_"+caption1+"_other_val").style.display="none";document.getElementById("span_"+caption2+"_other_val").style.display="none";}}
document.getElementById(caption2).disabled=false;url_str="include/get_info.php?type=depending&field="+dep_id+"&field_no="+field_no+"&dep="+id;var xmlhttp=getxmlhttp();xmlhttp.open("GET",url_str,false);xmlhttp.send(null);var dep_str=xmlhttp.responseText;var split_dep=dep_str.split(":");var no=split_dep.length;document.getElementById(caption2).options.length=0;var depIndex=0;document.getElementById(caption2).options[depIndex]=new Option(split_dep[0],"");depIndex++;if(other_val){document.getElementById(caption2).options[depIndex]=new Option(other_str,"-1");depIndex++;}
var found=0;for(var j=5;j<no;j++){split_d=split_dep[j].split(',');var dep_id=split_d[0];var dep_name=split_d[1];document.getElementById(caption2).options[depIndex]=new Option(dep_name,dep_name);if(sec_val==dep_name){document.getElementById(caption2).selectedIndex=depIndex;found=1;}
depIndex++;}
if(!found&&sec_val&&other_val){document.getElementById(caption2).selectedIndex=1;document.getElementById("span_"+caption2+"_other_val").style.display="block";document.getElementById(caption2+"_other_val").value=sec_val;}}
function adjustTotal(myForm,price,field,no_decimals){var total=myForm.full_total.value;if(field.checked==true){total=parseFloat(total)+parseFloat(price);}else{total=parseFloat(total)-parseFloat(price);}
myForm.full_total.value=total.toFixed(no_decimals);document.getElementById("total").innerHTML=total.toFixed(no_decimals);getDiscount(myForm,"ads",0);}
function changePriority(myForm,val){var total=myForm.full_total.value;var prev=myForm.pri.value;if(!prev)prev=0;if(!val)val=0;total=parseFloat(total)+parseFloat(val);total=parseFloat(total)-parseFloat(prev);myForm.pri.value=val;myForm.full_total.value=total;document.getElementById("total").innerHTML=total;getDiscount(myForm,"ads",0);}
function getDiscount(myForm,type,hide_processors){if(typeof myForm.discount_code=='undefined')return;var total=myForm.full_total.value;if(!total)return;var code=myForm.discount_code.value;url_str="include/get_info.php?type=discount&id="+code+"&dtype="+type+"&amount="+total;var xmlhttp=getxmlhttp();xmlhttp.open("GET",url_str);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4&&xmlhttp.status==200){var new_total=xmlhttp.responseText;if(new_total==-1)new_total=total;document.getElementById("total").innerHTML=new_total;if(hide_processors){if(new_total==0)document.getElementById("processors").style.display="none";else document.getElementById("processors").style.display="block";}}}
xmlhttp.send(null);}
function onChangePlan(myForm){var i;var selected_plan;if(typeof myForm.package.length=="number"){var radioLength=myForm.package.length;for(i=0;i<radioLength;i++){if(myForm.package[i].checked)selected_plan=myForm.package[i].value;}}
else selected_plan=document.getElementById("package").value;if(!selected_plan)return;url_str="include/get_info.php?type=sub_price&id="+selected_plan;var xmlhttp=getxmlhttp();xmlhttp.open("GET",url_str);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4&&xmlhttp.status==200){var ret_str=xmlhttp.responseText;var amount=parseFloat(ret_str);myForm.full_total.value=amount;document.getElementById("total").innerHTML=amount;getDiscount(myForm,"ads");}}
xmlhttp.send(null);}
function radioSelected(){var search=document.searchFolderContents.search
var radioLength=(typeof search.length=="number")?(search.length):1;}
function reloadDep(str){var selected_index=document.getElementById('category').selectedIndex;var cat=document.getElementById('category').options[selected_index].value;url_str="include/get_info.php?type=reload_depending&str="+str+"&cat="+cat;var xmlhttp=getxmlhttp();xmlhttp.open("GET",url_str);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4&&xmlhttp.status==200){var dep_str=xmlhttp.responseText;if(!dep_str)return;var split_dep=dep_str.split("^");var no_fields=split_dep.length;for(var idx=0;idx<no_fields;idx++){var vals=split_dep[idx].split(",");var no=vals.length;caption=vals[0];top_str=vals[1];caption2=vals[2];top_str2=vals[3];document.getElementById(caption).disabled=false;document.getElementById(caption).options.length=0;var depIndex=0;document.getElementById(caption).options[depIndex]=new Option(top_str,"");depIndex++;document.getElementById(caption2).options.length=0;document.getElementById(caption2).options[0]=new Option(top_str2,"");document.getElementById(caption2).disabled=true;if(no<=4){document.getElementById(caption).disabled=true;continue;}
for(var j=4;j<no;j++){document.getElementById(caption).options[depIndex]=new Option(vals[j],vals[j]);depIndex++;}}}}
xmlhttp.send(null);}
function checkAll(doc){var c=new Array();c=doc.getElementsByTagName('input');for(var i=0;i<c.length;i++)
{if(c[i].type=='checkbox')
{c[i].checked=true;}}}
function uncheckAll(doc)
{var c=new Array();c=doc.getElementsByTagName('input');for(var i=0;i<c.length;i++)
{if(c[i].type=='checkbox')
{c[i].checked=false;}}}
function checkDeleteData(field_vis,field){if(document.getElementById(field_vis).value=='')document.getElementById(field).value='';return 1;}
function onDeleteAlert(id){url_str="include/actions.php?object=alert&action=delete&id="+id;var xmlhttp=getxmlhttp();xmlhttp.open("GET",url_str);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4&&xmlhttp.status==200){location.reload(true);}}
xmlhttp.send(null);}
function onDeleteSavedSearch(id){url_str="include/actions.php?object=search&action=delete&id="+id;var xmlhttp=getxmlhttp();xmlhttp.open("GET",url_str);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4&&xmlhttp.status==200){location.reload(true);}}
xmlhttp.send(null);}
function onChangeLocation(id,table){url_str="include/get_info.php?type=browse_location&table="+table+"&id="+id;var xmlhttp=getxmlhttp();xmlhttp.open("GET",url_str);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4&&xmlhttp.status==200){var result=xmlhttp.responseText;var split_dep=result.split(",");var no_fields=split_dep.length;var tab;var location_div;for(var idx=0;idx<no_fields;idx++){tab="location_tab"+split_dep[idx];location_div="loc1_"+split_dep[idx];if(id==split_dep[idx]){document.getElementById(tab).className="active";document.getElementById(location_div).style.display="block";}else{document.getElementById(tab).className="";document.getElementById(location_div).style.display="none";}}}}
xmlhttp.send(null);}
function onChangeMake(id,table){url_str="include/get_info.php?type=browse_make&table="+table+"&id="+id;var xmlhttp=getxmlhttp();xmlhttp.open("GET",url_str);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4&&xmlhttp.status==200){var result=xmlhttp.responseText;var split_dep=result.split(",");var no_fields=split_dep.length;var tab;var make_div;for(var idx=0;idx<no_fields;idx++){tab="make_tab"+split_dep[idx];make_div="make1_"+split_dep[idx];if(id==split_dep[idx]){document.getElementById(tab).className="active";document.getElementById(make_div).style.display="block";}else{document.getElementById(tab).className="";document.getElementById(make_div).style.display="none";}}}}
xmlhttp.send(null);}
function onQuickSearch(myForm){var selected_index=myForm.category.selectedIndex;var selected_val=myForm.category.options[selected_index].value;var split_str=selected_val.split(",");id=split_str[0];url_str="include/get_info.php?type=quick-search&id="+id;var xmlhttp=getxmlhttp();xmlhttp.open("GET",url_str,true);xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4&&xmlhttp.status==200){var str=xmlhttp.responseText;if(str!='0'){var split_str=str.split(",");var no=split_str.length;for(f=0;f<no;f++){div_spec=split_str[f];var split_spec=div_spec.split("=");var field_name=split_spec[0];if(document.getElementById(field_name)!=null){if(split_spec[1]==1){$("#"+field_name).fadeIn();}
else
$("#"+field_name).fadeOut();}}}}}
xmlhttp.send(null);}
