function tagClass(_1,_2,_3,_4){
this.id="p"+Math.floor(Math.random()*100000000);
this.root_url=_2;
this.stars_obj=_3;
this.ajax=null;
this.address_obj=null;
this.el_id="";
this.div_id="";
this.message_div_id="";
this.edit_mode=false;
this.route_id=_4;
this.open_dialog=function(_5,_6,_7,_8,_9,_a,_b){
this.address_obj=_6;
this.el_id=_5;
this.div_id=_7;
this.message_div_id=_8;
this.cats_data=_9;
this.edit_mode=this.div_id.search(/_edit$/i)!=-1?true:false;
this.star_div_prefix=_b==undefined?"star_":_b;
var _c=document.getElementById(_7).innerHTML;
_c=_c.replace(/^[\r\n\t ]*<!\-\-|\-\->[\r\n\t ]*$/g,"");
var _d=new Array();
_d["init_rating"]=_a;
_d["biz_name"]=_6.biz_name;
var _e="";
if(!this.edit_mode){
if(_6.cat1!=""){
_e+=this.html_lify(_6.cat1);
if(_6.sub_cat1!=""){
_e+="&nbsp;&raquo;&nbsp;"+this.html_lify(_6.sub_cat1);
}
}
if(_6.cat2!=""){
if(_e!=""){
_e+="<br>";
}
_e+=this.html_lify(_6.cat2);
if(_6.sub_cat2!=""){
_e+="&nbsp;&raquo;&nbsp;"+this.html_lify(_6.sub_cat2);
}
}
}
_d["cats"]=_e;
_c=_c.replace(/%([_A-Z0-9]+)/gi,function(_f,p1){
return _d[p1];
});
this.popup(_5,_c);
this.stars_obj.init_div(document.getElementById("star_"+_7));
document.getElementById(_7+(this.edit_mode?"_biz_name":"_tags")).focus();
if(this.edit_mode){
this.update_cat(_6.cat1);
this.update_sub_cat(_6.cat1,_6.sub_cat1);
}
};
this.popup=function(_11,_12){
this.close_dialog();
var pos=this.calc_dialog_pos(_11);
var div=document.createElement("DIV");
div.id=this.id;
div.style.position="absolute";
div.style.zIndex=99998;
div.style.display="block";
div.style.left=pos.x+"px";
div.style.top=pos.y+"px";
div.innerHTML=_12;
document.body.appendChild(div);
this.trim_dialog_pos(div);
if(navigator&&navigator.appVersion&&navigator.appVersion.search(/msie +6\./i)!=-1){
var ifr=document.createElement("IFRAME");
ifr.id=this.id+"_iframe";
ifr.scrolling="no";
ifr.style.zIndex=99997;
ifr.style.filter="alpha(opacity=0)";
ifr.style.position="absolute";
ifr.style.border="0";
ifr.style.top=div.offsetTop+"px";
ifr.style.left=div.offsetLeft+"px";
ifr.style.height=div.offsetHeight+2+"px";
ifr.style.width=div.offsetWidth+2+"px";
ifr.style.display="block";
document.body.appendChild(ifr);
}
};
this.update_cat=function(_16){
var cat=document.forms[this.div_id+"_form"].cat1;
cat.options.length=0;
cat.options[cat.options.length]=new Option("SELECT CATEGORY","",_16!=""?false:true,_16!=""?false:true);
for(var k in this.cats_data){
cat.options[cat.options.length]=new Option(k,k,k==_16?true:false,k==_16?true:false);
}
};
this.update_sub_cat=function(cat,_1a){
var _1b=document.forms[this.div_id+"_form"].sub_cat1;
_1b.options.length=0;
if(this.cats_data[cat]==undefined){
return;
}
var _1c=this.cats_data[cat];
_1b.options[_1b.options.length]=new Option("SELECT SUB-CATEGORY","",_1a!=""?false:true,_1a!=""?false:true);
for(var i in _1c){
k=_1c[i];
_1b.options[_1b.options.length]=new Option(k,k,k==_1a?true:false,k==_1a?true:false);
}
};
this.submit=function(){
var f=document.forms[this.div_id+"_form"];
var _1f=this.edit_mode?f.biz_name.value:"";
var cat=this.edit_mode?f.cat1.value:"";
var _21=this.edit_mode?f.sub_cat1.value:"";
if(this.edit_mode&&_1f.search(/[^\r\n\t ]/)==-1){
return this.show_error("please enter name");
}
if(this.edit_mode&&cat==""){
return this.show_error("please select category");
}
if(this.edit_mode&&_21==""){
return this.show_error("please select sub-category");
}
div=document.getElementById("star_"+this.div_id);
var _22=parseFloat(document.getElementById("star_"+this.div_id).title);
if(_22<0){
return this.show_error("please select the stars");
}
var _23="action="+(this.edit_mode?"tag_edit":"tag")+"&location_id="+this.address_obj.location_id+"&rating="+escape(_22)+"&comments="+escape(f.comments.value)+"&tags="+escape(f.tags.value);
if(this.edit_mode){
_23+="&biz_name="+escape(_1f)+"&cat="+escape(cat)+"&sub_cat="+escape(_21)+"&xy="+escape(this.address_obj.xy)+"&city="+this.address_obj.city+"&county="+this.address_obj.county+"&address="+this.address_obj.address+"&zip="+escape(this.address_obj.zip);
}
if(this.ajax==null){
this.ajax=new ajaxClass();
}
this_obj=this;
this.show_error("");
this.ajax.request("POST",this.root_url+"/facebook/index.php",_23,this.div_id+"_message",true,function(_24){
var _25=_24.split("\t");
if(_25.length<3||_25[2]!="end"){
return this_obj.show_error("http error");
}
_25[1]=unescape(_25[1]);
if(_25[0]!=1){
return this_obj.show_error(_25[1]!=""?_25[1]:"unknown error");
}
_25=_25[1].split(",");
if(this_obj.edit_mode){
var _26=_25[0];
var _27=_25[1];
var _28=_25[2];
var _29=_25[3];
this_obj.show_message("Thank you!<br><br><br><a href=\"http://apps.facebook.com/hopstop/?action=assign_fb_uid_to_yp_member&member_id="+_26+"&location_id="+_27+"&anonymous_uid="+_28+"&password="+_29+"&route_id="+this_obj.route_id+"\">&nbsp;&nbsp;</a>");
}else{
var _28=_25[2];
var _29=_25[3];
this_obj.show_message("Thank you!<br><br><br><a href=\"http://apps.facebook.com/hopstop/?action=assign_fb_uid&location_id="+this_obj.address_obj.location_id+"&anonymous_uid="+_28+"&password="+_29+"&route_id="+this_obj.route_id+"\">&nbsp;&nbsp;</a>");
}
});
if(star_div=document.getElementById(this.star_div_prefix+this.address_obj.location_id)){
star_div.title=_22;
this.stars_obj.init_div(star_div);
}
};
this.show_error=function(_2a){
document.getElementById(this.div_id+"_error").innerHTML=_2a;
return true;
};
this.show_message=function(_2b){
var _2c=document.getElementById(this_obj.message_div_id).innerHTML;
_2c=_2c.replace(/^[\r\n\t ]*<!\-\-|\-\->[\r\n\t ]*$/g,"");
_2c=_2c.replace(/%message/gi,_2b);
this_obj.popup(this_obj.el_id,_2c);
};
this.close_dialog=function(){
if(div=document.getElementById(this.id)){
document.body.removeChild(div);
}
if(div=document.getElementById(this.id+"_iframe")){
document.body.removeChild(div);
}
};
this.calc_dialog_pos=function(_2d){
var pos=this.element_pos(_2d);
pos.y+=19;
return pos;
};
this.trim_dialog_pos=function(el){
if(!el){
return;
}
var x=el.offsetLeft;
var y=el.offsetTop;
var w=el.offsetWidth;
var h=el.offsetHeight;
var _34=this.window_size();
var _35=this.window_scroll_pos();
var _36=_34.h+_35.y;
var _37=_34.w+_35.x;
if(_36>h&&y+h>_36){
y=_36-h;
}
if(_37>w&&x+w>_37){
x=_37-w;
}
if(x<_35.x){
x=_35.x;
}
if(y<_35.y){
y=_35.y;
}
if(el.style.left!=x||el.style.top!=y){
if(_37-x-w<8){
x-=this.get_scroll_bar_width();
}
el.style.left=x+"px";
el.style.top=y+"px";
}
};
this.element_pos=function(_38){
var pos={x:0,y:0};
if(obj=document.getElementById(_38)){
if(obj.offsetParent){
pos.x=obj.offsetLeft;
pos.y=obj.offsetTop;
while(obj=obj.offsetParent){
pos.x+=obj.offsetLeft;
pos.y+=obj.offsetTop;
}
}
}
return pos;
};
this.window_size=function(){
var _3a={w:0,h:0};
if(typeof (window.innerWidth)=="number"){
_3a.w=window.innerWidth;
_3a.h=window.innerHeight;
}else{
if(document.documentElement&&(document.documentElement.clientWidth||document.documentElement.clientHeight)){
_3a.w=document.documentElement.clientWidth;
_3a.h=document.documentElement.clientHeight;
}else{
if(document.body&&(document.body.clientWidth||document.body.clientHeight)){
_3a.w=document.body.clientWidth;
_3a.h=document.body.clientHeight;
}
}
}
return _3a;
};
this.window_scroll_pos=function(){
var pos={x:0,y:0};
if(typeof (window.pageYOffset)=="number"){
pos.y=window.pageYOffset;
pos.x=window.pageXOffset;
}else{
if(document.body&&(document.body.scrollLeft||document.body.scrollTop)){
pos.y=document.body.scrollTop;
pos.x=document.body.scrollLeft;
}else{
if(document.documentElement&&(document.documentElement.scrollLeft||document.documentElement.scrollTop)){
pos.y=document.documentElement.scrollTop;
pos.x=document.documentElement.scrollLeft;
}
}
}
return pos;
};
this.get_scroll_bar_width=function(){
var _3c=document.createElement("p");
_3c.style.width="100%";
_3c.style.height="200px";
var _3d=document.createElement("div");
_3d.style.position="absolute";
_3d.style.top="0px";
_3d.style.left="0px";
_3d.style.visibility="hidden";
_3d.style.width="200px";
_3d.style.height="150px";
_3d.style.overflow="hidden";
_3d.appendChild(_3c);
document.body.appendChild(_3d);
var w1=_3c.offsetWidth;
_3d.style.overflow="scroll";
var w2=_3c.offsetWidth;
if(w1==w2){
w2=_3d.clientWidth;
}
document.body.removeChild(_3d);
return (w1-w2);
};
this.html_lify=function(str){
return str.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
};
};

