// Global Vars
var av_ref;
var site_id;
var performers;
var online_performers;
var att = null;
var vctp_url = "http://aff-jp.dxlive.com";
// ** 

Attribute=function (id,name,default_value_id,att_type,type_info,eng_name) {
 this.id=id;
 this.name=name;
 this.default_value_id=default_value_id;
 this.att_type=att_type;
 this.type_info=type_info; 
 this.eng_name = eng_name;
}

User=function () {
  var show_icon = 'regular';
	var user_name;
  var user_id; 
  var site_id;
  var user_type;
	var pass; 
}

User.prototype.writeEditableAttributes = function(att_list) {
  document.write('<table cellpadding="0" cellspacing="3" border="0">');
  if(!att_list) return;
  for( var key in att_list) {
		if(att_list[key] == "show_icon") {
			document.write("<input type=hidden name='att_id' value='115'>");
			document.write("<input type=hidden name='value_115' value=''>");
			document.write("<select name='val_id_115'><option value='1'>Regular</option><option value='0'");
			if(this.show_icon=='vip') document.write(" SELECTED");
			document.write(">VIP</option></select>");
    }
}}

function get_user() {
  if(active_user != null)
	  return active_user;
	else
		return new User();
}

Attribute.prototype.getEditableHtml = function(value_id_ar, type_info) {
	var val_ar = value_id_ar;
	var att_id = this.id;
	var ref = av_ref;
	var retStr = "";
  var this_type_info = type_info;

if(!val_ar || val_ar == null) {	val_ar = new Array(0);	}

	if(!this_type_info)
		this_type_info = this.type_info;
  if(this.att_type != 'IMAGE_FILE')
      retStr += ("<input type=hidden name='att_id' value='"+att_id+"'>");
  if (this.att_type == 'SELECT' || this.att_type == 'RATE') {
      var multiple = eval(unpackTypeInfo(this_type_info,0,'false'));
      var size = unpackTypeInfo(this_type_info,1,'1');
			var pref_txt = unpackTypeInfo(this_type_info,2,null);
			var pref_val = unpackTypeInfo(this_type_info,3,'');
      retStr += ("<input type=hidden name='value_"+att_id+"' value=''>");
 
      retStr += ("<select name='val_id_"+att_id+"' "+ ((size > 1)?"size="+size+" ":"")+ ((multiple)?"MULTIPLE":"")+">");
			if(pref_txt) 
				retStr += "<option value='"+pref_val+"'>"+pref_txt+"</option>";
      var all_vals = ref.getAllAttributeValues(att_id);

      var val_st = ":"+val_ar.join(":")+":";
      for(var i in all_vals) {
        var selected = (val_st.indexOf(":"+i+":") > -1);
        var t = "<option value='"+(i)+"' "+(selected?"SELECTED":"")+">"+(all_vals[i])+"</option>";
        retStr += (t);
      }

      retStr += ("</select>");
    }
    if (this.att_type == 'TEXTAREA') {
      var rows = unpackTypeInfo(this_type_info,0,'3');
      var cols = unpackTypeInfo(this_type_info,1,'30');

      retStr += ("<input type=hidden name='val_id_"+att_id+"' value='"+val_ar[0]+"'>");
      retStr += ("<textarea cols='"+cols+"' rows='"+rows+"' name='value_"+att_id+"'>"+ref.getValue(att_id,val_ar[0])+"</textarea>");
    } if (this.att_type == 'TEXT') {
      var size = unpackTypeInfo(this_type_info,0,'20');
      retStr += ("<input type=text size="+size+" name='value_"+att_id+"' value='"+ref.getValue(att_id,val_ar[0])+"'>");
      retStr += ("<input type=hidden name='val_id_"+att_id+"' value='"+val_ar[0]+"'>");
    } if (this.att_type == 'SKIN_SELECT') {
      retStr += ("<Table><tr>");
      var count = 0;
      var all_vals = ref.getAllAttributeValues(att_id);
      for(var i in all_vals) {
        if(count == 3) {
          retStr += ('</tr><tr>');
         count = 0;
        }
        var selected = "";
        if(i == val_ar[0]) selected = " CHECKED";
        var tt = all_vals[i];
        retStr += ('<TD><IMG src="/performers/skin_thumbs/thumb_'+ tt.substring(0,tt.indexOf(".")) +'.jpg"><br>');
        retStr += ('<INPUT type="radio" name="val_id_'+att_id+'" value="'+i+'" '+selected+'></TD>');
        count++;
      }
      retStr += ("</tr></table>");
    } if (this.att_type == 'IMAGE_FILE') {
      retStr += ("<IMG src='"+ref.getValue(att_id,val_ar[0])+"'>");
    } if (this.att_type == 'FILE') {
      var size = '60';
      retStr += ("<input type=text name='value_"+att_id+"' size="+size+" value='"+ref.getValue(att_id,val_ar[0])+"'>");
      retStr += ("<input type=hidden name='val_id_"+att_id+"' value='"+val_ar[0]+"'>");
    }
	return retStr;
}

AttributeValueRef=function () {
 this.att=new Object();
 this.val=new Object();
 this.attRev=new Object();
}
AttributeValueRef.prototype.addAttribute=function (attribute_id, attribute) {
 this.att[attribute_id] = attribute;
 this.attRev[attribute.eng_name.toUpperCase()] = attribute_id;
}
AttributeValueRef.prototype.A=function (attribute_id, attribute) { this.addAttribute(attribute_id, attribute); }
AttributeValueRef.prototype.addValue=function (attribute_id, value_id, value) {
 if(!this.val[attribute_id]) this.val[attribute_id] = new Array;
 this.val[attribute_id][value_id] = value;
}
AttributeValueRef.prototype.V=function (attribute_id, value_id, value) { this.addValue(attribute_id, value_id, value); }
AttributeValueRef.prototype.getAttribute=function (attribute_id) {
 return this.att[attribute_id];
}
AttributeValueRef.prototype.getAttributeIdByName=function(attribute_name) {
 return this.attRev[attribute_name.toUpperCase()];
}
AttributeValueRef.prototype.getValue=function (attribute_id, value_id) {
 if(!this.val[attribute_id] || !this.val[attribute_id][value_id])
	return "";
 return this.val[attribute_id][value_id];
}
AttributeValueRef.prototype.getAllAttributeValues=function (attribute_id) {
 return this.val[attribute_id];
}

av_ref = new AttributeValueRef();

PerformerAttributes=function (attribute_value_map) {
  this.ref = av_ref; // reference to global AttributeValueRef obj 
  this.map = new Object(); // maps attribute_id to array of value_ids
}

ValueList=function(attribute_id,value_id_array) {
	this.att_id = attribute_id;
	this.values = this.filter(av_ref,attribute_id,value_id_array);
	this.val_ids = value_id_array;
}
ValueList.prototype.toString= function() {if(this.values[0]) return this.values[0]; return "";}
ValueList.prototype.filter= function(attValRef,att_id,val_id_ar) {
	var ret = new Array;
	for(var i = 0; i < val_id_ar.length; i++) { ret[i]=attValRef.getValue(att_id,val_id_ar[i]); }
	return ret;
}

Photo=function(photo) { this.photo=photo; }

Performer=function (username, user_id, reg_date) {
 this.username=username;
 this.user_id=user_id;
 this.photos=new Array;
 this.atts=new PerformerAttributes (av_ref); 
 this.lang = false;
 this.reg_date = new Date(reg_date);
 this.viewers = 0;
 this.site_id = 0;
 // for optimizations (DSL 8.12.04)
 this.vals = new Array;
}

// Add attribute values to a performer
// NOTE: this sets multiple values for the same att to a comma separated list
Performer.prototype.addAtt=function(attName,attValue) {
  var val = "";
  if(this.vals[attName] != null)
        val = this.vals[attName] + ",";
  this.vals[attName] = val + attValue;
}
Performer.prototype.getAtt=function(attName) {

var ret = this.vals[attName];
if(ret == null || ret == 'undefined') {
	if(attName == 'skin') ret = "skin01.swf";
	ret = "";
}
  return ret;
}


Performer.prototype.toString=function () { return this.username; }
Performer.prototype.addPhoto=function (photo) { this.photos[this.photos.length]=photo; }
Performer.prototype.getPhotos=function () { return this.photos; }
Performer.prototype.getUserId = function() { return this.user_id; }
Performer.prototype.a=function (attribute_id,value_id) { this.addAttributeValue(attribute_id,value_id); }
Performer.prototype.addAttributeValue=function (attribute_id,value_id) {
 with(this.atts) { 
  if(!map[attribute_id]) {
  map[attribute_id] = new Array;
   map[attribute_id][0]=value_id;
 }
  else
   map[attribute_id][map[attribute_id].length]=value_id;
 }
}
Performer.prototype.getAttValueByAttName=function(attribute_name) {
 if(attribute_name == 'live_thumbnail') {
  return '/WebArchive/'+this.username+'/thumbs/LinkedImage.jpg';
  var file = this.getAttValueByAttName('image');
  var folder = this.username;
  if(file == 'DefaultImage.jpg') {
    folder  = 'default';
    file = 'Image.jpg';
  }

  return '/WebArchive/'+folder+'/thumbs/'+file;
 } if(attribute_name == 'picture') {
  return '/WebArchive/'+this.username+'/flash/LinkedImage.jpg';
  var file = this.getAttValueByAttName('image');
  var folder = this.username;
  if(file == 'DefaultImage.jpg') {
    folder  = 'default';
    file = 'Image.jpg';
  }
  return '/WebArchive/'+folder+'/flash/'+file;
 } if(attribute_name == 'snapshot') {
  return '/WebArchive/'+this.username+'/live/LinkedImage.jpg';
  var file = this.getAttValueByAttName('image');
  var folder = this.username;
  if(file == 'DefaultImage.jpg') {
    folder  = 'default';
    file = 'Image.jpg';
  }
  return '/WebArchive/'+folder+'/live/'+file;
 } if(attribute_name == 'vctp_thumbnail') {
  return '/WebArchive/'+this.username+'/vctp/LinkedImage.jpg';
  var file = this.getAttValueByAttName('image');
  var folder = this.username;
  if(file == 'DefaultImage.jpg') {
    folder  = 'default';
    file = 'Image.jpg';
  }
  return '/WebArchive/'+folder+'/vctp/'+file;
 }

 with(this.atts) {
  var att_id = ref.attRev[attribute_name.toUpperCase()];
		if(!att_id) {
			return "";	
		}
  var val_ids = new Array;
  if(!map[att_id] || !map[att_id][0]) {
   if(ref.getAttribute(att_id) && ref.getAttribute(att_id).default_value_id) {
     val_ids[0] = ref.getAttribute(att_id).default_value_id;
   } else {
     val_ids[0] = 0;
   }
  }
  else
   val_ids = map[att_id];
	var ret = new ValueList(att_id,val_ids);
  if(!ret)
   ret = "";
  return ret;
 }
}
Performer.prototype.getAttributeValue=function(att_id) {
 with(this.atts) {
  var val_ids = new Array;
  if(!map[att_id] || !map[att_id][0])
   val_ids[0] = ref.getAttribute(att_id).default_value_id;
  else
   val_ids = map[att_id];
	var ret = new ValueList(att_id,val_ids);
  if(!ret)
   ret = "";
  return ret;
 }
}

Performer.prototype.getAttributeValueId=function(att_id) {
 with(this.atts) {
  var val_ids = new Array;
  if(!map[att_id] || !map[att_id][0])
   val_ids[0] = ref.getAttribute(att_id).default_value_id;
  else
   val_ids = map[att_id];
  return val_ids;
 }
}


Performers=function () {
 this.performers=new Array; 
 this.length = 0;
 this.lang = false;
 this.icons = false;
 this.view_count = false;
}
performers = new Performers();
online_performers=new Performers;

Performers.prototype.add=function (performer) {
 this.length++;
 this.performers[performer.username]=performer;
}
Performers.prototype.count=function () { document.write(this.length); }
Performers.prototype.getPerformer=function (username) {
 return this.performers[username]; }
Performer.prototype.writeAttribute=function (attribute) {
 document.write(this.getAttValueByAttName(attribute)); 
}
Performer.prototype.writeImageAttribute=function (attribute_name, width, height, alt) {
 var attribute=this.getAttValueByAttName(attribute_name);
 if (attribute!=null) document.write('<IMG src="http://aff-images.dxlive.com'+attribute+'" width="'+width+'" height="'+height+'" alt="'+alt+'" border="0">'); }

function getEditableHtml(att_name,type_info) {
	var att = av_ref.getAttribute(av_ref.getAttributeIdByName(att_name));
	if(att == null) return "";
	return att.getEditableHtml(null,type_info);
}

function unpackTypeInfo(str, count, default_val) {
  if(!str)
    return default_val;
  var ar = str.split(':');
  if (!ar || ar.length < count)
    return default_val;
  return ar[count];
}

Performer.prototype.writeAttributes=function(att_list) {
 with(this.atts) {
  document.write('<table cellpadding="0" cellspacing="3" border="0" width="100%">');
	var joined;
	if(!att_list) return;
	for( var key in att_list) {
	  var att_id = ref.getAttributeIdByName(att_list[key]);
		var att = ref.getAttribute(att_id);
		if(!att) continue;
	  document.write('<tr valign="top"><td valign="top" width="10%" nowrap>a. </td><td class="font01" width="10%" nowrap>'+att.name+'</td>');
    document.write('<td nowrap width="5%" class="font01">:</td>');
    document.write('<td width="85%" class="font01">');
	  var val_ar = map[att_id];
		if(!val_ar) {
    	val_ar = new Array;
    	val_ar[0] = att.default_value_id ;
  	}
		if(att.name == 'skin') {
			var t = ref.getValue(att_id,val_ar[0]);
	  	document.write('<IMG src="/performers/skin_thumbs/' + t.substring(0,t.indexOf('.')) + '.jpg">');
		} else if (att.att_type == 'IMAGE_FILE') {
    	document.write("<IMG src='"+ref.getValue(att_id,val_ar[0])+"'>");
		} else {
   		for(var i = 0;i<val_ar.length;i++) {
	 			document.write(ref.getValue(att_id,val_ar[i])+"<br>");
			}
  	}
    document.write("</td></tr>")
  }
  document.write("</table>");  
 }
}

Performer.prototype.writeEditableAttributes=function(att_list) {
	document.write(this.getEditableAttributes(att_list));
}

Performer.prototype.getEditableAttributes=function(att_list) {
 var str = "";
 with(this.atts) {
  var joined;
	if(!att_list) return;
	for( var key in att_list) {
	  var att_id = ref.getAttributeIdByName(att_list[key]);
		var att = ref.getAttribute(att_id);
		if(!att) continue;
    		str += "<tr><td>"+att.name+"</td><td>";
		var val_ar = null;
    if(map)
      val_ar = map[att_id];
    if(!val_ar) {
      val_ar = new Array;
      val_ar[0] = att.default_value_id;
    }
    str += att.getEditableHtml(val_ar);
    str += "</td></tr>";
  }
 }

 return str;
}

Performer.prototype.writeGallery=function (perLine, width, height) {
 var perLine=perLine;
 with (this) {
  var photos=getPhotos();
  document.writeln('<TR>');
  if (photos!=null) {
   var count=1;
   for (var photo in photos) {
    var linebreak=((count%perLine)==0);
    with (photos[photo]) {
     document.writeln('<TD><A href="http://aff-images.dxlive.com/WebArchive/'+username+'/original/'+photo+'" target="_blank"><IMG src="http://aff-images.dxlive.com/WebArchive/'+username+'/thumbs/'+photo+'" width="'+width+'" height="'+height+'" alt="" border="0"></A></TD>'); }
    if (linebreak) document.writeln('<TR>');
    count++; } } } }

Filter = function(attribute_name, value_name) { // more value_names allowed as parameters
  this.att_name = attribute_name;
  this.myvalues = "";


  for(var i = 1; i < arguments.length; i++) {

    this.myvalues += "\t"+arguments[i]+"\n";
  }
}

Performers.prototype.filter= function(myfilter) {
  var newps = new Performers();
   for (var k in this.performers) {
    var vl = this.performers[k].getAttValueByAttName(myfilter.att_name);
    for(var j in vl.values) {
      if(myfilter.myvalues.indexOf("\t"+vl.values[j]+"\n") > -1) {
        newps.add(this.performers[k]);
        continue;
      }
    }
   }
   return newps;
}

Performers.prototype.split = function(att_name) {
//alert('in');
  var att_id = av_ref.getAttributeIdByName(att_name);
  var att = av_ref.getAttribute(att_id);
  var perfs_arr = new Array();
//alert('in2');
  var val_ids = av_ref.getAllAttributeValues(att_id);

  for(var k in val_ids) { perfs_arr[k] = new Performers(); }

//alert(perfs_arr[1]);

   for (var k in this.performers) {
//alert('k='+k+',value_list='+ this.performers[k].atts.map[att.id]);
    var val_ids = this.performers[k].getAttributeValueId(att.id);
//var val_ids = this.performers[k].atts.map[att.id];
    if(val_ids) {
    for(var j in val_ids) {
//alert('j='+j+',val_id='+val_ids[j]+', perf='+this.performers[k]);
      if(val_ids[j]) {
        perfs_arr[val_ids[j]].add(this.performers[k]);
      }
//alert('b');
    }
}
   }
//alert('leaving:'+perfs_arr[1]);
   return perfs_arr;
}

Category=function (id,name) {
 this.id=id;
 this.name=name;
 this.performers=new Array; }

Category.prototype.add=function (performer) {
 this.performers[this.performers.length]=performer; }

Categories=function () {
 this.categories=new Array; }

Categories.prototype.getIdList = function() {
	var ret = new Array;
	this.categories.sort(catComp);
	for(var category in this.categories) {
		ret[ret.length]=this.categories[category].id;
	}
	return ret;
}

Categories.prototype.getNameList = function() {
	var ret = new Array;
	this.categories.sort(catComp);
	for(var category in this.categories) {
		ret[ret.length]=this.categories[category].name;
	}
	return ret;
}

function catComp(a, b) {
  if(a.id < b.id) return -1;
  if(b.id < a.id) return 1;
  return 0;
}

Categories.prototype.add=function (category) {
 this.categories[this.categories.length]=category; }

Categories.prototype.get=function (id) {
  for (var category in this.categories) {
  if (this.categories[category].id==id) return this.categories[category]; }
 return null; }

Categories.prototype.getPerformerCount=function(id) {
	var cat=this.get(id);
	if(cat == null) return 0;
	return cat.performers.length;
}

Categories.prototype.writePerformerCount=function (id) {
  document.write(getPerformerCount(id)); }
	
Categories.prototype.fill=function (performers, attribute) {
if(!attribute) attribute = 'category';
 var seen=new Array;
 with (performers) {
  for (var performer in performers) {
   var id_vl=performers[performer].getAttValueByAttName(attribute);
   for(var vid in id_vl.val_ids) {
    var id = id_vl.val_ids[vid];
    if (id==null) continue;
    if (id=='') continue;
    if (seen[id]!=1) {
      this.add(new Category(id,id_vl.values[vid]));
      seen[id]=1;
    }
    var category=this.get(id);
    if (category==null) continue;
    category.add(performers[performer]); } } } }

Configuration=function () {
 this.Ip='';
 this.Server='';
 this.Copyright='';
 this.Language=''; 
 this.VName='';
 this.VPass='';
 this.VSite='';
}

function writePerformersChat (document, performer, configuration) {
 var bst = "";
 var usr = get_user();
 var vctp_param = "&vctp_url="+vctp_url+"&vctp_site="+configuration.VSite;

 var login = "&user_arg="+usr.user_name+"&pass_arg="+usr.pass;

 if(configuration.VName != '') {
	login = "&user_arg="+configuration.VName+"&pass_arg="+configuration.VPass;
 }
 if(checkBan(performer.username)) bst = "&ban_arg=true";
 
 var st = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="100%" height="100%" id="video_chat" align="">';
 st += ('<PARAM name="movie" value="' + vctp_url + '/flash/vctp_video_chat.swf?performerMode_arg=210&skin_arg=' + vctp_url +'/flash/'+performer.getAtt('skin')+'&ip_arg='+configuration.Ip+'&photo_arg='+performer.getAtt('picture')+'&langId_arg='+configuration.Language+login+vctp_param+bst+'">');
 st += ('<PARAM name="loop" value="false">');
 st += ('<PARAM name="menu" value="false">');
 st += ('<PARAM name="quality" value="high">');
 st += ('<EMBED src="' + vctp_url + '/flash/vctp_video_chat.swf?performerMode_arg=210&skin_arg=' + vctp_url + '/flash/'+performer.getAtt('skin')+'&ip_arg='+configuration.Ip+'&photo_arg='+performer.getAtt('picture')+'&langId_arg='+configuration.Language+login+vctp_param+bst+'" quality="high" bgcolor="#000000" width="100%" height="100%" name="video_chat" align="" type="application/x-shockwave-flash" pluginspace="http://www.macromedia.com/go/getflashplayer"></EMBED>');
 st += ('</OBJECT>');
 document.write(st);
}

function writeViewersChat (document, performer, configuration, points) {
 var bst = ""; 
 var mode_str = ""; 
 var points_str = points;
 if(typeof(points) == "undefined") {
  points_str = "";
 }

 if(checkBan(performer.username)) bst = "&ban_arg=true";
 if(busy_performers.getPerformer(performer.username)) bst += "&busy_arg=true";
 var usr = get_user();
 mode_str = checkViewerMode();
 if(usr.user_type == 207) { mode_str = "ROM";}
 else {mode_str = checkViewerMode();}
 var mode = '&viewer_mode_arg=' + mode_str;
 if (mode_str == 'Chat Mode') {
 	mode += 'public';
 } else if (mode_str == 'Peep Mode') {
 	mode += 'ROM';
 }
 bst += mode;
 bst += '&user_site_id='+usr.site_id;
 bst += '&promo_points='+points_str;

 var vctp_param = "&vctp_url="+vctp_url+"&vctp_site="+configuration.VSite;

 var login = "&user_arg="+usr.user_name+"&pass_arg="+usr.pass;
 //if(configuration.VName != '') {
	//login = "&user_arg="+configuration.VName+"&pass_arg="+configuration.VPass;
 //}
 document.writeln('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="100%" height="100%" id="video_chat" align="">');
 document.writeln('<PARAM name="movie" value="' + vctp_url + '/flash/vctp_video_chat.swf?user_mode_arg=205&performer_arg='+performer+'&skin_arg=' + vctp_url + '/flash/'+performer.getAtt('skin')+'&ip_arg='+configuration.Ip+'&photo_arg=http://aff-images.dxlive.com'+performer.getAtt('picture')+'&copyright_arg='+configuration.Copyright+'&server_arg='+configuration.Server+'&langId_arg='+configuration.Language+bst+login+vctp_param+'&show_add_points='+configuration.show_add_points+'">')
 document.writeln('<PARAM name="loop" value="false">');
 document.writeln('<PARAM name="menu" value="false">');
 document.writeln('<PARAM name="quality" value="high">');
 document.writeln('<PARAM name="bgcolor" value="#000000">');
 document.writeln('<EMBED src="' + vctp_url + '/flash/vctp_video_chat.swf?user_mode_arg=205&performer_arg='+performer+'&skin_arg=' + vctp_url + '/flash/'+performer.getAtt('skin')+'&ip_arg='+configuration.Ip+'&photo_arg=http://aff-images.dxlive.com'+performer.getAtt('picture')+'&copyright_arg='+configuration.Copyright+'&server_arg='+configuration.Server+'&langId_arg='+configuration.Language+bst+login+vctp_param+'&show_add_points='+configuration.show_add_points+'" quality="high" bgcolor="#000000" width="760" height="420" name="video_chat" align="" type="application/x-shockwave-flash" pluginspace="http://www.macromedia.com/go/getflashplayer"></EMBED>');
 document.writeln('</OBJECT>'); }

function writeFreeChat (document, performer, configuration) {
 var bst = ""; 
 if(checkBan(performer.username)) bst = "&ban_arg=true";
 if(busy_performers.getPerformer(performer.username)) bst += "&busy_arg=true";
 
 document.writeln('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="320" height="240" id="video_chat_free" align="">');
 document.writeln('<PARAM name="movie" value="' + vctp_url + '/flash/vctp_live.swf?performer_arg='+performer+'&vctp_url=' + vctp_url +'&ip_arg='+configuration.Ip+'&copyright_arg='+configuration.Copyright+'&server_arg='+configuration.Server+'&langId_arg='+configuration.Language+'&photo_arg=http://aff-images.dxlive.com'+performer.getAtt('picture')+bst + '">');
 document.writeln('<PARAM name="loop" value="false">');
 document.writeln('<PARAM name="menu" value="false">');
 document.writeln('<PARAM name="quality" value="high">');
 document.writeln('<PARAM name="bgcolor" value="#000000">');
 document.writeln('<EMBED src="' + vctp_url + '/flash/vctp_live.swf?performer_arg='+performer+'&photo_arg=http://aff-images.dxlive.com'+performer.getAtt('picture')+ '&vctp_url=' + vctp_url + '&ip_arg='+configuration.Ip+'&copyright_arg='+configuration.Copyright+'&server_arg='+configuration.Server+'&langId_arg='+configuration.Language+bst+'" quality="high" bgcolor="#000000" width="320" height="240" name="video_chat" align="" type="application/x-shockwave-flash" pluginspace="http://www.macromedia.com/go/getflashplayer"></EMBED>');
 document.writeln('</OBJECT>'); }

function writeMemberFreeChat (document, performer, configuration) {
 var bst = "";
 if(checkBan(performer.username)) bst = "&ban_arg=true";
 if(busy_performers.getPerformer(performer.username)) bst += "&busy_arg=true";

 document.writeln('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="320" height="240" id="video_chat_free" align="">');
 document.writeln('<PARAM name="movie" value="/viewers/live_member.swf?performer_arg='+performer+'&ip_arg='+configuration.Ip+'&copyright_arg='+configuration.Copyright+'&server_arg='+configuration.Server+'&langId_arg='+configuration.Language+'&photo_arg='+performer.getAttValueByAttName('picture')+bst+'">');
 document.writeln('<PARAM name="loop" value="false">');
 document.writeln('<PARAM name="menu" value="false">');
 document.writeln('<PARAM name="quality" value="high">');
 document.writeln('<PARAM name="bgcolor" value="#000000">');
 document.writeln('<EMBED src="/viewers/live_member.swf?performer_arg='+performer+'&photo_arg='+performer.getAttValueByAttName('picture')+'&ip_arg='+configuration.Ip+'&copyright_arg='+configuration.Copyright+'&server_arg='+configuration.Server+'&langId_arg='+configuration.Language+bst+'" quality="high" bgcolor="#000000" width="320" height="240" name="video_chat" align="" type="application/x-shockwave-flash" pluginspace="http://www.macromedia.com/go/getflashplayer"></EMBED>');
 document.writeln('</OBJECT>'); }

function writePerformersRecorder (document, performer, configuration) {
 var st = '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="700" height="550" id="video_record" align="">';
 st += ('<PARAM name="movie" value="'+vctp_url+'/flash/video_record.swf?performerMode_arg=210&skin_arg=/flash/'+performer.getAttValueByAttName('skin')+'&ip_arg='+configuration.Ip+'&photo_arg='+performer.getAttValueByAttName('picture')+'&langId_arg='+configuration.Language+'">');
 st += ('<PARAM name="loop" value="false">');
 st += ('<PARAM name="menu" value="false">');
 st += ('<PARAM name="quality" value="high">');
 st += ('<EMBED src="'+vctp_url+'/flash/video_record.swf?performerMode_arg=210&skin_arg=/flash/'+performer.getAttValueByAttName('skin')+'&ip_arg='+configuration.Ip+'&photo_arg='+performer.getAttValueByAttName('picture')+'&langId_arg='+configuration.Language+'" quality="high" bgcolor="#000000" width="760" height="420" name="video_chat" align="" type="application/x-shockwave-flash" pluginspace="http://www.macromedia.com/go/getflashplayer"></EMBED>');
 st += ('</OBJECT>');
 document.write(st);
}

function writeVideoPlayer (document, performer, configuration) {

 document.writeln('<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="100%" height="100%" id="video_player" align="">');
 document.writeln('<PARAM name="movie" value="'+vctp_url+'/flash/video_free_player.swf?muted=1&performer_arg='+performer+'&ip_arg='+configuration.Ip+'&copyright_arg='+configuration.Copyright+'&server_arg='+configuration.Server+'&langId_arg='+configuration.Language+'&photo_arg='+performer.getAttValueByAttName('picture')+'">');
 document.writeln('<PARAM name="loop" value="false">');
 document.writeln('<PARAM name="menu" value="false">');
 document.writeln('<PARAM name="quality" value="high">');
 document.writeln('<PARAM name="bgcolor" value="#000000">');
 document.writeln('<EMBED src="'+vctp_url+'/flash/video_free_player.swf?muted=1&performer_arg='+performer+'&photo_arg='+performer.getAttValueByAttName('picture')+'&ip_arg='+configuration.Ip+'&copyright_arg='+configuration.Copyright+'&server_arg='+configuration.Server+'&langId_arg='+configuration.Language+'" quality="high" bgcolor="#000000" width="100%" height="100%" name="video_player" align="" type="application/x-shockwave-flash" pluginspace="http://www.macromedia.com/go/getflashplayer"></EMBED>');
 document.writeln('</OBJECT>'); }

function openVideoPlayer(){
 //window.open('video_player.shtml?'+performer,'player','width=320,height=240,resizable=no,scrollbars=no');
}

function openSignup() {
  window.open("/join.html");
}

function openLaunchViewer (performer) {
 openAppWindow('vc_frameset.shtml?'+performer, performer, 760, 600); }

function openViewersChatFS (performer) {
// var winconfig = "left=0, Top=0, width=" + screen.width + ", height=" + screen.height + ", menubar=0, resizable=yes, toolbar=0, scrollbars=0, status=0"; 
// openAppWindow('/viewers/vc_frameset.html?'+performer, performer, 0, 0, winconfig); 
 openAppWindow('/viewers/vc_frameset.shtml?'+performer, performer, 760, 600); 
}

function openViewersChat (performer) {
// var winconfig = "left=0, Top=0, width=" + screen.width + ", height=" + screen.height + ", menubar=0, resizable=yes, toolbar=0, scrollbars=0, status=0"; 
// openAppWindow('/viewers/vc_frameset.html?'+performer, performer, 0, 0, winconfig); 
 openAppWindow('/viewers/vc_frameset.shtml?'+performer, performer, 760, 600); 
}

function openPerformersChat () {
 openAppWindow('/performers/video_chat.shtml', '', 760, 420); }

function openLaunchFree (username) {
 if(document.location.href.indexOf('affiliate_id=') != -1 || 
    (self.parent.window.name != 'dxFreeView' && window.name != 'dxFreeView')) {
  var window_handle = window.open('launch_free.html?'+username, 'dxFreeView', 'toolbar=no, scrollbars=yes, personalbar=no, menubar=no, width=760, height=600');
  window_handle.focus();
  window_handle.setTimeout('window.close()',600000);
  window_handle.opener = self;
 } else {
  self.opener = null;
  window.top.document.location.href='launch_free.html?'+username;
 }
 return false; 
}

function openAppWindow(url, name, width, height, wincfg) {
	if(!wincfg) wincfg = 'resizable=yes, toolbar=no, scrollbars=no, personalbar=no, menubar=no, width='+width+', height='+height;
	var w = window.open(url,name,wincfg);
	w.focus();
}

function vc_reload() { location.reload(); }

function randomizeOrder(a, b) {
  return Math.random() - .5;
}

/** CLEAN THIS UP IN HTML AND DELETE **/
/** switch to performers.list(perLine) **/
function list_online(performers, perLine) {
 var perLine=perLine;
 performers.list(perLine);
}

Performers.prototype.listTop = function(perLine,howMany) {
  return;
  this.list(perLine,false,false,0,0,howMany,true);
}

Performers.prototype.list = function(perLine, popUrl, popName, popWidth, popHeight, howMany, keepOrder, imgType, type ) {
 if(!popUrl) {
   var popUrl = "launch_free.html";
   var popName = 'dxFreeView';
   var popWidth = 760;
   var popHeight = 600;
   var winconfig = false;
   if(document.location.href.indexOf('/viewers/') != -1 ||
     document.location.href.indexOf('/video_chat/') != -1 ) { 
     popUrl = "vc_frameset.html";
     popName = '';
     winconfig = "left=0, Top=0, width=" + screen.width + ", height=" + screen.height + ", menubar=0, resizable=yes, toolbar=0, scrollbars=0, status=0"; 
   }
 }
 if( (typeof(imgType) == "undefined") || (imgType == "") ) {
  imgType = "live_thumbnail";
 }
 var url = popUrl;
 var wname = popName;
 with (this) {
  if (length) {
   document.writeln('<TR>');
   var count=1;
   var keys = new Array();
   var i = 0;
   for (var perf in performers) {
      if(type == "NEW") {
       with(performers[perf]){
	if(getAtt('new') == '1') 
             keys[i++] = perf;
	}
     }
      else if(type == "HQ"){
         with(performers[perf]){
           //var arr = getAttributeValueId(113);
           if( getAtt('has_hires') == '1' && getAtt('has_mic') == '1')
             keys[i++] = perf;
         }
      }

      else if(type == "REC"){
         with(performers[perf]){
           if( getAtt('recommended') == '1')
             keys[i++] = perf;
         }
      }

      else
        keys[i++] = perf;
  }

    if(!keepOrder) keys.sort(randomizeOrder);
   for(i = 0; i < keys.length; i++) {
    if(howMany && i >= howMany) break;
    var linebreak=((count%perLine)==0);
    var k = keys[i];
    with (performers[k]) {
      if(popUrl.indexOf('?') == -1) url = popUrl + "?"+username;
      if(popName == '') wname = username;
     document.writeln('<TD class="list_cell" valign=top>');
     document.writeln('<A href="#" onClick="openAppWindow(\''+url+'\',\''+wname+'\','+popWidth+','+popHeight+')">');
      document.writeln('<IMG src="http://aff-images.dxlive.com'+getAttValueByAttName(''+imgType+'')+'" alt="Live Thumbnail - '+username+'" border="0"><BR><div class="list_name">'+username+'<br>');
	if(this.lang) {
        var vl = getAtt('language');
        var vc = 0;
	  var vl_arr = vl.split(',');
          for(vid in vl_arr) {
                if(flag_files[vl_arr[vid]-1]) {
                        vc += 1;
                        if(vc < 4) document.write("<img border=0 src='/images/icons/"+ flag_files[vl_arr[vid]-1]+"' width=20 height=12 alt=''>");

                        //if (vc%4 == 0) document.write("<BR>");
        }}
//      document.write("<BR>");

       }
     document.write('<img src="' + vctp_url  + '/images/blank.gif" height=12 width=1 border=0>');
     if(this.icons) {
        if(this.lang) document.write("<br>");
        var toy = getAttributeValueId(537);
        var cam = (getAtt('has_hires') == '1');
	var mic = (getAtt('has_mic') == '1');
	var rec = (getAtt('recommended') == '1');
//      if(i < 13) alert(arr[0]);
        var flower = (getAtt('new') == '1');
        document.write("<table cellpadding=0 cellspacing=0 border=0 width=100%>");
        document.write("<tr><td width=25% align=center valign=top>");
        if(toy==1){
                document.write('<img src="/images/icons/icon_toy_shake.gif" >');
                document.write("</td><td width=25% align=center valign=top>");
        }
        if(toy==2){
                document.write('<img src="/images/icons/icon_toy_blink.gif" >');
              document.write("</td><td width=25% align=center valign=top>");
        }
        if(flower)
                document.write("<img src='" + vctp_url + "/images/icons/icon_newgirl.gif' border=0>");
        document.write("</td><td width=25% align=center valign=top>");
        if(cam)
                document.write("<img src='" + vctp_url + "/images/icons/icon_hirez.gif' border=0>");
        document.write("</td><td width=25% align=center valign=top>");
        if(mic)
                document.write("<img src='" + vctp_url + "/images/icons/icon_sound.gif' border=0>");
        document.write("</td><td width=25% align=center valign=top>")
        if(rec)
                document.write("<img src='" + vctp_url + "/images/icons/icon_flower.gif' border=0>");
        document.write("</td><td width=25% align=center valign=top><font color=#D133AA><b>")

	if(viewers > 0 && this.view_count)
                document.write(viewers);
//      document.write("<img src='/images/icons/count_".performers[k].viewers.".gif' border=0>");

        document.write("</td><td><img src='" + vctp_url + "/images/blank.gif' height=18 width=1 border=0></td>");
        document.write("</tr></table>");
     }
     document.writeln('</div></a>');
     document.writeln('</TD>'); }

    if (linebreak) document.writeln('<TR>');
    count++; } }
  else {
   document.writeln('<TR><TD align="center" class="performers_offline"><img src="'+ vctp_url + '/images/no_performers.gif"></TD>'); } } }

var flag_files = new Array('flag-jp.gif','flag-en.gif','flag-kr.gif','flag-ch','flag-ch','flag-fr','flag-sp','flag-it');

function list_performer (performer) {
 performer.print();
}

Performer.prototype.print=function() {
 var online=0;
 with (this) {

  if (online_performers.getPerformer(username)) online=1;
  if (online) {
   document.writeln('<TR><TD class="performer_online" align="center">'); }
  else {
   document.writeln('<TR><TD class="performer_offline" align="center">'); }
  if (online) document.write('<A href="javascript:openViewersChat(performer)">');
  document.write('<IMG width="160" height="120" src="http://aff-images.dxlive.com'+getAttValueByAttName('snapshot')+'" alt="Snapshot - '+username+'" border="5"><BR><b>'+username);

  if (online) document.write('</A>');

  if(this.lang) {
        document.write('<br>');
        var vl = getAttValueByAttName('language');
        var vc = 0;
        for(vid in vl.val_ids) {
                if(flag_files[vl.val_ids[vid]-1]) {
                        vc += 1;
                        document.write("<img src='" + vctp_url + "/images/icons/"+ flag_files[vl.val_ids[vid]-1]+"' width=20 height=12 alt='"+vl.values[vid]+"'>&nbsp;");
                        if (vc%4 == 0) document.write("<BR>");
        }}
  }



  document.write('</TD>');  
  if (online) document.write('<TR><TD class="performer_online" align="center"><A href="javascript:;" onClick="openViewersChat(performer)"><img src="' + vctp_url + '/images/button/now_online.gif" border="0" vspace="5"><br><img src="'+vctp_url+'/images/button/go_chat.gif" border="0"></A>');
	document.write('</TD></TR>'); }  }

function list_category (categories, id) {
 var category=categories.get(id);
 if (category==null) return null;
 with (category) {
	list_performers(performers);
 }
}

function list_performers (performers) {
	if(performers.performers)
		performers = performers.performers;
  for (var performer in performers) {
   with (performers[performer]) {
    document.writeln('<TR>');
    document.write('<TD><A href="/profile.shtml?'+username+'">'); writeImageAttribute('live_thumbnail', 80, 60, 'Live Thumbnail - '+username); document.write('</A></TD>');
    document.write('<TD><A href="/profile.shtml?'+username+'">'); document.write(username); document.write('</A></TD>');
    document.write('<TD>'); document.write(getAttValueByAttName('age')); document.write('</TD>');
    document.write('<TD>'); document.write(getAttValueByAttName('area')); document.write('</TD>'); 
    document.write('<TD>'); document.write(getAttValueByAttName('category')); document.write('</TD>');
    document.write('<TD>'); document.write(getAttValueByAttName('language')); document.write('</TD>');
    document.write('<TD>'); document.write(getAttValueByAttName('job')); document.write('</TD>');

	 } 
  }
 } 


function setBan(pname) {
   var t = new Date();
   var d = new Date();
   t.setTime(d.getTime() + 1000*60*60);
   document.cookie = escape(pname+"_ban") + "=on;"
   document.cookie += "expires=" + t.toGMTString();
}
function checkBan(pname) { return (document.cookie.indexOf(escape(pname+"_ban")+"=") != -1); }


function setViewerMode(mode) {
	//document.cookie = "vm=" + mode + ";";
 document.cookie = "vm=" + mode + "; path=/; expires=Sun, 18 Jan 2038 00:00:00 GMT;";
}

function checkViewerMode() { 

        if( document.cookie.indexOf(escape("vm")) != -1 ) {
                index = document.cookie.indexOf("vm");
                cookieStart = (document.cookie.indexOf("=", index) + 1);
                cookieEnd       = document.cookie.indexOf(";", index);
                        if (cookieEnd == -1) {
                                cookieEnd = document.cookie.length;
                        }
                vmode   = document.cookie.substring(cookieStart, cookieEnd);
		/*var vmode_str = "Chat Mode";
                if (vmode == 'public') {
                        vmode_str = 'Chat Mode';
                } else if (vmode == 'ROM') {
                        vmode_str = 'Peep Mode';
                }*/
                return vmode;

        } else {
		return "public";
        }
}

function closeWindow() {
        window.top.close();
}

function openAddpoint() {
  window.open("/viewers/","");

}

function openAddPoints() {
 var usr = get_user();
 if(usr.user_type == 207) {
  window.open("/viewers/index.shtml","");
 } else {
  window.open("/viewers/","");
 }
}

function writeGoodsFormInput(points) {
   var user = get_user();
   document.write('<input type=hidden size="4" value="');
   if(user.site_id == 1000048) {
     if(points == 25) {
	if(user.user_type == 207) { document.write("1005903"); }
	else { document.write("0"); }
     }
     if(points == 50) {
	if(user.user_type == 207) { document.write("1005913"); }
	else { document.write("1000127"); }
     }
     if(points == 110) {
	if(user.user_type == 207) { document.write("1005923"); }
	else { document.write("1000129"); }
     }
     if(points == 170) {
	if(user.user_type == 207) { document.write("1005933"); }
	else {		document.write("1000131"); }
     }
   }
   if(user.site_id == 1000049) {
     if(points == 25) {
	if(user.user_type == 207) { document.write("1006303"); }
	else { document.write("0"); }
     }
     if(points == 50) {
	if(user.user_type == 207) { document.write("1006313"); }
	else { document.write("1000135"); }
     }
     if(points == 110) {
	if(user.user_type == 207) { document.write("1006323"); }
	else { document.write("1000137"); }
     }
     if(points == 170) {
	if(user.user_type == 207) { document.write("1006333"); }
	else {document.write("1000139"); }
     }
   }
   if(user.site_id == 1000050) {
     if(points == 25) {
	if(user.user_type == 207) { document.write("1006353"); }
	else { document.write("0"); }
     }
     if(points == 50) {
	if(user.user_type == 207) { document.write("1006363"); }
	else { document.write("1000143"); }
     }
     if(points == 110) {
	if(user.user_type == 207) { document.write("1006373"); }
	else { document.write("1000145"); }
     }
     if(points == 170) {
	if(user.user_type == 207) { document.write("1006383"); }
	else {		document.write("1000147"); }
     }
   }
   document.write('" name="goods_id">');
}

function logged_in(user_name, password, user_type, performer_name, chat_type) {
   var t = new Date();
   var d = new Date();
   t.setTime(d.getTime() + 1000*60*60*24*365); // one year
   var exp = "expires=" + t.toGMTString();

//alert(user_name + "-" + password + "-"+user_type+"_"+performer_name+"_"+chat_type);

        document.cookie = "un="+user_name+";expires="+exp+";path=/";
        document.cookie = "pw="+password+";path=/";
        document.cookie = "ut="+user_type+";expires="+exp+";path=/";

//alert(document.cookie);

//alert(performer_name);
//        if(performer_name) {
//		setRecentList(performer_name);
 // 	}
//        setViewerMode(chat_type);


}

Performers.prototype.freelist = function(perLine, popUrl, popName, popWidth, popHeight, howMany, keepOrder) {
 if(!popUrl) {
   var popUrl = "launch_free.html";
   var popName = 'dxFreeView';
   var popWidth = 760;
   var popHeight = 600;
   var winconfig = false;
   if(document.location.href.indexOf('/viewers/') != -1 ||
     document.location.href.indexOf('/video_chat/') != -1 ) { 
     popUrl = "vc_frameset.html";
     popName = '';
     winconfig = "left=0, Top=0, width=" + screen.width + ", height=" + screen.height + ", menubar=0, resizable=yes, toolbar=0, scrollbars=0, status=0"; 
   }
 }
 var url = popUrl;
 var wname = popName;
 with (this) {
  if (length) {
   //document.writeln('<TR>');
   var count=1;
   var keys = new Array();
   var i = 0;
   for (var perf in performers) {
	keys[i++] = perf;
    }
    if(!keepOrder) keys.sort(randomizeOrder);
   for(i = 0; i < keys.length; i++) {
    if(howMany && i >= howMany) break;
    var linebreak=((count%perLine)==0);
    var firstten=((count%5)==0); //this is for first 10
//added

    if(i==0) //display first 5
       document.writeln('<table width="750" border="0" cellpadding="0" cellspacing="0"><tr><td height="23" valign="middle"><img src="/free/images/free_1to5.gif" width="750" height="20"></td></tr></table>');

    else if(i==10) //display 11-19th
       document.writeln('<table width="750" border="0" cellpadding="0" cellspacing="0"><tr><td height="23" valign="middle"><img src="/free/images/free_11to19.gif" width="750" height="20"></td></tr></table>');

    else if(i==5) //display 2nd 5
       document.writeln('<tr><td colspan=5 width=750 height="23" valign="middle"><img src="/free/images/free_6to10.gif" width="750" height="20"></td></tr>');

    else if(i==19) //display 20-28th
       document.writeln('<tr><td colspan=9 width=750 height="23" valign="middle"><img src="/free/images/free_20to28.gif" width="750" height="20"></td></tr>');

    if(i==0 || i==10)
       document.writeln('<table width=750 cellpadding="0" cellspacing="0" class="list_table"><tr>');

    var k = keys[i];
    with (performers[k]) {
      if(popUrl.indexOf('?') == -1) url = popUrl + "?"+username;
      if(popName == '') wname = username;
      if( i < 10)
         document.writeln('<TD valign=top><table width=99% cellpadding=1 cellspacing=0 align=center><tr><td bgcolor=#333333>'); //added table tag
      else
         document.writeln('<TD valign=top><table cellpadding=0 cellspacing=0 align=center><tr><td bgcolor=#333333>'); //added table tag

//     document.writeln('<A href="#" onClick="openAppWindow(\''+url+'\',\''+wname+'\','+popWidth+','+popHeight+',\''+winconfig+'\')">');
       document.writeln('<A href="javascript:;" onClick="openAppWindow(\''+url+'\',\''+wname+'\','+popWidth+','+popHeight+')">');
     //document.writeln('<IMG src="http://en.dxlive.com'+getAttValueByAttName('live_thumbnail')+'" width="80" height="60" alt="Live Thumbnail - '+username+'" border="0"><BR><div class="list_name">'+username+'<br>');

//if i<10, display a large image
      if(count < 11)
         document.writeln('<div align=center><IMG src="http://aff-images.dxlive.com'+getAttValueByAttName('snapshot')+'" width="140" height="105" alt="Live Thumbnail - '+username+'" border="0"></div><div class="list_name">'+username+'<br>');

//if i>9, display a thumbnail image
      else
         document.writeln('<IMG src="http://aff-images.dxlive.com'+getAttValueByAttName('live_thumbnail')+'" width="80" height="60" alt="Live Thumbnail - '+username+'" border="0"><BR><div class="list_name">'+username+'<br>');

	if(this.lang) {
        var vl = getAttValueByAttName('language');
        var vc = 0;
        for(vid in vl.val_ids) {
                if(flag_files[vl.val_ids[vid]-1]) {
                        vc += 1;
                        if(vc < 4) document.write("<img border=0 src='/images/icons/"+ flag_files[vl.val_ids[vid]-1]+"' width=20 height=12 alt='"+vl.values[vid]+"'>&nbsp;");

        }}
       }

     document.write('<img src="/images/blank.gif" height=12 width=1 border=0>&nbsp;');
     if(this.icons) {
        if(this.lang) document.write("<br>");
        var cam = (getAttValueByAttName('has_hires') == 'Yes');
        var arr = getAttributeValueId(113);
	var toy = getAttributeValueId(537);
//      if(i < 13) alert(arr[0]);
        var mic = (arr[0] == 1); //1 is hardcoded value id for 'yes'
        var days = (( new Date() - reg_date)/(1000*60*60*24) < 31);
        var flower = ((new Date() - reg_date)/(1000*60*60*24) < 31);
        document.write("<table cellpadding=0 cellspacing=0 border=0>");
        document.write("<tr><td width=25% align=center valign=top>");
	if(toy==1){
		document.write('<img src="/v3images/shared/icons/icon_toy_shake.gif" >');
    	        document.write("</td><td width=25% align=center valign=top>");
	}
	if(toy==2){
		document.write('<img src="/v3images/shared/icons/icon_toy_blink.gif" >');
    	      document.write("</td><td width=25% align=center valign=top>");
	}
        if(flower)
                document.write("<img src='/images/icons/icon_newgirl.gif' border=0>");
        document.write("</td><td width=25% align=center valign=top>");
        if(cam)
                document.write("<img src='/images/icons/icon_hirez.gif' border=0>");
        document.write("</td><td width=25% align=center valign=top>");
        if(mic)
                document.write("<img src='/images/icons/icon_sound.gif' border=0>");
        document.write("</td><td width=25% align=center valign=top><font color=#D133AA><b>")
        //if(viewers > 0 && this.view_count)
        //      document.write(viewers);
        document.write("</td><td><img src='/images/blank.gif' height=18 width=1 border=0></td>");
        document.write("</tr></table>");
     }
     document.writeln('</div></a></td></tr></table>'); //added table tag
     document.writeln('</TD>'); }

// if i < 10
// if(count==5 || count==10)
//    document.writeln('</TR></table>');//added </table>
 if(count==5 || count==10 || count==19 || count==28)
    document.writeln('</TR>');
if(count==10 || count==28)
   document.writeln('</table>');

    count++; 
   }
  }
  else {
   document.writeln('<TR><TD align="center" class="performers_offline"><img src="images/no_performers.gif"></TD>'); } } }

var en_op = new Performers();
/*
function build_online(ps) {
	var perfs = new Array();
	var randPerfs = new Array();
	var op_arr = new Array();

	with(ps) {
		if(length) {
			var vwrPerfs = new Array();
			var i = 0;  	 	var j = 0;			var a = 0;
    	for (var performer in ps.performers) {
      	vwrPerfs[i++] = ps.getPerformer(performer);
    	}
    	vwrPerfs.sort(vwrComp);
			var tmp_site = vwrPerfs[0].site_id;
			for(j=0; j < vwrPerfs.length; j++) {
				if(vwrPerfs[j].site_id != tmp_site) {
					randPerfs[a] = vwrPerfs[j];
					a++;
				} else {
					perfs[j] = vwrPerfs[j];
					tmp_site = vwrPerfs[j].site_id;
				}
			}

			randPerfs.sort(randomizeOrder);
			per
*/

