//<!-
// Function for Web
function openVideoPlayer(mediaID) {
  openNewWindow("/app/video/video_player.php?vid=" + mediaID,"","width=360,height=395,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 openPreview(uid) {
  openWindow('/app/preview.php?uid='+uid, 'preview', 700, 400); 
}

function openPreviewByName(uname) {
  openWindow('/app/preview.php?uname='+uname, 'preview', 700, 400); 
}

function openBigPreview(uid) {
  openWindow('/app/preview.php?tpl=big&uid='+uid, 'preview', 620, 685); 
}

function openVideoPlayer(mediaID) {
  openNewWindow("/app/video/video_player.php?vid=" + mediaID,"","width=360,height=395,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 openViewerVchat (uid, stype) {
  openWindow('/app/member/chat.php?uid='+uid+'&stype='+stype, 'Chat'+uid, 810, 510); 
}

function openPerformerVchat() {
  openWindow('/app/performer/chat.php', 'Chat', 810, 510); 
}

function openFavorites() {
//	openNewWindow('/app/contact/index.php?favorite_flag=1', 'contact', '');
}

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 (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;
  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;
    }
  }
  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 for web and flash
// ---------------------------------------------------------------------------------
function openVideoLibrary() {
  //http://www.exshot.com/exshot/videoLibrary/performerLibrary.jsp
  openNewWindow('/app/performer/video.php', 'videoLibrary', '');
}

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 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() {
  //http://www.exshot.com/exshot/performer2/howto_vc_functions.jsp
  openNewWindow('/performer/howto.html', 'help' , '');
}

function openViewerHelp() {
  //http://www.exshot.com/exshot/share/howto_chat.jsp
  openNewWindow('/howto/index.html', 'help' , '');
}

function openProfile(pname) {
  openNewWindow('/profile/' + pname + '.html', 'profile' + pname, 'resizable=yes, location=no, toolbar=no, scrollbars=yes, personalbar=no, menubar=no, width=560, 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' , '');
}

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?action=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)

}

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 redirect(flashPerformerName , flashPerformerId) {
  openBigPreview(flashPerformerName,flashPerformerId,'true');
}


////////////////////////////////////////
var userName = '';
var userId = '';
var userType = '';
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];
}
function isVIP() {
	return (userType==206)?true:false;
}
function isUser() {
  return (userType==205 || userType==207 || userType==208 || userType==215 || userType==220)?true:false;
}
function isPerformer() {
	return (userType==210)?true:false;
}
function getUserType() {
 if(userType != null){
    return userType;
 }
 return '';
}
function writeGoodsFormInput(points) {
   var str = '';
   str = '<input type=hidden size="4" value="';
     if(points == 10) {
			if(getUserType() == 207) { str = str + "1007501"; }
			else { str = str + "1006121"; }
     }
     if(points == 30) {
			if(getUserType() == 207) { str = str + "1007511"; }
			else { str = str + "1006201"; }
     }
     if(points == 40) {
			if(getUserType() == 207) { str = str + "1007521"; }
			else { str = str + "1006241"; }
     }
     if(points == 60) {
			if(getUserType() == 207) { str = str + "1007531"; }
			else { str = str + "1006261"; }
   }
    str = str + '" name="goods_id">';
    
    return str;
}
//-->
