﻿

function ChangeLan(objLanDisplayID){

    window.setInterval("setLanVal('" + objLanDisplayID + "')",2000);

}

function ChangeMsg(objMsgNumDisplayID, objMsgTextDisplayID){

    window.setInterval("setMsg('" + objMsgNumDisplayID + "', '" + objMsgTextDisplayID + "')",2000);

}

function ChangeIconBonus(objIconID){

    window.setInterval("setIcon('" + objIconID + "')",2000);
}

function setMsg(objMsgNumDisplayID, objMsgTextDisplayID)
{
    strMsgNum = arMsgNum[j];
    strMsgText = arMsgText[j];
    
    document.getElementById(objMsgNumDisplayID).src = strMsgNum;
    document.getElementById(objMsgTextDisplayID).innerHTML = strMsgText;
    
    if(j >= (arMsgNum.length - 1)){
        j=0;
    }else{
        j++;
    }
}

function setLanVal(objLanDisplayID){

    strLan = arLan[i];
    
    document.getElementById(objLanDisplayID).innerHTML = strLan;
    
    if(i >= (arLan.length - 1)){
        i=0;
    }else{
        i++;
    }
}

function setIcon(objIconID){

    strSrcIcon = arIconPath[icon_i];
    
    document.getElementById(objIconID).src = strSrcIcon;
    
    if(icon_i >= (arIconPath.length - 1)){
        icon_i=0;
    }else{
        icon_i++;
    }

}

function setNavigationActive(strSelLink, blnChangeActiveNav)
{
    switch (strSelLink)
    {
        case "Exchange":
        
            document.getElementById('MPmain_cph_Main_User_Nav_lnk_Btn_Balance').className = 'clsLinkMenu';
            document.getElementById('MPmain_cph_Main_User_Nav_lnk_Btn_Compensation').className = 'clsLinkMenu';
            document.getElementById('MPmain_cph_Main_User_Nav_lnk_Btn_Exchange').className = 'clsLinkMenuSelected';
            document.getElementById('MPmain_cph_Main_User_Nav_hidSelLink').value = strSelLink;
            
            if(blnChangeActiveNav)
            {
                var strTemp;
                strTemp = document.getElementById('MPmain_cph_Main_User_Nav_hidActive').value;
                document.getElementById('MPmain_cph_Main_User_Nav_hidActive').value = document.getElementById('MPmain_cph_Main_User_Footer_hidActive').value;
                document.getElementById('MPmain_cph_Main_User_Footer_hidActive').value = strTemp;
            }
            break;
            
        case "CustomerAccount":
            document.getElementById('MPmain_cph_Main_Customer_Nav_lnk_Btn_CustomerAccount_CompanyDataChange').className = 'clsLinkMenu';
            document.getElementById('MPmain_cph_Main_Customer_Nav_lnk_Btn_CustomerAccount_PersonalDataChange').className = 'clsLinkMenu';
            document.getElementById('MPmain_cph_Main_Customer_Nav_lnk_Btn_CustomerAccount_AddEmployee').className = 'clsLinkMenu';
            document.getElementById('MPmain_cph_Main_Customer_Nav_lnk_Btn_CustomerAccount').className = 'clsLinkMenuSelected';
            document.getElementById('MPmain_cph_Main_Customer_Nav_hidSelLink').value = strSelLink;
            break;
        default:
            break;
    }
}

function Password_ClientValidate(source, arguments)
{
    var strValue = arguments.Value;
    
    if (strValue.length >= 4 && strValue.length <= 20)
    {
        arguments.IsValid = true;
    }
    else
    {
        arguments.IsValid = false;
    }
}

function txtCAPTCHAVal_ClientValidate(source, arguments)
{
    var strValue = arguments.Value;
    
    if (strValue.length == 5)
    {
        arguments.IsValid = true;
    }
    else
    {
        arguments.IsValid = false;
    }
}

var objHelpWindow;

			
function displayHelp(HelpFileName, intWidth, intHeight, intPosX, intPosY)
{
	var intClientWidth = window.screen.availWidth;
	var intClientHeight = window.screen.availHeight;
		
	var intHelpWidth = intWidth;
	var intHelpTop = intPosY;
	var intHelpLeft = intClientWidth - intWidth - intPosX;
	var intHelpHeight = intHeight;
	
	var strBrowser = new String(window.navigator.userAgent);
	if(strBrowser.search('Firefox')>-1)
	{
		intHelpHeight = intHelpHeight - 25
	}


	if (objHelpWindow == null)
	{
		objHelpWindow = window.open(HelpFileName, null,'top=' + intHelpTop + ',left=' + intHelpLeft + ',height=' + intHelpHeight + ',width=' + intHelpWidth + ',status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes,titlebar=no');
	}
	else
	{
		if (objHelpWindow.closed)
		{
			objHelpWindow = window.open(HelpFileName, null,'top=' + intHelpTop + ',left=' + intHelpLeft + ',height=' + intHelpHeight + ',width=' + intHelpWidth + ',status=no,toolbar=no,menubar=no,location=no,resizable=yes,scrollbars=yes,titlebar=no');
		}
				
		objHelpWindow.focus();
	}
	
}

function cmdBack()
{
    history.back();
}

function cmdSizeContent(objResizeData, intMinusPixel){

    return (objResizeData.offsetParent.offsetWidth - intMinusPixel);
    
}		


function cmdOpenPopUp(strUrl)
{
    window.open(strUrl,'PopUp','width=650, height=400, scrollbars=no, toolbar=0, location=no, directories=no, status=no');
}

function cmdOpenNewWindow(strUrl, strName, intWidth, intHeight)
{
    window.open(strUrl, strName,'width=' + intWidth + ', height=' + intHeight + ', scrollbars=yes, toolbar=yes, resizable=yes');
}

function hideAll()
{                        
    var allElements=document.getElementById('exmusic_content').getElementsByTagName('div');
    for (var i = 0; i < allElements.length; i++) 
    {   
        var strCur=allElements[i].id;
        				            
        if((strCur!=null)&&((strCur.search(/detail.+/)!=-1)||(strCur.search(/confirm.+/)!=-1))) 
        {
            allElements[i].style.display='none';
        }
    }                        
}

function Details(intAlbumNr,intClose)
{
    hideAll();	       
    var objAnchor=document.getElementById('anchor' + intAlbumNr);				      
    var curTop = 0;
    var curLeft = 0;
    var curWidth = 0;
    var i=0;
    if(objAnchor.offsetParent)
    {				         
        while (objAnchor.offsetParent)
        {
            curTop += objAnchor.offsetTop - objAnchor.scrollTop;
            curLeft += objAnchor.offsetLeft - objAnchor.scrollLeft;
            objAnchor = objAnchor.offsetParent;  
            
            if((objAnchor.tagName == "TABLE")&&(i==0))
            {
                i++;
                curWidth=objAnchor.offsetWidth;
            }
        }
    }
    else
    {   
        /*while(objAnchor.parentNode)
        {
            alert(objAnchor.offsetTop);
            curTop += objAnchor.offsetTop - objAnchor.scrollTop;
            curLeft += objAnchor.offsetLeft - objAnchor.scrollLeft;
            objAnchor = objAnchor.parentNode;
        }*/
        curTop=objAnchor.y;
        curLeft=objAnchor.x;
    }
    if(intClose==1)
    {
        document.getElementById('detail'+intAlbumNr).style.display='none';
    }
    else
    {	     
        document.getElementById('detail'+intAlbumNr).style.top=curTop+"px";
        document.getElementById('detail'+intAlbumNr).style.left=curLeft+"px";    
        document.getElementById('detail'+intAlbumNr).style.display='block';
    }
}

function Confirm(intAlbumNr,intClose)
{
    hideAll();
    var objAnchor=document.getElementById('anchor' + intAlbumNr);				      
    var curTop = 0;
    var curLeft = 0;
    var curWidth = 0;
    var i=0;
    if(objAnchor.offsetParent)
    {				         
        while (objAnchor.offsetParent)
        {
            curTop += objAnchor.offsetTop - objAnchor.scrollTop;
            curLeft += objAnchor.offsetLeft - objAnchor.scrollLeft;
            objAnchor = objAnchor.offsetParent;
            if((objAnchor.tagName == "TABLE")&&(i==0))
            {
                i++;
                curWidth=objAnchor.offsetWidth;
            }
        }
    }
    else
    {   
        /*while(objAnchor.parentNode)
        {
            alert(objAnchor.offsetTop);
            curTop += objAnchor.offsetTop - objAnchor.scrollTop;
            curLeft += objAnchor.offsetLeft - objAnchor.scrollLeft;
            objAnchor = objAnchor.parentNode;
        }*/
        curTop=objAnchor.y;
        curLeft=objAnchor.x;
    }
    if(intClose==1)
    {
        document.getElementById('confirm'+intAlbumNr).style.display='none';
    }
    else
    {
        document.getElementById('confirm'+intAlbumNr).style.top=curTop+"px";
        document.getElementById('confirm'+intAlbumNr).style.left=curLeft+"px";      
        document.getElementById('confirm'+intAlbumNr).style.display='block';
    }
}

function calcPoints(objSource, objDestination, decRate)
{
   var lngCalc = objSource.value * decRate;
   objDestination.value = lngCalc.toFixed(2);
   objDestination.value = objDestination.value.replace(/\./,",");

}

function calcCharsLeft(objMessage,objCharsLeft,intMax)
{
   if(objMessage.value.length>intMax)
   {
      objMessage.value = objMessage.value.substring(0,intMax);
   }
   objCharsLeft.value = intMax - objMessage.value.length;
}

function changeToEdit(objLabel,objInput,objSender,objHid)
{
   objLabel.style.display='none';
   objInput.style.display='block';	
   objSender.style.display='none';
   objHid.value = "1";
}

function initToEdit(objLabel,objInput,objSender,objHid)
{
   if (objHid.value == "1")
   {
       objLabel.style.display='none';
       objSender.style.display='none';
       objInput.style.display='block';
   }
}

/*
    reg: icon-animation
*/
function setRegIconBG(intCnt)
{
    var objIconDivHL = document.getElementById("adv_reg_advantage_" + intCnt);
    var objIconDivNL;
    
    for(var j=0; j < intCnt; j++)
    {
        objIconDivNL = document.getElementById("adv_reg_advantage_" + j);
        objIconDivNL.style.background = "#E7EAB2";        
    }
    
    if(intCnt < 6)
    {
        objIconDivHL.style.background = "#BDCD00";
        window.setTimeout("setRegIconBG(" + (intCnt+1) + ")", 1000);
    }
}
