<!--//
function loadImage() { 
	var rollover = new Array();
	for (var i=0; i < 22 ; i++) {
		rollover[i] = new Image();
	}
}


function close_win(){
    window.opener = window;
    var win = window.open(location.href,"_self");
    win.close();
}
	
	
function _JumpURLnewWin(url,sizeX,sizeY) 
{
  if (url != ''){
    win=window.open(url,"a","scrollbars=1,resizable=yes,width=" + sizeX + ",height=" + sizeY);
	
	scrXr = screen.width;
	scrYr = screen.height;
	win.moveTo( scrXr*0.16, scrYr*0.16 );
	win.focus()
  }
}
function _TargetWinOpen(url,sizeX,sizeY,target) 
{
  if (url != ''){
    win=window.open(url,target,"scrollbars=1,resizable=yes,width=" + sizeX + ",height=" + sizeY);
  }
}
function SelectJumpURL(obj) 
{
  url = obj.options[obj.selectedIndex].value;
  if (url != '')
  {
    window.location = url;
  }
}

function NewWinDetail(url) 
{
	window.open(url, 'photodetail', 'width=500, height=500, menubar=no, toolbar=no, scrollbars=no, location=no, status=no, resizable=no')
}

//-->


function changecolor(open_ck)
{
	var gd_pno = document.getElementById('gd_pno').value;
	var gd_color = document.getElementById('gd_color').value;
	var gd_size = document.getElementById('gd_size').value;
	var url = 'http://pj28.cyberstar.co.jp/goods/getstock/';
	var pars = 'gd_color=' + gd_color + '&gd_size=' + gd_size + '&gd_pno=' + gd_pno + '&open_ck=' + open_ck;
	
	var myAjax = new Ajax.Request(
		url, 
		{
			method: 'post', 
			parameters: pars, 
			onSuccess:function(httpObj){
				if(httpObj.responseText != ''){
					$("order").innerHTML = httpObj.responseText;
				}
			},
			onFailure:function(httpObj){
				$("order").innerHTML = "エラーで読み込めませんでした";
			}
		});
	
}

//ポップアップ展開
function subWindowOpen(html, winname, w, h){
  var x = 2;
  var y = 2;

  subwin = window.open(html,winname,'resizable=0,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,width='+w+',height='+h+',screenX='+x+',screenY='+y+',left='+x+',top='+y);
  subwin.focus();
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function changeImg(iName,img){
	document.images[iName].src=img;
}

//タブ切り替え(ナウナビ使用) 画像名を[_select][_noselect]で保存

function seltab(bpref, hpref, id_max, selected) {
  if (! document.getElementById) return;
  for (i = 0; i <= id_max; i++) {
    if (! document.getElementById(bpref + i)) continue;
    if (i == selected) {
      document.getElementById(bpref + i).style.display= "block";
//	  document.getElementById(hpref + i).setAttribute("src", document.getElementById(hpref + i).getAttribute("src").replace("_noselect.", "_select."));

    } else {
      document.getElementById(bpref + i).style.display = "none";
//	  document.getElementById(hpref + i).setAttribute("src", document.getElementById(hpref + i).getAttribute("src").replace("_select.", "_noselect."));
    }
  }
}
// 
// $j = jQuery.noConflict();
// 
// SITE = {  
// basepath : '/',  
// preloader : {  
// loadedImages: [],  
// load: function (url){  
// var img = this.loadedImages;  
// var l = img.length;  
// img[l] = new Image();  
// img[l].src = url;  
// }
// }
// };
// 
// $j(function(){
// $j('img.roll').each(function(){
// this.originalSrc = $j(this).attr('src');
// this.rolloverSrc = this.originalSrc.replace(/(\.gif|\.jpg|\.png)/, "_over$1");
// SITE.preloader.load(this.rolloverSrc);
// });  
// $j('img.roll').not($j('.rollgroup .roll, .current .roll')).hover(function(){
// $j(this).attr('src',this.rolloverSrc);
//   },function(){
// $j(this).attr('src',this.originalSrc);
// });
// });


var tooltip=function(){
	var id = 'tt';
	var top = 3;
	var left = 3;
	var maxw = 500;
	var speed = 10;
	var timer = 20;
	var endalpha = 85;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = 'block';
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();


// document.onmousedown = function(){
//  var e=arguments[0]||event;
//  var x=zxcWWHS()[2]+e.clientX;
//  var y=zxcWWHS()[3]+e.clientY;
//  document.onmousemove=function(){
//  var e=arguments[0]||event;
//    window.scroll(x-e.clientX, y-e.clientY);
//    return false;
//  }
//  document.onmouseup=function(){
//    document.onmousemove=null;
//  }
//  return false;
// }

function zxcWWHS(){
 if (window.innerHeight) return [window.innerWidth-10,window.innerHeight-10,window.pageXOffset,window.pageYOffset];
 else if (document.documentElement.clientHeight) return [document.documentElement.clientWidth-10,document.documentElement.clientHeight-10,document.documentElement.scrollLeft,document.documentElement.scrollTop];
 return [document.body.clientWidth,document.body.clientHeight,document.body.scrollLeft,document.body.scrollTop];
}

window.onload = function() {
	HtinyScrolling.init(); scrollTips.init();
}

function gotoit(target){
	HtinyScrolling.scrollToIt(target);
}

// var HtinyScrolling = {
// 	speed : 20,      //set here the scroll speed: when this value increase, the speed decrease.
// 	maxStep: 100,	 //set here the "uniform motion" step for long distances
// 	brakeK: 5,		 //set here the coefficient of slowing down
// 	hash:null,
// 	currentBlock:null,
// 	requestedX:0,
// 	init: function() {
// 		var lnks = document.getElementsByTagName('a');
// 		for(var i = 0, lnk; lnk = lnks[i]; i++) {
// 			if ((lnk.href && lnk.href.indexOf('#') != -1) &&  ( (lnk.pathname == location.pathname) ||
// 			('/'+lnk.pathname == location.pathname) ) && (lnk.search == location.search)) {
// 			addEvent(lnk,'click',HtinyScrolling.initScroll,false);
// 			lnk.onclick=function(){return false;} // Safari
// 			}
// 		}
// 	},
// 	getTarget: function(target) {
// 		while(target.tagName.toLowerCase() != 'a')
// 			target = target.parentNode;
// 		return target;
// 	},
// 	getElementXpos: function(el){
// 		var x = 0;
// 		while(el.offsetParent){
// 			x += el.offsetLeft;
// 			el = el.offsetParent;
// 		}	return x;
// 	},
// 	getScrollLeft: function(){
// 		if(document.all) return (document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
// 		else return window.pageXOffset;
// 	},
// 	getWindowWidth: function(){
// 		if (window.innerWidth)	return window.innerWidth;
// 		if(document.documentElement && document.documentElement.clientWidth) return document.documentElement.clientWidth;
// 	},
// 	getDocumentWidth: function(){
// 		if (document.width) return document.width;
// 		if(document.body.offsetWidth) return document.body.offsetWidth;
// 	},
// 	initScroll: function(e){
// 		var targ;
// 		if (!e) var e = window.event;
// 		if (e.target) targ = e.target;
// 		else if (e.srcElement) targ = e.srcElement;
// 		targ = HtinyScrolling.getTarget(targ);  //a fix by Skid X
// 		HtinyScrolling.hash = targ.href.substr(targ.href.indexOf('#')+1,targ.href.length);
// 		HtinyScrolling.currentBlock = document.getElementById(HtinyScrolling.hash);
// 		if(!HtinyScrolling.currentBlock) return;
// 		HtinyScrolling.requestedX = HtinyScrolling.getElementXpos(HtinyScrolling.currentBlock);
// 		HtinyScrolling.scroll(targ);
// 		return false;
// 	},
// 	scrollToIt: function(targ){ //thanks to Michael Ionita-Ganea
// 		target = document.getElementById(targ);
// 		HtinyScrolling.currentBlock = document.getElementById(targ);
// 		if(!HtinyScrolling.currentBlock) return;
// 		HtinyScrolling.requestedX = HtinyScrolling.getElementXpos(HtinyScrolling.currentBlock);
// 		HtinyScrolling.scroll(target);
// 		return false;
// 
// 	},
// 	scroll: function(targ) {
// 		var left  = HtinyScrolling.getScrollLeft();
// 		if(HtinyScrolling.requestedX > left) { //a fix by Michael Ionita-Ganea
// 			var endDistance = Math.round((HtinyScrolling.getDocumentWidth() - (left + HtinyScrolling.getWindowWidth())) / HtinyScrolling.brakeK);
// 			endDistance = Math.min(Math.round((HtinyScrolling.requestedX-left)/ HtinyScrolling.brakeK), endDistance);
// 			var offset = Math.min(Math.abs(Math.round((HtinyScrolling.requestedX-left)/ HtinyScrolling.brakeK)), HtinyScrolling.maxStep);
// 		}else {
// 				var offset = - Math.min(Math.abs(Math.round((HtinyScrolling.requestedX-left)/ HtinyScrolling.brakeK)), HtinyScrolling.maxStep);
// 		}
// 		window.scrollTo(left + offset, 0);
// 		if(Math.abs(left-HtinyScrolling.requestedX) <= 1 || HtinyScrolling.getScrollLeft() == left) {
// 			HtinyScrolling.hash = null;
// 		} else 	setTimeout(HtinyScrolling.scroll,HtinyScrolling.speed);
// 	}
// }

var scrollTips = {
	dx : null,
	init : function() {
		if (window.addEventListener) {
		window.addEventListener("DOMMouseScroll", this.mouseScroll, false);
		} else document.attachEvent("onmousewheel", this.mouseScroll);
		var left = document.getElementById('left');
		addEvent(left,'mouseover', function() {this.dx=setInterval('scrollTips.arrowScroll(0)',100);return false;});
		addEvent(left,'mouseout', function() { clearInterval(this.dx); return false;});
		var right = document.getElementById('right');
		addEvent(right,'mouseover', function() {this.dx=setInterval('scrollTips.arrowScroll(1)',100);return false;});
		addEvent(right,'mouseout', function() { clearInterval(this.dx); return false;});
	},
	mouseScroll : function(e) {
		if (!e) var e = window.event;
		  var scroll = e.detail ? e.detail * 20 : e.wheelDelta / -20;
		if (scroll>=0 ){
		window.scrollBy(100,0);
		} else  window.scrollBy(-100,0) ;
	},
	arrowScroll: function(val) {
		if(val==1) {
			window.scrollBy(100,0);
		} else {
			window.scrollBy(-100,0)
		}
	}
}

function addEvent( obj, type, fn ) {
	if (obj.addEventListener)
		obj.addEventListener( type, fn, false );
	else if (obj.attachEvent) {
		obj["e"+type+fn] = fn;
		obj[type+fn] = function() { obj["e"+type+fn]( window.event ); }
		obj.attachEvent( "on"+type, obj[type+fn] );
	}
}

function removeEvent( obj, type, fn ) {
	if (obj.removeEventListener)
		obj.removeEventListener( type, fn, false );
	else if (obj.detachEvent) {
		obj.detachEvent( "on"+type, obj[type+fn] );
		obj[type+fn] = null;
		obj["e"+type+fn] = null;
	}
}



// モードとキーを指定してSUBMITを行う。
function fnModeSubmit(form_nm, mode, keyname, keyid) {
	switch(mode) {
	case 'delete_category':
		if(!window.confirm('選択したカテゴリとカテゴリ内のすべてのカテゴリを削除します')){
			return false;
		}
		break;
	case 'delete':
		if(!window.confirm('一度削除したデータは、元に戻せません。\n削除しても宜しいですか？')){
			return false;
		}
		break;
	case 'confirm':
		if(!window.confirm('登録しても宜しいですか')){
			return false;
		}
		break;
	case 'delete_all':
		if(!window.confirm('検索結果をすべて削除しても宜しいですか')){
			return false;
		}
		break;
	default:
		break;
	}

	document.forms[form_nm].elements['mode'].value = mode;
	if(keyname != "" && keyid != "") {
		document.forms[form_nm].elements[keyname].value = keyid;
	}
	document.forms[form_nm].submit();
}



// End -->
