// JavaScript Document
var maxWindowHeight;


window.onresize= SetMinWindowSize;
function SetMinWindowSize() {
  var dX = GetSizeWindow('x');
  var obj = GetObject1('hmTable');
  if (dX <= 930) {	  
	  obj.width = 930+'px';
  }
  else {
	  obj.width = '100%';
  }
}


function GetObject(objId)
{
	var myN6 = document.getElementById; // ブラウザ(N6)のチェック用
	//var myIE = document.all;            // ブラウザ(IE)のチェック用
	var myN4 = document.layers;         // ブラウザ(N4)のチェック用
	var obj;
		
	if (document.all) {
		obj = document.all[objId];		
		maxWindowHeight = document.documentElement.scrollTop + document.documentElement.clientHeight;			
	}
	else if (myN6) {
		obj = document.getElementById(objId);
		maxWindowHeight = window.pageYOffset + window.innerHeight;	
	}
	else if (myN4) {
		obj = document[objId];
		maxWindowHeight = window.pageYOffset + window.innerHeight;
	}
	return obj;
}

function GetObject1(objId)
{
	var myN6 = document.getElementById; // ブラウザ(N6)のチェック用
	var myIE = document.all;            // ブラウザ(IE)のチェック用
	var myN4 = document.layers;         // ブラウザ(N4)のチェック用
	var obj;
	if (myIE) {
		//obj = document.all[objId];		
		obj = document.getElementById(objId);	
	}
	else if (myN6) {
		obj = document.getElementById(objId);
	}
	else if (myN4) {
		obj = document[objId];
	}
	return obj;
}

function expandSELECT(sel) {
	if (navigator.appName == "Microsoft Internet Explorer") {
		sel.style.width = 'auto';
	}
}

function contractSELECT(sel) {
	if (navigator.appName == "Microsoft Internet Explorer") {
		sel.style.width = '180px';
	}
}

function GetNumItemPerRow(n)
{
	var myN6 = document.getElementById; // ブラウザ(N6)のチェック用
	var myIE = document.all;            // ブラウザ(IE)のチェック用
	var myN4 = document.layers;         // ブラウザ(N4)のチェック用	
	var WinWidth;
	var num, ShowWidth;
	
	if (myIE) {		
		WinWidth = document.documentElement.clientWidth;			
	}
	else if (myN6) {		
		WinWidth =  window.innerWidth;	
	}
	else if (myN4) {		
		WinWidth =  window.innerWidth;
	}
	
	switch (n) {
		case 1: // for Search page
			ShowWidth = WinWidth -(21 + 210 + 10 + 21);
			break;
		case 2: // for keep page
			ShowWidth = WinWidth;
			break;
		case 3: // for holder of footages
			ShowWidth = WinWidth -(21 + 21);
			break;		
	}
	
	num = Math.floor(ShowWidth/195);
	return parseInt(num);
}

function GetSizeWindow(type)
{
	var Width;
	var myWidth = 0, myHeight = 0;
  	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
  	}

	if ((type == "x") || (type == "X")) {
		Width = myWidth;			
	}
	else {
		Width = myHeight;			
	}
	
	return Width;
}

/*
機能：マイ・E好箸魍・渥
*/
function openmylist(hostname)
{
	window.open(hostname+"/keep.php", "mykeep", "width=870px, height=500px, location=no, directories=no, left=300px, menubar=no, resizable=yes, scrollbars=yes, status=no, toolbar=no, top=0px");	
}

function openmycart(hostname)
{
	window.open(hostname+"/cart.php", "mycart", "width=920px, height=500px, location=no, directories=no, left=300px, menubar=no, resizable=yes, scrollbars=yes, status=no, toolbar=no, top=0px");	
}

function movie(materialid, aspect)
{
	var widthx, widthy;	
	
	if (aspect == 1) {
		widthx = 740;
		widthy = 760;
	}
	else {
		widthx = 810;
		widthy = 700;
	}
	window.open("video.php?id="+materialid+"&aspect="+aspect, "video", "width="+widthx+", height="+widthy+", location=no, directories=no, left=300px, menubar=no, resizable=no, scrollbars=yes, status=no, toolbar=no, top=0px");
}

function photo(photoid, aspect)
{	
	var widthx, widthy;	
	if (aspect==1) {
		widthx = 850;
		widthy = 630;
	}
	else {
		widthx = 780;
		widthy = 790;	
	}

	window.open("photo.php?id="+photoid+"&aspect="+aspect, "photo", "width="+widthx+", height="+widthy+", location=no, directories=no, left=300px, menubar=no, resizable=no, scrollbars=yes, status=no, toolbar=no, top=0px");
}

function photo1(photoid, aspect)
{	
	var widthx, widthy;	
	if (aspect==1) {
		widthx = 850;
		widthy = 630;
	}
	else {
		widthx = 780;
		widthy = 790;	
	}

	window.open("photo/photo.php?id="+photoid+"&aspect="+aspect, "photo", "width="+widthx+", height="+widthy+", location=no, directories=no, left=300px, menubar=no, resizable=no, scrollbars=yes, status=no, toolbar=no, top=0px");
}


function movie1(materialid, aspect, start, end)
{
	var widthx, widthy;	
	
	if (aspect == 1) {
		widthx = 740;
		widthy = 760;
	}
	else {
		widthx = 810;
		widthy = 700;
	}
	window.open("video.php?id="+materialid+"&aspect="+aspect+"&start="+start+"&end="+end+"&type=1", "video", "width="+widthx+", height="+widthy+", location=no, directories=no, left=300px, menubar=no, resizable=no, scrollbars=yes, status=no, toolbar=no, top=0px");
}

function open_previewmovie_holder(autherid, materialno, aspect)
{
	var widthx, widthy;	
	
	if (aspect == 1) {
		widthx = 740;
		widthy = 560;
	}
	else {
		widthx = 810;
		widthy = 500;
	}
	window.open("video.php?autherid="+autherid+"&materialno="+materialno+"&aspect="+aspect, "video", "width="+widthx+", height="+widthy+", location=no, directories=no, left=300px, menubar=no, resizable=no, scrollbars=yes, status=no, toolbar=no, top=0px");
}


function doRdClick(filename) 
{	
	document.forms["frmRdType"].action = filename;
	document.forms["frmRdType"].submit();
}


function doLTrim(str)
{
	var i = 0;
	while( (str.substr(i, 1) == " ") && (i < str.length) ) i++;
	return str.substr(i);
}

function isValidEmail(str)
{
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function isValidPhone(str)
{
	var strtemp = "0123456789";
	for(var i=0; i < str.length; i++)
	{
		if (strtemp.indexOf(str.substr(i, 1)) == -1) {
			return false;
		}
	}
	return true;
}