﻿function createCookie(name, value, days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        var expires = "; expires=" + date.toGMTString();
    }
    else var expires = "";
    document.cookie = name + "=" + value + expires + "; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name, "", -1);
}

function closePopup(popupNo) {
    var popUp = document.getElementById(popupNo);
    var iPopUp = document.getElementById("I"+popupNo);
    if(popUp != null)
        popUp.style.visibility = 'hidden';
        
    if(iPopUp != null)
        iPopUp.style.visibility = 'hidden';
}

function disablePopup(popupNo) {
    closePopup(popupNo);
    createCookie(popupNo, "false", 365);
}



function showPopups(arrControls) {
    for (key in arrControls) {
        var popupControl = document.getElementById(arrControls[key]);
        var value = readCookie("popup" + key.toString());

        if (value == null || value == "true")
            popupControl.style.visibility = 'visible';
        else
            popupControl.style.visibility = 'hidden';

    }
}
function OpenWindow() {
    intWidth = 950;
    intHeight = 570;
    window.open('http://www.wisdomain.com/wis_html/jp/SolutionTip/SolutionTip.htm', "_blank", "width=" + intWidth + ",height=" + intHeight + ",resizable=no, scrollbars=1");
}

window.onload = function() {

	var rotate = document.getElementById("rotateA0")
	var rotateACnt = 0;
	var rotateBCnt = 0;
	var rotateCCnt = 0;

	if (rotate != null) {
		rotate = document.getElementById("rotateA" + doRotateDisplay(getRotateCnt("rotateA")));
		rotate.style.display = "block";
	}

	rotate = document.getElementById("rotateB0")
	if (rotate != null) {
		rotate = document.getElementById("rotateB" + doRotateDisplay(getRotateCnt("rotateB")));
		rotate.style.display = "block";
	}

	rotate = document.getElementById("rotateC0")
	if (rotate != null) {
		rotate = document.getElementById("rotateC" + doRotateDisplay(getRotateCnt("rotateC")));
		rotate.style.display = "block";

	}

}

function doRotateDisplay(divCnt) {
	var date = new Date();
	var second;
	var SelectedDiv;
	second = date.getSeconds() + 1;
	SelectedDiv = Math.floor((second % (divCnt + 1)));
	return SelectedDiv;
}

function getRotateCnt(divId) {
	var rotateCnt = 0;
	var rotate;
	for (var i = 1; i < 10; i++) {
		rotate = document.getElementById(divId + i)
		if (rotate != null)
			rotateCnt = i;	
	}
	return rotateCnt;
}