﻿
/**
 * get url protocl
 */
function getScheme(url)
{
	var p = "";
	if (url.indexOf("https") != -1
		&& url.indexOf("https") == 0)
	{
		p = "https";
	}
	else if (url.indexOf("http") != -1
		&& url.indexOf("http") == 0)
	{
		p = "http";
	}

	return p;
}

/**
 * change the ssl state
 */
function sslChange(url)
{
	var p = getScheme(url);

	if (p == "http")
	{
		window.location.href = "https" + url.substring(4);
	}
	else if (p == "https")
	{
		window.location.href = "http" + url.substring(5);
	}
}

/**
 * print out the ssl html
 */
function sslOut(url, mtStaticPath)
{
	var p = getScheme(url);

	if ( p == "http")
	{
		document.write("<p><img src='" + mtStaticPath + "blogs_common/img/navi/ttl_ssl_off.gif' alt='SSLモード：off' width='85' height='16' /><a href='javascript:sslChange(window.location.href);'><img src='" + mtStaticPath + "blogs_common/img/navi/btn_ssl_on.gif' alt='SSLモードをonにする' width='70' height='16' /></a></p>");
	}
	else
	{
		document.write("<p><img src='" + mtStaticPath + "blogs_common/img/navi/ttl_ssl_on.gif' alt='SSLモード：on' width='85' height='16' /><a href='javascript:sslChange(window.location.href);'><img src='" + mtStaticPath + "blogs_common/img/navi/btn_ssl_off.gif' alt='SSLモードをoffにする' width='70' height='16' /></a></p>");
	}
}