// EXtended Vars

if(typeof(ownserver) == "undefined") {
	ownserver = "http://aff-jp.dxlive.com";
}

function openAppWindow(url, name, width, height, wincfg) {
	if(!wincfg) wincfg = 'resizable=yes, toolbar=no, scrollbars=auto, personalbar=no, menubar=no, width='+width+', height='+height;
	var w = window.open(url,name,wincfg);
	w.focus();
}
Performers.prototype.list= function(perLine, popUrl, popName, popWidth, popHeight, howMany, keepOrder, imgType, type, attr ) {
	if(!popUrl) {
		var popUrl = "launch_free.html";
		var popName = 'FreeView';
		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.shtml";
			popName = '';
			winconfig = "left=0, Top=0, width=" + screen.width + ", height=" + screen.height + ", menubar=0, resizable=yes, toolbar=0, scrollbars=0, status=0";
		}
	}

	if(imgType == "vctp_thumbnail") {
		thumbwid = 120;
		thumbheig= 90;
	}

	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 == "EN") {
					with(performers[perf]){
						if( getAtt('language') == '2')
						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;


		if (viewers > 2){
			document.writeln('<td width="120" style="/*光ってるとき*/padding:2px;">');
			document.writeln('<table  border="0" width="120" height="90" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #ffffff;background:url(' + ownserver + '/ncimg/thumb_fl.gif) no-repeat center bottom;">');

		} else {
			document.writeln('<td width="120" style="/*３人以下の時*/padding:2px;">');
			document.writeln('<table border="0" width="120" height="90" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #ffffff;background-color:#000000;">');
		}

		document.writeln('<tr valign="top"><td colspan="2" align="center">');
		document.writeln('<a href="' + popUrl + '?'+username+'">');
		document.writeln('<img src="http://imageup.dxlive.com'+getAttValueByAttName(''+imgType+'')+'" alt="'+username+'" border="0" width="120" height="90"><br></a>');
		document.writeln('</td></tr></table>');

		document.writeln('<table border="0" width="122" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #ffffff;border-top:0px solid #ffffff;background-image:url(' + ownserver + '/ncimg/name_bg.gif);background-repeat:no-repeat;>');






	// パフォ状態表示
		document.writeln('<tr valign="top">');
		document.writeln('<td width="20" align="center">');

			if(viewers > 0 && this.view_count)
				document.write('<span class="num" title="'+username+'のチャット中人数：'+ viewers +'人">' + viewers + '</span>');
				document.writeln('</td>');


			if(public_performers.getPerformer(username))//チャット中
				document.writeln('<td align="right" valign="middle" height="20" width="100" style="background:url(/ncimg/chat.gif) no-repeat;"><a href="gallery.html?' + username + '" target="_blank" title="' + username + '写真集"><img src="/ncimg/preview/icoGallery.gif" /></a></td>');

			else if(private_performers.getPerformer(username))//2ショット
				document.writeln('<td align="right" valign="middle" height="20" width="100" style="background:url(/ncimg/2shot.gif) no-repeat;"><a href="gallery.html?' + username + '" target="_blank" title="' + username + '写真集"><img src="/ncimg/preview/icoGallery.gif" /></a></td>');

			else if(!public_performers.getPerformer(username) && !private_performers.getPerformer(username))//待機
				document.writeln('<td align="right" valign="middle" height="20" width="100" style="background:url(/ncimg/online.gif) no-repeat;"><a href="gallery.html?' + username + '" target="_blank" title="' + username + '写真集"><img src="/ncimg/preview/icoGallery.gif" /></a></td>');






		document.writeln('</td>');
		document.writeln('</tr>');

		document.writeln('<tr width="120">');
		document.writeln('<td width="120" align="center" class="list_name" colspan="2">');
		document.writeln('<a href="' + popUrl + '?'+username+'">'+username+'</a>');
		document.writeln('</td>');
		document.writeln('</tr>');



// ICONS
	if(this.icons) {
        if(this.lang) document.writeln('<tr>');
			var toy = getAttributeValueId(537);
	        var cam = (getAtt('has_hires') == '1');
			var rec = (getAtt('recommended') == '1');
			var mic = (getAtt('has_mic') == '1');

			var flower = (getAtt('new') == '1');
			document.writeln('<td colspan="3" align="center" height="18">');

			document.writeln('<table border="0" cellpadding="0" cellspacing="0"><tr><td>');

			if(flower)
				document.writeln('<img src="' + ownserver + '/ncimg/icon_newgirl.gif" alt="新人" align="absmiddle" style="margin-right:1px;">');

			if(cam)
				document.writeln('<img src="' + ownserver + '/ncimg/icon_hirez.gif" alt="高画質" align="absmiddle" style="margin-right:1px;">');

			if(mic)
				document.writeln('<img src="' + ownserver + '/ncimg/icon_sound.gif" alt="マイク" align="absmiddle" style="margin-right:1px;">');
			if(rec)
				document.writeln('<img src="' + ownserver + '/ncimg/icon_flower.gif" alt="お薦め" align="absmiddle" style="margin-right:1px;">');
			if(toy==1)
				document.write('<img src="http://aff-jp.dxlive.com/VCTP/images/icons/icon_toy_shake.gif" alt="バイブ有り未使用" align="absmiddle">');
			if(toy==2)
				document.write('<img src=" http://aff-jp.dxlive.com/VCTP/images/icons/icon_toy_blink.gif" alt="バイブ有り使用中" align="absmiddle">');
			if(!flower && !cam && !mic && !rec && !toy)
				document.writeln('&nbsp;');

				document.writeln('</td></tr></table></td></tr>');
	}
		document.writeln('<tr>');


// LANGUAGE FLAGS
		var flag_files = new Array('flag-jp.gif','flag-en.gif','flag-kr.gif','flag-ch','flag-ch','flag-fr','flag-sp','flag-it');
		document.writeln('<td colspan="3" align="right" height="12">');

		document.writeln('<table border="0" cellpadding="0" cellspacing="0" width="118">');
		document.writeln('<tr>');

		//attr表示
		document.writeln('<td style="color:#ffffff;text-align:left;">');
		if(attr){
			document.writeln('<img src="/ncimg/icon_attrTag.gif" align="absmiddle">'+attr+'');
		}
		document.writeln('</td>');

		document.writeln('<td style="text-align:right;">');
			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='" + vctp_url + "/images/icons/"+ flag_files[vl_arr[vid]-1]+"' width=13 height=9 alt='' align=absmiddle>");
						}
	        		}
				}
			}
		document.writeln('</td>');
     	document.writeln('</tr></table></td></tr></table>'); 
	}

		if (linebreak) document.writeln('<tr>');
			count++;
		}
		} else {
  	 		document.writeln('<tr><td align="center" class="performers_offline"><img src="' + ownserver + '/images/no_performers.gif"></td>');
		}

	}

}







// NEW PRINT
function vclist_performer (performer) {
	performer.vcprint();
}
Performer.prototype.vcprint=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('<tr><td class="performer_online" align="center"><a href="javascript:;" onClick="openViewersChat(performer)"><img src="' + ownserver + '/images/button/now_online.gif" border="0" vspace="5"><br><img src="' + ownserver + '/images/button/go_chat.gif" border="0"></a>');
			document.write('</td></tr>'); 
		}
	}





// search list * Target blank
	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="/' + popUrl + '?'+username+'">'); writeImageAttribute('live_thumbnail', 80, 60, 'Live Thumbnail - '+username); document.write('</a></td>');
					document.write('<td><a href="/' + popUrl + '?'+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>');
				}
			}
	}
