/*
	デジタルぱーぷる共通JavaScript
*/

function dpload()
{
	var i, allLinks;
	
	if (document.layers) {
		allLinks = document.links;
	}
	else if (document.all) {
		allLinks = document.all.tags('A');
	}
	else if (document.getElementsByTagName) {
		allLinks = document.getElementsByTagName('A');
	}
	else {
		return null;
	}
	
	for (i=0; i<allLinks.length; i++)
	{
		if(!allLinks[i].onclick) {
			allLinks[i].onclick = clickLink;
		}
	}
	
	return true;
}

function clickLink()
{
	if ((this.href).charAt(0) == "#") {
		return true;
	}
	if ((this.href).indexOf("mailto:") >= 0) {
		return true;
	}
	if (this.target) {
		return true;
	}
	if (this.href.match("k_no=[0-9]*")) {
		if (!shopjump(this.href)) {
			return true;
		}
	}
	else {
		if (!sjump(this.href)) {
			return true;
		}
	}
	return false;
}

function sjump(target_URL)
{
	if (target_URL) {
		document.PFSafe.action = target_URL;
		document.PFSafe.target = "_self";
		document.PFSafe.submit();
	}
	else {
		return false;
	}
	return true;
}

function shopjump(target_URL)
{
	var temp1, temp2, k_no;
	
	if (target_URL) {
		temp1 = target_URL.split("?");
		if (temp1.length > 1) {
			temp2 = temp1[1].match("k_no=([0-9]+)");
			if (temp2.length > 1) {
				k_no = temp2[1];
				
				document.PFSafe.action = temp1[0];
				document.PFSafe.target = "_self";
				document.PFSafe.k_no.value = k_no;
				document.PFSafe.submit();
				
				return true;
			}
		}
	}
	return false;
}

function popwin()
{
	if (arguments.length > 2) {
		window.open(arguments[0], arguments[1], arguments[2]);
	}
	else if (arguments.length > 1) {
		window.open(arguments[0], arguments[1]);
	}
	else if (arguments.length > 0) {
		window.open(arguments[0]);
	}
	else {
		return true;
	}
	
	return false;
}

function spopwin()
{
	var temp1, temp2, k_no;
	
	if (arguments.length > 2) {
		window.open("", arguments[1], arguments[2]);
		document.PFSafe.target = arguments[1];
	}
	else if (arguments.length > 1) {
		window.open("", arguments[1]);
		document.PFSafe.target = arguments[1];
	}
	else if (arguments.length > 0) {
		window.open("", "subwin");
		document.PFSafe.target = "subwin";
	}
	else {
		return true;
	}
	
	if (arguments[0]) {
		temp1 = arguments[0].split("?");
		if (temp1.length > 1) {
			temp2 = temp1[1].match("k_no=([0-9]+)");
			if (temp2.length > 1) {
				k_no = temp2[1];
			}
		}
	}
	
	document.PFSafe.action = arguments[0];
	document.PFSafe.k_no.value = k_no;
	document.PFSafe.submit();
	
	return false;
}

function parentjump(target_LINK)
{
	var temp1, temp2, target_URL, k_no;
	var parent = 'mainwin';
	
	if (target_LINK) {
		
		target_URL = target_LINK.toString();

		if (target_URL.match("k_no=[0-9]+")) {
			temp1 = target_URL.split("?");
			if (temp1.length > 1) {
				temp2 = temp1[1].match("k_no=([0-9]+)");
				if (temp2.length > 1) {
					k_no = temp2[1];
					
					document.PFSafe.action = temp1[0];
					document.PFSafe.k_no.value = k_no;
				}
			}
		}
		else {
			document.PFSafe.action = target_URL;
		}
		
		if (!(!window.opener || window.opener.closed)) {
			window.opener.name = parent;
		}
		document.PFSafe.target = parent;
		document.PFSafe.submit();
		
		return false;
	}
	
	return true;
}

