var bannerId = 9132008;
var perfRedirect;
function loadVideo(width,high) {
	if(!user_arr)	return;

  videoDiv = getElementFromName('videoCode');
  if(!videoDiv) return;
  
  if(!width || !high)
  {
  	width = 160;
  	high = 120;
  }
  
  var arr = new Array();
  for(uname in user_arr) {
    if(user_arr[uname].session_type=='110') arr.push(uname);
  }

	if(arr.length == 0)	{
		loadBanner(width,high);
		return;
	}

  var uname = '';
  if(arr.length > 0) {
    var index = Math.floor(Math.random() * arr.length);
    uname = arr[index];
    perfRedirect = uname;
  }

  if(uname=='') return;

  var uid = user_arr[uname].user_id;

  var str = '<div id="affiliatePreview">';
  str += '<div id="videoPerformer">';
  str += '<div id="videoPerformername">' + uname + 'ちゃん</div></div>';
  str += '<div id="video">';
  str += '<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width= '+width+' height='+high+' id="video_chat" align="">';
  str += '<param name="allowScriptAccess" value="always" />';
  str += '<PARAM name="movie" value="/flash/chat/freePreview20.swf">';
  str += '<param name=FlashVars value="channel=' + uname + '&performerID=' + uid + '&userType=&sessionType=110&langID=jp&userSiteID=1001343&skinName=skin0&ban=0&photo=http://imageup.exshot.com/WebArchive/' + uid + '/flash/LinkedImage.jpg" />';
  str += '<PARAM name="salign" value="LT">';
  str += '<PARAM name="quality" value="high">';
  str += '<PARAM name="bgcolor" value="#006666">';
  str += '<param name="wmode" value="transparent">';
  str += '<embed src="/flash/chat/freePreview20.swf" salign="LT" FlashVars="channel=' + uname + '&performerID=' + uid + '&userType=&sessionType=110&langID=jp&webID=A&userSiteID=1001343&skinName=skin0&ban=0&photo=http://imageup.exshot.com/WebArchive/' + uname + '/flash/LinkedImage.jpg" quality="high" bgcolor="#006666" width= '+width+' height='+high+' name="video_chat" align="" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" wmode="transparent"/>';
  str += '</OBJECT>';
  str += '</div>';
  str += '</div>';

  videoDiv.innerHTML = str;
}

function loadBanner(width, high) {
  videoDiv = getElementFromName("videoCode");
  if (!videoDiv) return;
  if(!width || !high)
  {
  	width = 160;
  	high = 140;
  }
  if(width == 160){
  	banner_img = '/img/home/random_preview/exshot.jpg';
        bannerId = 9132003;
  	width = 160;
  	high = 140;
  } else if (width == 140) {
  	banner_img = '/img/home/random_preview/exshot_2.jpg';
        bannerId = 9132008;
  	width = 140;
  	high = 120;
  } else {
        banner_img = '/img/home/random_preview/exshot_2.jpg';
        width = width;
        high = high;
  }

  videoHTMLCode = '<div id="affiliatePreview">';
  videoHTMLCode += '<a href="http://click.dtiserv2.com/redir.fcgi?click=110&amp;site=132&amp;b='+bannerId+'" target="_blank">';
  videoHTMLCode += '<img src="'+banner_img+'" width="'+width+'" height="'+high+'" border="0">';
  videoHTMLCode += '</a>';
  videoHTMLCode += '</div>';
  videoDiv.innerHTML = videoHTMLCode;
}



