var base_url = "http://www.exshot.com/app";

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 search_v(name){
  
  xmlhttp = getXmlhttp();

if(document.getElementById("all").checked)
   var c_type = 999;
else if(document.getElementById("normal").checked)
   var c_type = 422;
else if(document.getElementById("premium").checked)
   var c_type = 423;
else
   var c_type = 999;            
   
var page = name;   
var sort = document.getElementById("sort").value;   
var list_num = document.getElementById("list_num").value;
   
var s_year = document.getElementById("s_Year").value;
var s_month = document.getElementById("s_Month").value;
var s_day = document.getElementById("s_Day").value;
var s_date = s_year+"-"+s_month+"-"+s_day;
   
var e_year = document.getElementById("e_Year").value;
var e_month = document.getElementById("e_Month").value;
var e_day = document.getElementById("e_Day").value;
var e_date = e_year+"-"+e_month+"-"+e_day;
         
var param = "action=list_video&list_num="+list_num+"&s_date="+s_date+"&e_date="+e_date+"&c_type="+c_type+"&sort="+sort+"&page="+page;
var url = "/app/performer/video_history.php";
  
xmlhttp.open("get", url+"?"+param, true);

xmlhttp.onreadystatechange = function() {
    
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      document.getElementById("result").innerHTML = xmlhttp.responseText;
    }
  }
  xmlhttp.setRequestHeader("Content-Type" , "application/x-www-form-urlencoded");
  xmlhttp.send(null);
  
  return false;
}

function get_video_detail(video_id, column, desObj){
    url = "/app/video/newsearch.php?mode=get_data&video_id="+video_id+"&field="+column;
    xmlhttp = getXmlhttp();
    xmlhttp.open('GET', url, true);
    xmlhttp.onreadystatechange = function(){
     if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
       result = xmlhttp.responseText;
       if(desObj) {
          desObj.innerHTML = "";
          desObj.innerHTML = result;
       }
     }
    }
   xmlhttp.send(null);
}

 function addToFavorite(mediaId) {
    var xmlhttp = getXmlhttp();
    var url = "/app/video/newsearch.php?mode=favorite&video_id="+mediaId;
    xmlhttp.open('GET', url, true);
    xmlhttp.onreadystatechange = function(){
     if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
       res = xmlhttp.responseText;
       if(res == 1)
         alert("お気に入りに追加しました");
       else
         alert("failed");
     }
    }
   xmlhttp.send(null);
 }

  function rmFrmFavorite(mediaId) {
    if(confirm("お気に入りから削除します")){
      var xmlhttp = getXmlhttp();
      var url = "/app/video/newsearch.php?mode=favorite&video_id="+mediaId+"&rm=1";
      xmlhttp.open('GET', url, true);
      xmlhttp.onreadystatechange = function(){
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
          res = xmlhttp.responseText;
          window.location.reload( false );
        }
      }
	xmlhttp.send(null);
   }
 }


/***********************************************
* Drop Down/ Overlapping Content- ?? Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var faderTimer;
var divId;
var divHeight;
var newDivHeight;
var overlayXOffset;
var overlayYOffset;
var linkobj;

function getposOffset(overlay, offsettype){
        var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
        var parentEl=overlay.offsetParent;
        while (parentEl!=null){
                totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
                parentEl=parentEl.offsetParent;
        }
        return totaloffset;
}


function openSubvideo(curobj, subobjstr, opt_position, user_id, element_id, Xoffset, Yoffset){
        originalObj = curobj;
        linkobj = document.getElementById(element_id+"_link");
        linkobj.style.width = "600px";
        xmlHttpGet('/app/video/newsearch.php?mode=subvideo&user_id='+user_id+'&elementId='+element_id, 'subcontent2');
        overlayXOffset =  Xoffset;
        overlayYOffset =  Yoffset;
        return overlay(curobj, subobjstr, opt_position);
}


function overlay(curobj, subobjstr, opt_position){
        if (document.getElementById){
        var subobj=document.getElementById(subobjstr);
        linkobj.innerHTML = (subobj.style.display!="block")? "ビデオリストを閉じる" : "ビデオリストを開く";
        subobj.style.display=(subobj.style.display!="block")? "block" : "none";        
        var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0);
        var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0);
        xpos+=overlayXOffset;
        ypos+=overlayYOffset;
        subobj.style.left= xpos+"px";
        subobj.style.top=ypos+"px";
        return false;
        }
        else
        return true;
}

function closeLayer() {
  overlayclose('subcontent3');
  return false;
}

function overlayclose(subobj){
        divId = subobj;
        divHeight = ((document.getElementById(subobj).style.height).substring(0,(document.getElementById(subobj).style.height).indexOf("px")));
        newDivHeight = divHeight;
        fadeDiv();
}

function fadeDiv(){
        var divObj = document.getElementById(divId);
        newDivHeight = newDivHeight - 10;
        divObj.style.height = newDivHeight + "px";
        faderTimer = setTimeout('fadeDiv()',1);
        if (newDivHeight < 10){
                clearTimeout(faderTimer);
                closeDiv();
        }
}

function closeDiv(){
        var divObj = document.getElementById(divId);
        document.getElementById(divId).style.display="none";
        divObj.style.height = divHeight;
}

function ismaxlength(obj){
        var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
        if (obj.getAttribute && obj.value.length>mlength){
        }
}


