﻿
//#########################################################################
/* RemoteCall link list*/
/* maked by larblue */
//#########################################################################

$(function() {
	$('.gnb ul').css('display', 'none');
	$('.gnb span').css('display', 'none');
	$('.feature p').css('display', 'none');
	$('.feature p:last').css('display', 'block');
	$('.notice li ul').css('display', 'none');
	$('.notice li ul:first').css('display', 'block');
	$('.left_menu ul ul ul').css('display', 'none');
	
	/* GNB Navigation Animation & Link */
	$('.gnb>li').mouseover(function() {
		$(this).children('a').addClass('over');
		$(this).children('ul').css('display', 'block');
		$(this).children('span').css('display', 'block');
	});
	$('.gnb>li').mouseout(function() {
		$(this).children('a').removeClass('over');
		$(this).children('ul').css('display', 'none');
		$(this).children('span').css('display', 'none');
	});
	/* Language Selection Animation & Link */
	$('.changelang').toggle(function() {
		$(this).addClass('changelangover');
		$(this).children('div').css('display', 'block');
	}, function() {
		$(this).removeClass('changelangover');
		$(this).children('div').css('display', 'none');
	});
	$('.changelang li').mouseover(function() {
		$(this).addClass('over');
	}).mouseout(function() {
		$(this).removeClass('over');
	});
	$('.changelang li a').click(function() {
		top.document.location.href = $(this).attr('href');
	});
	/* 3tap tip,product information, mov guide */
	$('.feature li > a').click(function() {
		$('.feature li a').removeClass('on');
		$(this).addClass('on');
		$('.feature li').children('p').css('display', 'none');
		var targetlist = $(this).attr('href');
		$(targetlist).children('p').css('display', 'block');
		return false;
	});
	
	$('dl.product a').click(function() {
		var linkPoint = $(this).attr('href');
		window.open(linkPoint, '', 'width=650,height=500,scrollbars=no');
		return false;
	});
	/* Notice Tab Animation */
	$('.notice>ul>li').click(function() {
		$('.notice li a').removeClass('on');
		$(this).children('a:first').addClass('on');
		$('.notice li ul').css('display', 'none');
		$(this).children('ul').css('display', 'block');
		return false;
	});
	$('.sublist li a').click(function() {
		location.href = $(this).attr('href');
	});

	/* left menu accodian */
	var bodyStyle = $('body').attr('class');
	var chapterNum = 0;
	var menuNum = 0;
	var submenuNum = 0;
	if (bodyStyle.length >= 7) {
		chapterNum = bodyStyle.substring(4, 5);
		menuNum = bodyStyle.substring(5, 6);
		submenuNum = bodyStyle.substring(6, 7);
	}
	var locationInfo = '.left_menu>ul>li:nth-child(' + chapterNum + ') ul>li:nth-child(' + menuNum + ')';
	
	var mainlistNum = locationInfo + ' ul';
	var listNum = locationInfo + '>a:first';
	var sublistNum = locationInfo + ' ul li:nth-child(' + submenuNum + ')';
	var leftMenu = '.leftmenu' + chapterNum;

	$('.left_menu>ul>li').css('display', 'none');
	$(leftMenu).css('display', 'block');
	$(mainlistNum).css('display', 'block');
	$(listNum).css('background', 'url(/contents/ko/images/common/left_sprite_bg.gif) 0 -552px').css('color', '#dd2120');
	$(sublistNum).addClass('over');
});


//Appliance pop //
function fnQNA(){
    window.opener.location.href="/contents/ja/support/support_inquire.aspx"
    self.close();
}

//スライドメニュー
var stmnGAP1 = 337; //初期上段間隔
var stmnGAP2 = 100; //スクロール後上段間隔
var stmnBASE = 400;
var stmnActivateSpeed = 200; 
var stmnScrollSpeed = 10; 

function RefreshStaticMenu()
{
        var stmnStartPoint, stmnEndPoint, stmnRefreshTimer;

        stmnStartPoint = parseInt(STATICMENU.style.top, 10);
        stmnEndPoint = document.body.scrollTop + stmnGAP2;
        if (stmnEndPoint < stmnGAP1) stmnEndPoint = stmnGAP1;

        if ( stmnStartPoint != stmnEndPoint ) {
                stmnScrollAmount = Math.ceil( Math.abs( stmnEndPoint - stmnStartPoint ) / 15 );
                STATICMENU.style.top = parseInt(STATICMENU.style.top, 10) + ( ( stmnEndPoint<stmnStartPoint ) ? -stmnScrollAmount : stmnScrollAmount );
                stmnRefreshTimer = stmnScrollSpeed;
        }
                                    else {
                stmnRefreshTimer = stmnActivateSpeed;
        }

        setTimeout ("RefreshStaticMenu();", stmnRefreshTimer);
}

function InitializeStaticMenu()
{
        STATICMENU.style.top = document.body.scrollTop + stmnBASE;
        RefreshStaticMenu();
        }

function openUsingGuide(){
    window.open('https://rview.net/remoteview/bc/contents/main/openUsingGuide.aspx?cNo=4','uguide','width=640,height=445,scrollbars=no');
}


/*
===============================================================================
* Program Common
===============================================================================
*/

//id type Check :  英文小文字,数字,_
function IDTypeChk(str){
//    if(str.trim()=="" || str.trim() == null){
//        alert("IDを入力して下さい。");
//        return false;
//    }
    var len = str.length;
    if(len < 6 || len > 30){
    	alert("IDは6文字以上30文字以下の英小文字、数字のみ入力可能です。");
        return false;
    }
	for (i=0; i <= len -1 ; i++){
	    var chr=str.charCodeAt(i);
	    //48~57
	    //65~90 97~122
	    if(!(chr>=48 && chr<=57) && !(chr >= 97 && chr <= 122)){
			alert("IDは英文小文字,数字だけ入力可能です。");
			return false;
	    }   
    }
	return true;
}

//pwd type Check :  英文小文字,数字,_
function PwdTypeChk(str){
//    if(str.trim()=="" || str.trim() == null){
//        alert("暗証番号を入力して下さい。");
//        return false;
//    }

    if(str.trim() != ""){
        var len = str.length;
        if(len < 6 || len > 30){
            alert("暗証番号は6者以上30字以下英文小文字,数字だけ入力可能です。");
            return false;
        }
	    for (i=0; i <= len -1 ; i++){
	        var chr=str.charCodeAt(i);
	        if(!(chr>=48 && chr<=57) && !(chr >= 97 && chr <= 122)){
			    alert("暗証番号は英文小文字,数字だけ入力可能です。");
			    return false;
	        }   
        }
	    return true;
    }
}

function banner3pOver() {
	var targetLi = document.getElementById('banner3p').getElementsByTagName('li');
	for (i = 0; i < targetLi.length; i++) {
		targetLi[i].onmouseover = function() {
			this.className = 'imgView';
		}
		targetLi[i].onmouseout = function() {
			this.className = 'imgNotView';
		}
	}
}

/* dialog controllers */
var dialogEl;
function createDialog() {
    //console.info('createDialog', arguments);

    return $([
          '<div class="dialog" style="display: none;">',
            '<h3 class="title"></h3>',
            '<a href="#" class="close"></a>',
            '<div class="body"></div>',
          '</div>'
        ].join('\n')).appendTo(document.body);
}

function centerDialog() {
    dialogEl && dialogEl.is(':visible') && dialogEl.animate({
        left: $(window).width() / 2 - dialogEl.width() / 2,
        top: $(window).height() / 2 - dialogEl.height() / 2 + $(window).scrollTop()
    });
}

function openDialog(title, data, options) {
    //console.info('openDialog', arguments);
    if (!dialogEl) {
        dialogEl = createDialog();
        dialogEl.find('.close').click(closeDialog);
    }
    if (!options) options = {};

    dialogEl.css({ width: options.width || 600 });
    options.height && dialogEl.css({ height: options.height });

    function callback() {
        options.callback && options.callback();
        centerDialog();
    }

    dialogEl.css({
        left: $(window).width() / 2 - dialogEl.width() / 2
    }).find('.title').html(title).end().find('.body').html(data);

    if (dialogEl.is(':visible')) callback();
    else {
        dialogEl.show().css({
            top: 0 - dialogEl.height()
        }).animate({
            top: $(window).height() / 2 - dialogEl.height() / 2 + $(window).scrollTop()
        }, callback);
    }
    //console.log($(data).find('script'), dialogEl.find('script'));
}

function closeDialog(event) {
    //console.info('closeDialog', arguments);
    dialogEl.animate({ top: 0 - dialogEl.height() }, function() {
        dialogEl.hide();

        var player = window.document.getElementById("player");
        if (player.sendEvent) {
            player.sendEvent("stop", true);
        }

    });
    event.preventDefault();
    event.stopPropagation();
}

/* shared functions */
function stop(event) {
    event.preventDefault();
    event.stopPropagation();
}

function request(pageId, callback) {
    $.ajax({
        type: 'get',
        url: '/_common/lib/VideoPlayer_JA.aspx?pageid=' + pageId,
        success: callback,
        error: function() {
            alert('Error!');
        }
    });
}
