<!--
////////// JS Library for Reggaerecord.com
////////// copyright(c) 2005-2008 Yasushi Kurobane

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = true;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

var lastLayer;
var mouse_x, mouse_y;
var my_browser = getBrowser();

function initEventListener() {
	switch(my_browser) {
		case "IE":
		document.onmousemove = getMouseIE;
		break;
		
		case "N6":
		window.addEventListener("mousemove", getMouseN6, true);
		break;
		
		case "N4":
		window.captureEvents(Event.MOUSEMOVE);
		window.onmousemove = getMouseN4;
		break;
		
		case "OP":
		document.onmousemove = getMouseOP;
		break;
		
	}
}

function getMouseIE() {
	mouse_x = window.event.clientX + document.body.scrollLeft - 50 + "px";
	mouse_y = window.event.clientY + document.body.scrollTop - 10 + "px";
}

function getMouseN6(e) {
	mouse_x = e.clientX + window.pageXOffset + "px";
	mouse_y = e.clientY + window.pageYOffset + "px";
}

function getMouseN4(e) {
	mouse_x = e.x;
	mouse_y = e.y;
}

function getMouseOP() {
	mouse_x = window.event.clientX - 50 + "px";
	mouse_y = window.event.clientY - 10 + "px";
}

function showLayer(id, visible) {
	//alert("check<br />");
	if (!id) return;
	var visibility;
	var overflow;
	if (visible) {
		visibility = "visible";
		overflow = "auto";
	} else {
		visibility = "hidden";
		overflow = "hidden";
	}
	var theLayer = getLayer(id);
	theLayer.style.visibility = visibility;
	theLayer.style.overflowY = overflow;
	//alert(theLayer.id);
	if (my_browser == "IE") {
		var theShim = getLayer("shim");
		if (visible) {
			theShim.style.width = theLayer.offsetWidth;
			theShim.style.height = theLayer.offsetHeight;
			theShim.style.display = "inline";
			//theLayer.focus();
		} else {
			theShim.style.display = "none";
		}
	}
}

function showLayerHere(id) {
	if (!id) return;
	var theLayer = getLayer(id);
	showLayer(id, true);
	lastLayer = id;
}

function getLayer(id) {
	var theLayer;
	
	switch(my_browser) {
		case "IE":
		theLayer = document.all[id];
		break;
		
		case "N6":
		theLayer = document.getElementById(id);
		break;
		
		case "N4":
		theLayer = document[id];
		break;
		
		case "OP":
		theLayer = document.getElementById(id);
		break;
		
	}
	
	return theLayer;
}

function hideLastLayer() {
	if (!lastLayer) return;
	setOnClickHandler(false);
	showLayer(lastLayer, false);
	var theLayer = getLayer(lastLayer);
	theLayer.scrollTop = 0;
}

function setOnClickHandler(val) {
	//alert(val);
	switch(my_browser) {
		case "IE":
		if (val) {
			//alert(hideLastLayer);
			document.onclick = hideLastLayer;
		} else	{
			document.onclick = null;
		}
		break;
		
		case "N6":
		if (val) {
			window.addEventListener("click", hideLastLayer, true);
		} else {
			window.removeEventListener("click", hideLastLayer, true);
		}
		break;
		
		case "N4":
		window.captureEvents(Event.CLICK);
		window.onclick = val?hideLastLayer:null;
		break;
		
		case "OP":
		document.onclick = val?hideLastLayer:null;
		break;
		
	}
}

function getWindowWidth() {
	var theWidth;
	if (navigator.appName.indexOf('Microsoft') >= 0) {
		theWidth = document.body.clientWidth;
	} else if (navigator.appName.indexOf('Netscape') >= 0){
		theWidth = innerWidth;
	} else {
		theWidth = 1024;
	}

	return theWidth;
}

function windowResized() {
	if (window.window_width) if (getWindowWidth() == window_width) return;
	var theURL = window.location.href;
	
	document.reload_form.window_width.value = getWindowWidth();
	document.reload_form.submit();
}

function getBrowser() {
	var browser_name;
	if (navigator.userAgent.indexOf("Opera",0) != -1) {
		browser_name = "OP";
	} else if (document.all) {
		browser_name = "IE";
	} else if (document.getElementById) {
		browser_name = "N6";
	} else if (document.layers) {
		browser_name = "N4";
	}
	return browser_name;
}

function search(type, keyword) {
	var key_list = new Array('artist', 'title', 'format_code', 'rhythm', 'label', 'recent', 'section_web_order', 'song');
	var multi = false;
	
	keyword = keyword.replace(/\[quote\]/g, "'");
	keyword = keyword.replace(/\[dquote\]/g, '"');
	
	if ($('multi_search').style.display == 'none') {

		if (false) { //document.simple_search_form.keyword.value) {
			keyword = document.simple_search_form.keyword.value + " " + keyword;
			if ($('field_' + type).selected != 'selected') {
				type= 'all';
			}
		}
		//showSearchForm();
		if ($('field_' + type) != null) {
			document.simple_search_form.keyword.value = keyword;
			$('field_' + type).selected = 'selected';
			document.simple_search_form.submit();
			return;
		}
	} else {
		for (i = 0; i < key_list.length; i++) {
			if (key_list[i] == type) continue;
			if (document.multi_search_form[key_list[i]].value != '') {
				multi = true;
				break;
			}
		}
	}
	if (multi) {
		document.multi_search_form[type].value = keyword;
		document.multi_search_form.submit();
	} else {
		var theURL = depth_fix + "catalog/search.php?search_type=" + type;
		if (keyword != '') {
			theURL += "&keyword=" + encodeURIComponent(keyword);
		}
		document.location.href = theURL;
	}
}

function changeLanguage(src, dst) {
	var src_url = document.location.href;
	var dst_url = src_url.replace("/" + src + "/", "/" + dst + "/");
	/*if (dst_url.indexOf("/help/") >= 0) {
		dst_url = dst_url.substr(0, dst_url.indexOf("/help/") + 6);
	}*/
	document.location.href = dst_url;
}

function compactFields(src_obj, dest) {
	var src_fields = new Array();
	var dest_field = document.getElementById(dest);
	var result = 0;
	var src = src_obj.id;
	var offset = src.lastIndexOf("_");
	src = src.substr(0, offset);
	var i = 1;
	while (document.getElementById(src + '_' + i) != null) {
		var temp = document.getElementById(src + '_' + i);
		if (temp.checked) {
			result = result + Math.pow(2, i - 1);
		}
		i++;
	}
	dest_field.value = result;
}

function writeContactInfo(a, b, c, d) {
	var i = 'mai';
	var j = '@';
	var k;
	var l;
	var m;
	switch(b) {
		case 1:
		k = 'reggaerecord';
		l = '.com';
		break;
		
		case 2:
		k = 'dubstore';
		l = '.co.jp';
		break;
	}
	i += 'lto:';
	a += j + k + l;
	if (c) {
		m = c;
	} else {
		m = a;
	}
	if (d) {
		n = "?subject=" + d;
	} else {
		n = "";
	}
	document.write('<a href="' + i + a + n + '">' + m + '</a>');
}
-->
