//<!-
function rep_imgfavorite()	{
	imgsrc	=	document.getElementById('img_favorite').src;

	adfav	=	imgsrc.indexOf('prof_fav');
	unfav	=	imgsrc.indexOf('prof_unfav');

	if(adfav > 0) {
		document.getElementById('img_favorite').src =	"/img/home/new/prof_unfav.gif";
	}
	if(unfav > 0) {
		document.getElementById('img_favorite').src =	"/img/home/new/prof_fav.gif";
	}
	imgsrc2	=	document.getElementById('img_favorite').src;
}

var CLUB_URL = "http://club.exshot.com";
//==== DX Faceoff
var DX_URL = "http://www.dxlive.com";
function openProfileDX(uname) {
	//  if(userType)
	//    openNewWindow(DX_URL+'/preview/'+uname+'?action=login&fromSite=1001343', 'preview'+uname, 'resizable=yes,toolbar=no,scrollbars=yes,personalbar=no,menubar=no,width=800,height=950');
	//  else
	//    openNewWindow(DX_URL+'/preview/'+uname+'?fromSite=1001343', 'preview'+uname, 'resizable=yes,toolbar=no,scrollbars=yes,personalbar=no,menubar=no,width=800,height=950');
    openNewWindow(DX_URL+'/preview/'+uname+'?fromSite=1001343', 'preview'+uname, 'resizable=yes,toolbar=no,scrollbars=yes,personalbar=no,menubar=no,width=800,height=950');
}

function openViewersChatDX(performer, stype) {
  if(!stype){
    stype=120;
  }
  openNewWindow(DX_URL+ '/chat/'+performer+'/'+stype+'/1001343/', performer, 'resizable=yes,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=780,height=700');
}

function openViewersChatHDDX(performer, stype) {
  if(!stype){
    stype=120;
  }
  openNewWindow(DX_URL+ '/chat/'+performer+'/'+stype+'/1001343/', performer, 'resizable=yes,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=910,height=540');
}

function openMailboxDX(uname){
  openNewWindow(DX_URL+ '/mailbox/compose?url=mailbox/compose&toidlist='+uname, 'mailbox', 'resizable=yes,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=910,height=540');
}

function openViewersChat(performer, stype) {
  if(!stype){
    stype=120;
  }
  openNewWindow(DX_URL+ '/chat/'+performer+'/'+stype+'/1001343/', performer, 'resizable=yes,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=780,height=700');
}

function openViewersChatSame(performer, stype) {
  if(!stype){
    stype=120;
  }
  var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
  if(is_chrome){
    window.location = DX_URL+ '/chat/'+performer+'/'+stype+'/1001343/';
  }else{
    var chatw = window.open(DX_URL+ '/chat/'+performer+'/'+stype+'/1001343/', performer, 'resizable=yes,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=780,height=700');
    window.close();
    chatw.focus();
  }
}

//==== END DX


//==== EX_CCG Faceoff
var CCG_URL = "http://www.caribbeancomgirl.com";
function openProfileCCG(uname) {
  if(userType)
    openNewWindow(CCG_URL+'/profile/'+uname+'?fromSite=1001343&action=login', 'profile'+uname, 'resizable=yes,toolbar=no,scrollbars=yes,personalbar=no,menubar=no,width=855,height=605');
  else
     openNewWindow(CCG_URL+'/profile/'+uname+'?fromSite=10011343', 'profile'+uname, 'resizable=yes,toolbar=no,scrollbars=yes,personalbar=no,menubar=no,width=855,height=605');
}

function openSendMailCCG(uname) {
  // openSendMail(pname)
  openNewWindow(CCG_URL+'/mailbox/compose/?to='+uname , 'mailbox' , '');
}
function openViewerVchatCCG(uid, stype) {
  openNewWindow(CCG_URL+'/chat/member/'+uid+'/'+stype+'/1001343/', 'Chat'+uid, 'directories=no,status=no,location=no,resizable=yes,toolbar=no,scrollbars=yes,personalbar=no,menubar=no,width=975,height=480');
}

function openViewerVchatCCGSame(uid, stype) {
  var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
  if(is_chrome){
     window.location = CCG_URL+'/chat/member/'+uid+'/'+stype+'/1001343/';
  }else{
     var chatw = window.open(CCG_URL+'/chat/member/'+uid+'/'+stype+'/1001343/', uid, 'resizable=yes,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=780,height=700');
     window.close();
     chatw.focus();
  }
}


//==== END FACE OFF

function openCompliance() {
    openNewWindow("/pop/memo.htm", 'compliance', 'toolbar=1,location=1,status=1,scrollbars=1,menubar=1,resizable=1');
}

function openFaq(){
    openNewWindow("/faq.html#DOQ7", 'BankKick', 'toolbar=1,location=1,status=1,scrollbars=1,menubar=1,resizable=1');
}

function liveviewer() {
      livew = window.open('/livesession.html', 'livesession', 'resizable=no,toolbar=no,scrollbars=no,personalbar=no,menubar=no,location=no,status=no,width=568,height=273,top=0,left=0');
    //w.focus();
}

function closeLiveviewer(){
  //Doing this so no javascript error appears when testing for livew.
  if(!livew){
    var livew;
  } else {
    livew.close();
  }
}

// called by flash
function openInquiry(errorCode){
   var error_url =  "https://service.d2pass.com/klmember/inquiry/";
   if(errorCode)
      error_url =  "https://service.d2pass.com/klmember/inquiry/?error_num="+errorCode;

   if(userType == 210){
     if(errorCode)
        error_url = "https://service.d2pass.com/klperformer/inquiry/?error_num="+errorCode;
     else
        error_url = "https://service.d2pass.com/klperformer/inquiry/";
   }
   window.open(error_url);
}

function resizeChatWindow(size){
  if(size == 'small'){
    window.resizeTo(780,387);
  } else if(size == 'medium'){
    window.resizeTo(940,507);
  } else if(size == 'full'){
    window.moveTo(0,0);
    window.resizeTo(screen.width, screen.height);
  }
}

// Function for Web
function openVideoPlayer(mediaID) {
  openNewWindow("/app/video/video_player.php?vid=" + mediaID,"","width=560,height=750,scrollbars=no,location=no,menubar=no,left=10,top=30");
}
function openVideoPlayer_camp(mediaID) {
  openNewWindow("/app/video/video_player.php?camp=1&vid=" + mediaID,"","width=560,height=750,scrollbars=no,location=no,menubar=no,left=10,top=30");
}

function openVideoPlayerPromo(mediaID) {
  openNewWindow("/app/videoPromo/video_player.php?vid=" + mediaID,"","width=560,height=750,scrollbars=no,location=no,menubar=no,left=10,top=30");
}


function openViewerEditProfile() {
  openNewWindow('/app/member/profile.php', 'viewerEditProfile', 'location = yes, resizable=yes, toolbar=yes, scrollbars=yes, personalbar=yes, menubar=yes, width=850, height=685');
}
function setCookie (name, value){
  document.cookie = name + '=' + escape(value) + ";path=/;"
}

function getCookie(cookieName){
  var search = cookieName + '=';
  if (document.cookie.length>0) {
    offset = document.cookie.indexOf(search);
    if (offset != -1){
      offset += search.length;
      end     = document.cookie.indexOf(';',offset);
      if(end == -1)
        end = document.cookie.length;
      return unescape(document.cookie.substring(offset,end));
    }
  }
  return null;
}

/*
function openWindow(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 openJoin(){
   openNewWindow('/join.html', 'join', '')
}
function openPreview(uname) {
  window.location = '/preview/'+uname+'.html';
}

//function openPreview(uid) {
  //openNewWindow('/app/preview.php?uid='+uid+'&tpl=new', 'preview', 'resizable=no,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=600,height=750'); 
//}
function openPreview1Pondo(uid) {
  openNewWindow('/app/preview.php?uid='+uid+'&tpl=1pondo', 'preview', 'resizable=no,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=600,height=750'); 
}

function openPreviewByName(uname) {
  openNewWindow('/preview/'+uname+'.html', 'preview', 'width=800, height=800, menubar=no, toolbar=no, scrollbars=yes'); 
  //openNewWindow('/app/preview.php?uname='+uname, 'preview', 'resizable=no,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=700,height=400'); // Deleted on Nov. 6, 2009 RT#60913
}

function openBigPreview(uid) {
  openNewWindow('/app/preview.php?tpl=big&uid='+uid, 'preview', 'resizable=no,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=700,height=400'); 
}

function openReview(performerName) {
  openNewWindow('/app/survey.php?src=1&name='+performerName, 'review', 'resizable=no,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=700,height=550');
}

function openVideoPlayer(mediaID) {
  openNewWindow("/app/video/video_player.php?vid=" + mediaID,"","width=560,height=750,scrollbars=no,location=no,menubar=no,left=10,top=30");
}

function openVideoHistory() {
	openNewWindow('/app/member/video_history.php','purchase_history','status=yes,scrollbars=yes,resizable=yes,width=800,height=600');
}

function openVideoList(pname) {
	openNewWindow('/app/video/video.php?uname='+pname, pname+'videoList', 'resizable=yes, toolbar=yes, scrollbars=yes, personalbar=yes, menubar=yes, width=685, height=685');
}

function openVideoListPromo(pname) {
        openNewWindow('/app/videoPromo/video.php?uname='+pname, pname+'videoList', 'resizable=yes, toolbar=yes, scrollbars=yes, personalbar=yes, menubar=yes, width=685, height=685');
}

function openViewerVchat (uid, stype, fromSite) {
   if(fromSite)
      openNewWindow('/app/member/chat.php?uid='+uid+'&stype='+stype+'&fromSite='+fromSite, 'Chat'+uid, 'resizable=yes,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=780,height=378');
   else
      openNewWindow('/app/member/chat.php?uid='+uid+'&stype='+stype, 'Chat'+uid, 'resizable=yes,toolbar=no,scrollbars=no,personalbar=yes,menubar=no,width=780,height=378');
}


function openViewerVchatEX (uid, stype, fromSite) {
   if(fromSite)
      openNewWindow('/app/member/chat.php?uid='+uid+'&stype='+stype+'&fromSite='+fromSite, 'Chat'+uid, 'resizable=yes,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=780,height=378');
   else
      openNewWindow('/app/member/chat.php?uid='+uid+'&stype='+stype, 'Chat'+uid, 'resizable=yes,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=780,height=378');
   window.focus();
}


function openViewerVchatEXSame(pid, stype, fromSite, replace) {
   if(stype == '' || stype == null){
      stype = 115;
   }
      var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
      if(is_chrome){
         if(FromSite)
            window.location = '/app/member/chat.php?uid='+pid+'&stype='+stype+'&fromSite='+fromSite;
         else
            window.location = '/app/member/chat.php?uid='+pid+'&stype='+stype;
      }else{
        if(fromSite){
          chatw = window.open('/app/member/chat.php?uid='+pid+'&stype='+stype+'&fromSite='+fromSite, pid, 'resizable=yes,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=975,height=480');
        } else {
          chatw = window.open('/app/member/chat.php?uid='+pid+'&stype='+stype, pid, 'resizable=yes,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=975,height=480');
        }
        window.close();
        chatw.focus();
      }
}


function openViewerHDVchat (uid, stype, fromSite) { //910*540
  if(fromSite)
     openNewWindow('/app/member/chat.php?hd=1&uid='+uid+'&stype='+stype+'&fromSite='+fromSite, 'HDChat'+uid, 'resizable=yes,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=940,height=507');
  else
     openNewWindow('/app/member/chat.php?hd=1&uid='+uid+'&stype='+stype, 'HDChat'+uid, 'resizable=yes,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=940,height=507');
}


function openInvitationVchat (uid, stype) {	// Updated on Nov. 6, 2009

	xmlFile		=	"/app/isshehd.php?uid="+uid;
	xmlhttp		= getXmlhttp();
	xmlhttp.open("GET", xmlFile, false);
	xmlhttp.send(null);
	ishd		=	xmlhttp.responseText;

	if(ishd == 1)	{
		openViewerHDVchat (uid, stype);
	} else {
		openViewerVchat (uid, stype);
	}
//  openNewWindow('/app/member/chat.php?uid='+uid+'&stype='+stype+'&invt=1', 'Chat'+uid, 'resizable=yes,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=808,height=550');
}

//	function openInvitationVchat (uid, stype) {
//	  openNewWindow('/app/member/chat.php?uid='+uid+'&stype='+stype+'&invt=1', 'Chat'+uid, 'resizable=yes,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=808,height=550');
//	}

function openInvitation() {
  openNewWindow('/app/performer/invitation.php', 'PFinvitation', 'resizable=yes,location=no,toolbar=no,scrollbars=yes,personalbar=no,menubar=no,status=no,width=165,height=550');
}

function openPerformerVchat() { //820*640
   openNewWindow('/app/performer/chat.php', 'Chat', 'resizable=yes,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=740,height=620');
}

function openPerformerNEWVchat() { //800*570
   openNewWindow('/app/performer/chat_new.php', 'Chat', 'resizable=yes,toolbar=no,scrollbars=no,personalbar=no,menubar=no,width=820,height=640');
}


function openPerformerHDVchat() { //990*520
   openNewWindow('/app/performer/chat.php?hd=1', 'HDChat', 'resizable=yes,toolbar=no,scrollbars=yes,personalbar=no,menubar=no,width=1320,height=700');
}

function openFavorites() {
	openNewWindow('/app/contact/index.php?favorite_flag=1', 'contact', '');
}

function openContact(id) {
        openNewWindow('/app/contact/index.php?mode=edit&contact_id='+id,'edit','width=675 height=450 scrollbars=yes resizable=yes')
}

function openGravureImage(uname, uid, event) {
  openNewWindow('popup.html?uname=' + uname + '&uid=' + uid + '&event=' + event, 'gravure'+uname, 'resizable=yes, toolbar=no, scrollbars=no, personalbar=no, menubar=no, width=665, height=505');
}

function checkUncheckAll(theElement) {
  var theForm = theElement.form;
	var z = 0;
	for(z=0; z<theForm.length; z++){
  	if(theForm[z].type == 'checkbox' && theForm[z].name != 'checkall'){
			theForm[z].checked = theElement.checked;
		}
  }
}

function getSessionType(user_name) {
	if(user_arr!=null) {
		var user = user_arr[user_name];
		if(user!=null) {
			return user.session_type;
		}
	}
	return 0;
}

function xmlHttpGet(strURL, elementId) {
  var xmlhttp = false;
  if(elementId == 'onlineArea'){
     var objOnline = getElementFromName(elementId);
     objOnline.innerHTML = 'Loading Performer Online';
  }

  if (window.XMLHttpRequest) {
    xmlhttp = new XMLHttpRequest(); //Mozilla/Safari
  } else if (window.ActiveXObject) { //IE
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
  if(!xmlhttp) return;
	strURL += (strURL.indexOf('?')>0?'&_rand=':'?_rand') + Math.random(); 
  xmlhttp.open('GET', strURL, true);
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      var obj = getElementFromName(elementId);
      if(obj) obj.innerHTML= xmlhttp.responseText;
			fixPNGImages(elementId);
    }
  }
  xmlhttp.send(null);
  return;
}

function getXmlhttp(){
  var xmlhttp;
    
  if(window.XMLHttpRequest) {
    try {
        xmlhttp = new XMLHttpRequest();
    } catch(e) {
	xmlhttp = false;
    }
  } else if(window.ActiveXObject) {
    try {
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch(e) {
       try {
           xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
       } catch(e) {
       		xmlhttp = false;
       }
    }
  }
  return xmlhttp;
}

function getElementFromName(nm){
  // IE5+, Mozilla, Opera
  if(document.getElementById) return document.getElementById(nm);
  if(document.all) return eval('document.all.' + nm); // IE4
  if(document.layers){ // NN4
    var s='';
    for(var i=1; i<arguments.length; i++)
      s+='document.layers.'+arguments[i]+'.';
    return eval(s+'document.layers.'+nm);
  }
  return null;
}

function openNewWindow(theURL,winName,features) {
	var w = window.open(theURL,winName,features);
	w.focus();
}

function openProfWindow(theURL) {
	var winName		=	"profile";
	var features	=	"width=800, height=800, menubar=no, toolbar=no, scrollbars=yes";
	var w = window.open(theURL,winName,features);
	w.focus();
}

var userName = '';
var userId = '';
var userType = '';
var hd = 0;
var nightworkAllow = 0;
var c = getCookie('NetiA');
if(c) {
	var arr = c.split(':');
	userName = arr[0];
}
c = getCookie('vauth');
if(c) {
  var arr = c.split(':');
  userName = arr[0];
  userId = arr[1];
  userType = arr[2];
  siteId = arr[3];
  nightwork = arr[4];
  hd = arr[7];
  nightworkAllow = arr[8];
}
// Just after first point purchase, userType changes from 208 to 205. So new_userType holds latest user_type from DB.
if(userType == 208) {
	new_userType	=	New_User_Type();
	if(userType != new_userType) {
		userType = new_userType;
	}
}

function isVIP() {
	return (userType==206)?true:false;
}
function isUser() {
  return (userType==205 || userType==207 || userType==208 || userType==215 || userType==220)?true:false;
}

function isMember() {
  if(isUser() || isVIP()) return true;
  else return false;
}

function isFreeUser() {
  return (userType==207 || userType==208)?true:false;
}

function isRegularUser() {
  return (userType==205)?true:false;
}

function isAdmin() {
  return (userType==215 || userType==220)?true:false;
}

function isPerformer() {
  return (userType==210)?true:false;
}

function isNightWork() {
  return (nightwork==1)?true:false;
}

function isHdPerformer() {
  return (hd == 1)?true:false;
}

// ---------------------------------------------------------------------------------
// Function for web and flash
// ---------------------------------------------------------------------------------
function openViewerPresent() {
  openNewWindow('/present.html', 'viewerpresent', 'location=yes, resizable=yes, toolbar=yes, scrollbars=yes, personalbar=yes, menubar=yes, width=1000, height=700');
}

function openPerformerPresent() {
  openNewWindow('/performer/present.html', 'performerpresent', 'location=yes, resizable=yes, toolbar=yes, scrollbars=yes, personalbar=yes, menubar=yes, width=1000, height=700');
}


function openVideoLibrary() {
  openNewWindow('/app/newsearch.php', 'videoLibrary', 'location=yes, resizable=yes, toolbar=yes, scrollbars=yes, personalbar=yes, menubar=yes, width=1000, height=700');
  //openNewWindow('/app/video/newsearch.php', 'videoLibrary', 'location=yes, resizable=yes, toolbar=yes, scrollbars=yes, personalbar=yes, menubar=yes, width=1000, height=700');
}

function openVideoHistory() {
  openNewWindow('/app/member/video_history.php', 'videoHistory' , 'location=yes, resizable=yes, toolbar=yes, scrollbars=yes, personalbar=yes, menubar=yes, width=850, height=700');
}

function openMileage() {
  openNewWindow('/app/member/mileage.php', 'memberMileage' , 'resizable=yes, toolbar=no, scrollbars=yes, personalbar=no, menubar=no, width=580, height=300');
}

function openPerformerMileage(){
  openNewWindow('/app/performer/mileage.php', 'performerMileage' , 'resizable=yes, toolbar=no, scrollbars=yes, personalbar=no, menubar=no, width=650, height=600');
}


function openMemberAccount() {
  openNewWindow('/app/member/account.php', 'memberMileage' , 'resizable=yes, toolbar=no, scrollbars=yes, personalbar=no, menubar=no, width=580, height=300');
}

function openNotification() {
  openNewWindow('/app/contact/index.php?favorite_flag=1', 'Notification' , 'resizable=yes, toolbar=no, scrollbars=yes, personalbar=no, menubar=no, width=700, height=500');
}

function openBBS() {
  //http://utility.exshot.com/cgi-bin/exvwrbbs/bbs.cgi
  openNewWindow('http://utility.exshot.com/cgi-bin/exvwrbbs/bbs.cgi', 'BBS', 'resizable=yes, toolbar=yes, scrollbars=yes, personalbar=yes, menubar=yes, width=850, height=700');
}

function openPerformerHelp() {
	if(isNightWork()) {
		openNewWindow('/performer910/howto_vc_functions.html', 'help' , '');
	} else {
		openNewWindow('/performer/howto_vc_functions.html', 'help' , '');
	}
}

function openViewerHelp() {
  openNewWindow('/function_chat.html', 'help' , '');
}

function openProfile(pname) {
  //openProfile('exshot/profile/profile.jsp','',perf_name,'true')
  openNewWindow('/profile/' + pname + '.html', 'profile' + pname, 'resizable=yes, location=no, toolbar=no, scrollbars=yes, personalbar=no, menubar=no, width=800, height=800');
}

function openPerformerProfile(pname) {
  openNewWindow('/profile/' + pname + '.html', 'smallprofile' + pname, 'resizable=yes, location=no, toolbar=no, scrollbars=yes, personalbar=no, menubar=no, width=700, height=690');
}

function openProfileEX(pname) {
  openNewWindow('http://www.kanjukulive.com/profile/' + pname + '.html', 'profile' + pname, 'resizable=yes, location=no, toolbar=no, scrollbars=yes, personalbar=no, menubar=no, width=700, height=690');
}

function openProfileCEX(pname) {
  openNewWindow('http://club.exshot.com/profile/' + pname + '.html', 'profile' + pname, 'resizable=yes, location=no, toolbar=no, scrollbars=yes, personalbar=no, menubar=no, width=700, height=690');
}


function openSendMail(uname) {
  // openSendMail(pname)
  openNewWindow('/app/mailbox/index.php?mode=compose&toidlist=' + uname , 'mailbox' , '');
}

function openMailbox() {
  // openMailbox()
  openNewWindow('/app/mailbox/index.php', 'mailbox' , 'resizable=yes, location=no, toolbar=no, scrollbars=yes, personalbar=no, menubar=no');
}

function openViewerProfile(uname) {
  //openViewerProfile(uname)
  openNewWindow('/app/performer/member_profile.php?uname='+uname, 'viewerProfile', 'resizable=yes, toolbar=no, scrollbars=yes, personalbar=no, menubar=no, width=700, height=500');
}

function openPerformerMemo(uid) {
  //openPerformerMemo(viewerName)
  openNewWindow('/app/contact/index.php?mode=edit&contact_id='+uid, 'contact', '');
}

function closeCurrentWindow(sec) {
  //case: viewer's connection to flash server has closed via logout button
  //js call: closeCurrentWindow(.1)  (parameter is delay before closing window)
  if (sec == '' || sec == null)
  	sec = 0.1;
  window.setTimeout('window.close()',sec*100);
  
}

function setBan(channel) {
  //case: perf has kicked a viewer
  //js call: setBan(channel)  (parameter 'channel' is the performer ID)
}

function openRegularJoin() {
  //case: point purchase has failed
  //openNewWindow('/exshot/'+pagetype+'/addpoint.jsp','AddPoints','menubar=yes,location=yes,resizable=yes,scrollbars=yes,status=yes,toolbar=yes')
  openNewWindow('/join.html', 'join', '');
}

function openVIPJoin() {
  openNewWindow('/join.html', 'join', '');
}

////////////////////////////////////////

function page_reload(){

if(!opener.window.userId)   
   window.opener.location.reload();
      
// if(document.referrer != '' || document.referrer)
//   alert(document.referrer);
// else
//   alert(document.referrer+"no referrer"+userId);   

}

function fixPNGImages(areaID) {
	var arVersion = navigator.appVersion.split("MSIE");
	var version = parseFloat(arVersion[1]);
	if ((version >= 5.5) && (document.body.filters)) {
		var pngAreaObj=document.getElementById(areaID);
		var pnglist=pngAreaObj.getElementsByTagName("img");

		for(var i=0; i<pnglist.length; i++){
			var img = pnglist[i];
			var imgName = img.src.toUpperCase();
			if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
				var imgID = (img.id) ? "id='" + img.id + "' " : "";
				var imgClass = (img.className) ? "class='" + img.className + "' " : "";
				var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' ";
				var imgStyle = "display:inline-block;" + img.style.cssText;
				if (img.align == "left") imgStyle = "float:left;" + imgStyle;
				if (img.align == "right") imgStyle = "float:right;" + imgStyle;
				if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle;
				var strNewHTML = "<span " + imgID + imgClass + imgTitle
					+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
					+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
					+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>";
				img.outerHTML = strNewHTML;
				i = i-1;
			}
		}
  }
}

function writeFavoriteTitle(mode) {
  var str = '';
  str += '<ul>';

  str += '<li id="favorite01"><a href="javascript:;" onClick="openFavorites();return false;">お気に入りの女の子編集</a></li>';

  if (isUser()) {
    if (mode == 'no_expand') str += '<li id="favorite02"><a href="javascript:;" onClick="xmlHttpGet(\'/app/search.php?favorite=1&limit=16&tpl=favorite&get_hits=0\', \'favoriteArea\'); writeFavoriteTitle(\'expand\');">お気に入りの女の子>をすべてみる。</a></li>';
    if (mode == 'expand') str += '<li id="favorite02ON"><a href="javascript:;" onClick="xmlHttpGet(\'/app/search.php?favorite=1&limit=8&tpl=favorite&get_hits=0\', \'favoriteArea\'); writeFavoriteTitle(\'no_expand\');">お気に入りの女の子をすべてみる。</a></li>';
  } else if (isVIP()) {
    if (mode == 'no_expand') str += '<li id="favorite02"><a href="javascript:;" onClick="xmlHttpGet(\'/app/search.php?favorite=1&limit=40&tpl=favorite&get_hits=0\', \'favoriteArea\'); writeFavoriteTitle(\'expand\');">お気に入りの女の子>をすべてみる。</a></li>';
    if (mode == 'expand') str += '<li id="favorite02ON"><a href="javascript:;" onClick="xmlHttpGet(\'/app/search.php?favorite=1&limit=8&tpl=favorite&get_hits=0\', \'favoriteArea\'); writeFavoriteTitle(\'no_expand\');">お気に入りの女の子をすべてみる。</a></li>';
  }
  str += '</ul>';

  obj = getElementFromName("favoriteTab");
  if (obj) obj.innerHTML = str;
}

function writeRSSTitle(mode) {
  var str = '';
  str += '<ul>';
  str += '<li id="RSS01"><a href="/app/news.php">新着情報</a></li>';
  str += '<li id="RSS02"><a href="/exshot/news/news.xml" target="_blank">ＲＳＳフィード</a></li>';
  if (mode == 'no_expand') str += '<li id="RSS03"><a href="javascript:;" onClick="xmlHttpGet(\'/app/news.php?tpl=home&limit=10\', \'RSS\');writeRSSTitle(\'expand\');">お得な情報が満載！今すぐチェック！すべて見る >></a></li>';
  if (mode == 'expand') str += '<li id="RSS03ON"><a href="javascript:;" onClick="xmlHttpGet(\'/app/news.php?tpl=home&limit=5\', \'RSS\');writeRSSTitle(\'no_expand\');">お得な情報が満載！今すぐチェック！すべて見る >></a></li>';
  str += '</ul>';

	obj = getElementFromName('RSStitle');
  if(obj) obj.innerHTML = str;
}

function writeFlash( swf , width , height )
{
  var html = ""
 
  html+="<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'"
  html+="        width   = " + width
  html+="        height  = " + height + ">"
  html+="<param  name    = movie value=" + swf + ">"
  html+="<param  name    = quality value=high>"
  html+="<param name='wmode' value=transparent>"
  html+="<embed  src     = " + swf + " "
  html+="        wmode=transparent"
  html+="        quality = high  "
  html+="        width   = "+ width
  html+="        height  = " + height
  html+="        type    = 'application/x-shockwave-flash' "
  html+="        pluginspage='http://www.macromedia.com/go/getflashplayer'>"
  html+="</embed>"
  html+="</object>"
  
  document.write(html)
}

function ajaxRequest(url, method, params){

    xmlhttp = getXmlhttp();
    var params  = params;
    url     = url;
    var method  = method;
    result  = "";

    if(method.toUpperCase() == 'GET'){
       url = url + '?' + params;
    }
    xmlhttp.open(method, url, true);

    if(method.toUpperCase() == 'POST'){
      xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      xmlhttp.setRequestHeader("Content-length", params.length);
      xmlhttp.setRequestHeader("Connection", "close");
    }
 
    xmlhttp.onreadystatechange = function(){
     if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
       result = xmlhttp.responseText;
     }
    }
   xmlhttp.send(params);
//alert(result);
 return result;

}
 
function isPopupBlocker(){
  var mine = window.open('','','width=1,height=1,left=0,top=0,scrollbars=no');
  if(mine)
     var popUpsBlocked = false;
  else
     var popUpsBlocked = true;

  if(mine) mine.close();
  
  return (popUpsBlocked) ? true : false;
}

function getFlashMovie(movieName) {
	//alert(movieName);
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  var isChrome = navigator.userAgent.indexOf("Chrome") != -1;
  return (isIE || isChrome ) ? document.getElementById(movieName) : document[movieName];
}

function pauseVideo(videoname) {
  getFlashMovie(videoname).pauseVideo();
}

function enlargevideo(videoname) {
  pauseVideo(videoname);
  if(userType)
    openVideoPlayer(videoname);
  else
    openVideoPlayerPromo(videoname);
}

function openlargevideo(videoname) {
  if(userType)
    openVideoPlayer(videoname);
  else
    openVideoPlayerPromo(videoname);
}

function add_point_campaign_not_use() {
  if (campaign) {
    var xmlhttp = getXmlhttp();
    var url = "/app/free_points.php";
    xmlhttp.open('GET', url, true);
    xmlhttp.onreadystatechange = function(){
     if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
       res = xmlhttp.responseText;
       //alert(res);
       if(res == 1){
         agreewin=dhtmlmodal.open("agreebox", "iframe", page, title, "width=300px,height=200px,center=0,resize=1,scrolling=1,left=0,top=0,screenX=0,screenY=100'", "recal");
       }
     }
    }
   xmlhttp.send(null); 
  }
}

function vVote(to_user, campaign){
    var params = "to_user=" + to_user + "&campaign=" +campaign;
    var xmlhttp = getXmlhttp();
    var url = "/app/member/vote.php";
    xmlhttp.open('POST', url, true);
    xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlhttp.setRequestHeader("Content-length", params.length);
    xmlhttp.setRequestHeader("Connection", "close");
    xmlhttp.onreadystatechange = function(){
     if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
       res = xmlhttp.responseText;
       if(res == 1){
         alert("投票しました。 ");
       }else{
         alert("投票はお一人様1回限りです。 ");
       }
     }
    }
   xmlhttp.send(params);
}

function check_browser_version(){
  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  if (isIE) {
     var arVersion = navigator.appVersion.split("MSIE");
     var version = parseFloat(arVersion[1]);
     return version;
  }
  return 7;
}

function refresh_d2pbar(){
   var version = check_browser_version();
   if (version <= 6 ) return true;

   var url = "/d2ptb";
   var xmlhttp = getXmlhttp();
   xmlhttp.open('GET', url, true);
   xmlhttp.onreadystatechange = function() {
     if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
         var str = xmlhttp.responseText;
         str = str.replace(/a:/g, "div#d2ptool a:");
         var obj = document.getElementById("d2toolbar");
         if(obj) obj.innerHTML= str;
     }else{
       return;
     }
   }
  xmlhttp.send(null);
}

// D2P Bookmark Project
function d2pbook_popitup(url) {
	newwindow=window.open(url,'name','height=300,width=500, menubar=0, resizable=0, location=0, status=0');
	if (window.focus) {newwindow.focus()}
	return false;
}

function New_User_Type(){
	if(userId > 0) {
		xmlFile	="/app/getuserinfo.php?uid="+userId;
		xmlhttp	= getXmlhttp();
		xmlhttp.open("GET", xmlFile, false);
		xmlhttp.send(null);
		xmluinf	=	xmlhttp.responseXML;
		if(xmluinf.documentElement)	{
			// IE
			xmluser	=	xmluinf.getElementsByTagName('user')[0];
			NewUserType	=	xmluser.childNodes[4].firstChild.nodeValue;
		}	else	{
			// Other
			NewUserType	=	xmluinf.getElementsByTagName('user_type')[0].textContent;
		}
	} else	{
		NewUserType	=	"";
	}
	return NewUserType;
}

function refresh_usertype(){
	userType	=	New_User_Type();
}

function savethumbmsg(uname, uid, eid) {
	str		=	document.getElementById(eid).value
	encmsg	=	encodeURI(str);
    var xmlhttp = getXmlhttp();
    var url = "/app/performer/thumbmsg.php?pfnm="+uname+"&id="+uid+"&msg="+encmsg;
    xmlhttp.open('POST', url, true);
    xmlhttp.onreadystatechange = function(){
     if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
       res = xmlhttp.responseText;
       //alert(res);
       if(res == 1){
         //alert("success");
         readthumbmsg(uname, uid, eid);
       } else {
         alert(res);
       }
     }
    }
   xmlhttp.send(null); 
   // load the box
}

function readthumbmsg(uname, uid, eid) {
    var xmlhttp = getXmlhttp();
    var url = "/app/performer/thumbmsg.php?pfnm="+uname+"&id="+uid+"&read=1";
    //alert(url);
    xmlhttp.open('POST', url, true);
    xmlhttp.onreadystatechange = function(){
     if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
       res = xmlhttp.responseText;
       rtcode	=	res.substr(0, 2);
       if(rtcode == "OK"){
         alert("更新しました");
         rtmsg	=	res.substr(2);
         //alert(rtmsg);
         document.getElementById(eid).value = rtmsg;
       }else{
         alert("更新できませんでした");
       }
     }
    }
   xmlhttp.send(null); 
}

function checkthumbmsglen(str) {
	if(str.length <= 15) {
		return true;
	} else {
		alert("15文字以内です。");
		return false;
	}
}

function openProf(pfname){
	window.open('/profile/'+pfname+'.html',pfname,'resizable=yes, location=no, toolbar=no, scrollbars=yes, personalbar=no, menubar=no, width=670, height=920');void(0);
}

function checkOldFirefox(paramstr) {
	// Return 1 whe the brower is FireFox and the version is Older Than 3.6.
	var USAGENT = navigator.userAgent;

	ffloc		=	USAGENT.indexOf("Firefox");
	oldfirefox	=	0;

	if( ffloc > -1 )	{
		vernum	=	ffloc	+ 8;
		verstr = USAGENT.substring(vernum,vernum + 4);

		if(paramstr != 0)	{
			verstr = paramstr;
		}
		//document.write('<br>');
		//document.write(verstr);

		lastvarstr	=	verstr.substr(3,1);

		if(lastvarstr.match(/[0-9]+/g))	{
			//document.write('<br>');
			//document.write("Numeric desu");
		}	else	{
			//document.write('<br>');
			//document.write("Not Numeric");
			verstr	=	verstr.substr(0,3);
			//document.write(verstr);
		}

		flverstr = parseFloat(verstr);
		if(flverstr <= 3.6)	{
			//document.write('<br>');
			//document.write("FireFox 3.6 or Older");
			oldfirefox	=	1;
		}	else	{
			//document.write('<br>');
			//document.write("FireFox Not 3.6 but Newer");
			oldfirefox	=	0;
		}
	}
	return oldfirefox;
}

//-->


