﻿// JScript File
var DivIds = new Array("NewDir","EditDir","DeleteDir", "NewFile", "DeleteFile");


function BG_Switch(Id)
{
if(document.getElementById('Check_' + Id).checked)
{
document.getElementById('PhotobookImgContainer_' + Id).style.backgroundPosition = 'center';
}
else
{
document.getElementById('PhotobookImgContainer_' + Id).style.backgroundPosition = 'bottom';
}
}

function HoverImg(Id)
{
if(document.getElementById('Check_' + Id).checked)
{
document.getElementById('PhotobookImgContainer_' + Id).style.backgroundPosition = 'center';
}
else
{
document.getElementById('PhotobookImgContainer_' + Id).style.backgroundPosition = 'top';
}
}

function UnHoverImg(Id)
{
if(document.getElementById('Check_' + Id).checked)
{
document.getElementById('PhotobookImgContainer_' + Id).style.backgroundPosition = 'center';
}
else
{
document.getElementById('PhotobookImgContainer_' + Id).style.backgroundPosition = 'bottom';
}

}

function ConfPopup(ViewType, p_intId)
{
    CloseConfPopup();
    document.getElementById('Conf_'+p_intId).style.display = ViewType;
}

function CloseConfPopup()
{
var l_intCounter = 0;
var l_objDiv = document.getElementById("Conf_"+l_intCounter);
while(l_objDiv != null)
{
l_objDiv.style.display = 'none';
l_intCounter++;
l_objDiv = document.getElementById("Conf_"+l_intCounter);
}

}

function ShowReply()
{
    document.getElementById('ContentDivHide').style.display = 'block';
    document.getElementById('MainDotsHide').style.display = 'block';
}

function OpenPopup(Id)
{
    CloseDiv();
    document.getElementById(Id).style.display = 'block';
}

function CloseDiv()
{
    for (var i=0;i<DivIds.length;i++)
    { 
        if(document.getElementById(DivIds[i]) != null){
            document.getElementById(DivIds[i]).style.display = 'none';
        }
    } 
}

function ClearFrom()
{
    if(document.getElementById('Date').value == "mm/dd/yyyy")
    {
        document.getElementById('Date').value = "";
    }
}

function ClearDate(Id)
{
    if(document.getElementById(Id).value == "mm/dd/yyyy")
    {
        document.getElementById(Id).value = "";
    }
}

function CheckForm(Type)
{
    if(Type == 'NewsSignup')
    {
        if(document.getElementById('Name').value == '')
        {
            document.getElementById('Name').style.borderColor = '#FF0000';
            alert('You forgot your Name');
            document.getElementById('Name').focus();
            return false;
        }
        else
        {
            document.getElementById('Name').style.borderColor = '#63797e';
        }
       
        if(document.getElementById('Email').value == '')
        {
            document.getElementById('Email').style.borderColor = '#FF0000';
            alert('You forgot your Email');
            document.getElementById('Email').focus();
            return false;
        }
        else
        {
            if(CheckEmail('Email') == '')
            {
                document.getElementById('Email').style.borderColor = '#63797e';
            }
            else
            { 
                document.getElementById('Email').style.borderColor = '#FF0000';
                alert('You forgot your Email');
                document.getElementById('Email').focus();
                return false;
           } 
        } 
    }

    if(Type == 'NewAlbum')
    {
        if(document.getElementById('Name').value == '')
        {
            document.getElementById('Name').style.borderColor = '#FF0000';
            alert('You forgot the Name');
            document.getElementById('Name').focus();
            return false;
        }
        else
        {
            document.getElementById('Name').style.borderColor = '#63797e';
        }
    }
    else if(Type == 'NewMap')
    {
        if(document.getElementById('MapName').value == '')
        {
            document.getElementById('MapName').style.borderColor = '#FF0000';
            alert('You forgot the Name');
            document.getElementById('MapName').focus();
            return false;
        }
        else
        {
            document.getElementById('MapName').style.borderColor = '#63797e';
        }
    }
    else if(Type == 'NewFile')
    {
        if(document.getElementById('Detail').value == '')
        {
            document.getElementById('Detail').style.borderColor = '#FF0000';
            alert('You forgot the Detail');
            document.getElementById('Detail').focus();
            return false;
        }
        else
        {
            document.getElementById('Detail').style.borderColor = '#63797e';
        }
        if(document.getElementById('File').value == '')
        {
            document.getElementById('File').style.borderColor = '#FF0000';
            alert('You forgot the File');
            document.getElementById('File').focus();
            return false;
        }
        else
        {
            document.getElementById('File').style.borderColor = '#63797e';
        }
    }
    else if(Type == 'MemberShip')
    {
        var l_intLength = document.getElementById('Password').value.length;
        if(document.getElementById('Password').value == '' || document.getElementById('Password2').value == '')
        {
            document.getElementById('Password').style.borderColor = '#FF0000';
            document.getElementById('Password2').style.borderColor = '#FF0000';
            alert('You forgot the Password');
            document.getElementById('Password').focus();
            return false;
        }
        else if(l_intLength < 3)
        {
            document.getElementById('Password').style.borderColor = '#FF0000';
            alert('The password is too short');
            document.getElementById('Password').focus();
            return false;
        }
        else if(document.getElementById('Password').value != document.getElementById('Password2').value)
        {
            document.getElementById('Password').style.borderColor = '#FF0000';
            document.getElementById('Password2').style.borderColor = '#FF0000';
            alert('Passwords are not similar');
            document.getElementById('Password2').focus();
            return false;
        }
        else
        {
            document.getElementById('Password').style.borderColor = '#63797e';
            document.getElementById('Password2').style.borderColor = '#63797e';
        }
    }
    else if(Type == 'AddNew')
    {
        if(document.getElementById('Title').value == '')
        {
            document.getElementById('Title').style.borderColor = '#FF0000';
            alert('You forgot the title');
            document.getElementById('Title').focus();
            return false;
        }
        else
        {
            document.getElementById('Title').style.borderColor = '#63797e';
        } 
             
        if(document.getElementById('Body').value == '')
        {
            document.getElementById('Body').style.borderColor = '#FF0000';
            alert('You forgot the body');
            document.getElementById('Body').focus();
            return false;
        }
        else
        {
            document.getElementById('Body').style.borderColor = '#63797e';
        } 
    }

    if(Type == 'NewConference') 
    {
        if(document.getElementById('Title').value == '')
        {
            document.getElementById('Title').style.borderColor = '#FF0000';
            alert('You forgot the title');
            document.getElementById('Title').focus();
            return false;
        }
        else
        {
            document.getElementById('Title').style.borderColor = '#63797e';
        }
        
        if(document.getElementById('Venue').value == '')
        {
            document.getElementById('Venue').style.borderColor = '#FF0000';
            alert('You forgot the Venue');
            document.getElementById('Venue').focus();
            return false;
        }
        else
        {
            document.getElementById('Venue').style.borderColor = '#63797e';
        }  
        
        if(document.getElementById('City').value == '')
        {
            document.getElementById('City').style.borderColor = '#FF0000';
            alert('You forgot the City');
            document.getElementById('City').focus();
            return false;
        }
        else
        {
            document.getElementById('Body').style.borderColor = '#63797e';
        }  
       
        if(document.getElementById('Body').value == '')
        {
            document.getElementById('Body').style.borderColor = '#FF0000';
            alert('You forgot the Body');
            document.getElementById('Body').focus();
            return false;
        }
        else
        {
            document.getElementById('Body').style.borderColor = '#63797e';
        }       
        
    }

    else if(Type == 'RegConf')
    {
        if(document.getElementById('Name').value == '')
        {
            document.getElementById('Name').style.borderColor = '#FF0000';
            alert('You forgot the Name');
            document.getElementById('Name').focus();
            return false;
        }
        else
        {
            document.getElementById('Name').style.borderColor = '#63797e';
        } 
             
        if(document.getElementById('FirstName').value == '')
        {
            document.getElementById('FirstName').style.borderColor = '#FF0000';
            alert('You forgot the FirstName');
            document.getElementById('FirstName').focus();
            return false;
        }
        else
        {
            document.getElementById('FirstName').style.borderColor = '#63797e';
        } 
    }
    else if(Type == 'Enquiries')
    {
        if(document.getElementById('Email').value == '')
        {
            document.getElementById('Email').style.borderColor = '#FF0000';
            alert('You forgot your Email');
            document.getElementById('Email').focus();
            return false;
        }
        else
        {
            if(CheckEmail2('Email') == '')
            {
                document.getElementById('Email').style.borderColor = '#63797e';
            }
            else
            { 
                document.getElementById('Email').style.borderColor = '#FF0000';
                alert('You forgot your Email');
                document.getElementById('Email').focus();
                return false;
           } 
        }
        
        if(document.getElementById('Text').value == '')
        {
            document.getElementById('Text').style.borderColor = '#FF0000';
            alert('You forgot the text');
            document.getElementById('Text').focus();
            return false;
        }
        else
        {
            document.getElementById('Text').style.borderColor = '#63797e';
        } 
    }
    RemoveHTML();
}

function IsDate(p_strValue, p_strLanguageFormat)
{
    var l_objRegExp;
    var l_intDay;
    var l_intMonth;
    var l_intYear;
    var l_intDaysInMonth;
    var l_Valid;
    var l_objDate;

    l_Valid = true;
    l_objRegExp = new RegExp("^(\\d{1,2})[/-](\\d{1,2})[/-](\\d{4})$");
    if (!l_objRegExp.test(p_strValue))
    {

            l_objRegExp = new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}$");
            if (!l_objRegExp.test(p_strValue))
            {
                    return 'No valid date';
            }
            else
            {
                    return true;
            }
                    }
    else
    {
		
            l_objRegExp.exec(p_strValue);
            switch (p_strLanguageFormat)
            {
                    case "English":
                    {
                            l_intDay = new Number(RegExp.$2);
                            l_intMonth = new Number(RegExp.$1);
                            break;
                    }
                    case "Dutch":
                    {
                            l_intDay = new Number(RegExp.$1);
                            l_intMonth = new Number(RegExp.$2);
                            break;
                    }
            }
            l_intYear =  new Number(RegExp.$3);
            l_intYear += ((l_intYear < 100)?((l_intYear >= 50)?1900:2000):0);
            l_intDaysInMonth = new Array (31,0,31,30,31,30,31,31,30,31,30,31);
            l_intDaysInMonth[1]= ((l_intYear%4==0)&&((l_intYear%100!=0)||(l_intYear%400==0)))?29:28;
            l_Valid = ((l_intMonth < 1) || (l_intMonth > 12) || 
					  (l_intDay < 1) || (l_intDay > l_intDaysInMonth[l_intMonth - 1]) || 
					  (l_intYear < 0))?false:true;
			if (l_Valid)
            {
                    l_objDate = new Date(l_intYear, (l_intMonth - 1), l_intDay);
                    l_Valid = isNaN(l_objDate)?false:true;
            }
            if (l_Valid == false)
            {
                    l_Valid = "Invalid date (";
                    if (p_strLanguageFormat == "English")
                    {
                            l_Valid += "MM/DD/YYYY";
                    }
                    else
                    {
                            l_Valid += "DD/MM/JJJJ";
                    }
                    l_Valid += ")";
            }       
            return l_Valid;
    }
} 

function CheckEmail(NewsLetter)
{
        if (/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i.test(document.getElementById("Email_1").value))
            return '';
        else
        {
            return 'Wrong Email';
        }
}

function CheckEmail2()
{
        if (/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i.test(document.getElementById("Email").value))
            return '';
        else
        {
            return 'Wrong Email';
        }
}

function ContactFormCheck()
{
    //CompanyName
    if(document.getElementById('CompanyName').value == '')
    {
        document.getElementById('CompanyName').style.borderColor = '#FF0000';
        document.getElementById('CompanyName').focus();
        alert('You forgot the Company name');
        return false;
    }
    else
    {
        document.getElementById('CompanyName').style.borderColor = '#63797e';
    }
    //Address
    if(document.getElementById('Address').value == '')
    {
        document.getElementById('Address').style.borderColor = '#FF0000';
        document.getElementById('Address').focus();
        alert('You forgot the Address');
        return false;
    }
    else
    {
        document.getElementById('Address').style.borderColor = '#63797e';
    }
    //Country
    if(document.getElementById('Country').value == '')
    {
        document.getElementById('Country').style.borderColor = '#FF0000';
        document.getElementById('Country').focus();
        alert('You forgot the Country');
        return false;
    }
    else
    {
        document.getElementById('Country').style.borderColor = '#63797e';
    }
    //Website
    if(document.getElementById('Website').value == '')
    {
        document.getElementById('Website').style.borderColor = '#FF0000';
        document.getElementById('Website').focus();
        alert('You forgot the Website');
        return false;
    }
    else
    {
        document.getElementById('Website').style.borderColor = '#63797e';
    }
    //CompanyOwnership
    if(document.getElementById('CompanyOwnership').value == '')
    {
        document.getElementById('CompanyOwnership').style.borderColor = '#FF0000';
        document.getElementById('CompanyOwnership').focus();
        alert('You forgot the Company ownership');
        return false;
    }
    else
    {
        document.getElementById('CompanyOwnership').style.borderColor = '#63797e';
    }
    //Air
    if(document.getElementById('Air').checked)
    {
         if(!IsNumeric(document.getElementById('AirNumbers').value))
        {
            document.getElementById('AirNumbers').style.borderColor = '#FF0000';
            document.getElementById('AirNumbers').focus();
            alert('You forgot the Air numbers');
            return false;
        }
        else
        {
            document.getElementById('AirNumbers').style.borderColor = '#63797e';
        }
        
        if(document.getElementById('AirCapacity').value == '')
        {
            document.getElementById('AirCapacity').style.borderColor = '#FF0000';
            document.getElementById('AirCapacity').focus();
            alert('You forgot the Air capacity');
            return false;
        }
        else
        {
            document.getElementById('AirCapacity').style.borderColor = '#63797e';
        }
    }
    else
    {
        document.getElementById('AirCapacity').style.borderColor = '#63797e';
        document.getElementById('AirNumbers').style.borderColor = '#63797e';
    }
    //Sea
    if(document.getElementById('Sea').checked)
    {
        if(!IsNumeric(document.getElementById('SeaNumbers').value))
        {
            document.getElementById('SeaNumbers').style.borderColor = '#FF0000';
            document.getElementById('SeaNumbers').focus();
            alert('You forgot the Sea numbers');
            return false;
        }
        else
        {
            document.getElementById('SeaNumbers').style.borderColor = '#63797e';
        }
        
        if(document.getElementById('SeaCapacity').value == '')
        {
            document.getElementById('SeaCapacity').style.borderColor = '#FF0000';
            document.getElementById('SeaCapacity').focus();
            alert('You forgot the Sea capacity');
            return false;
        }
        else
        {
            document.getElementById('SeaCapacity').style.borderColor = '#63797e';
        }
    }
    else
    {
        document.getElementById('SeaCapacity').style.borderColor = '#63797e';
        document.getElementById('SeaNumbers').style.borderColor = '#63797e';
    }
    //Land
    if(document.getElementById('Land').checked)
    {
        if(!IsNumeric(document.getElementById('LandNumbers').value))
        {
            document.getElementById('LandNumbers').style.borderColor = '#FF0000';
            document.getElementById('LandNumbers').focus();
            alert('You forgot the Land numbers');
            return false;
        }
        else
        {
            document.getElementById('LandNumbers').style.borderColor = '#63797e';
        }
        
        if(document.getElementById('LandCapacity').value == '')
        {
            document.getElementById('LandCapacity').style.borderColor = '#FF0000';
            document.getElementById('LandCapacity').focus();
            alert('You forgot the Land capacity');
            return false;
        }
        else
        {
            document.getElementById('LandCapacity').style.borderColor = '#63797e';
        }
    }
    else
    {
        document.getElementById('LandCapacity').style.borderColor = '#63797e';
        document.getElementById('LandNumbers').style.borderColor = '#63797e';
    }
    //Lift
    if(document.getElementById('Lift').checked)
    {
        if(!IsNumeric(document.getElementById('LiftNumbers').value))
        {
            document.getElementById('LiftNumbers').style.borderColor = '#FF0000';
            document.getElementById('LiftNumbers').focus();
            alert('You forgot the Lift numbers');
            return false;
        }
        else
        {
            document.getElementById('LiftNumbers').style.borderColor = '#63797e';
        }
        
        if(document.getElementById('LiftCapacity').value == '')
        {
            document.getElementById('LiftCapacity').style.borderColor = '#FF0000';
            document.getElementById('LiftCapacity').focus();
            alert('You forgot the Lift capacity');
            return false;
        }
        else
        {
            document.getElementById('LiftCapacity').style.borderColor = '#63797e';
        }
    }
    else
    {
        document.getElementById('LiftCapacity').style.borderColor = '#63797e';
        document.getElementById('LiftNumbers').style.borderColor = '#63797e';
    }
    //Employees
    if(!IsNumeric(document.getElementById('Employees').value))
    {
        document.getElementById('Employees').style.borderColor = '#FF0000';
        document.getElementById('Employees').focus();
        alert('You forgot the Employees');
        return false;
    }
    else
    {
        document.getElementById('Employees').style.borderColor = '#63797e';
    }
    //References
    if(document.getElementById('References').value == '')
    {
        document.getElementById('References').style.borderColor = '#FF0000';
        document.getElementById('References').focus();
        alert('You forgot the References');
        return false;
    }
    else
    {
        document.getElementById('References').style.borderColor = '#63797e';
    }
    RemoveHTML()
} 

function ContactFormCheck2()
{
    //CompanyName
    if (/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i.test(document.getElementById("Email").value))
    {
        document.getElementById('Email').style.borderColor = '#63797e';
    }
    else
    {
        document.getElementById('Email').style.borderColor = '#FF0000';
        document.getElementById('Email').focus();
        alert('You forgot the Email');
        return false;
    }
    
    if(document.getElementById('Company').value == '')
    {
        document.getElementById('Company').style.borderColor = '#FF0000';
        document.getElementById('Company').focus();
        alert('You forgot the Company name');
        return false;
    }
    else
    {
        document.getElementById('Company').style.borderColor = '#63797e';
    }
    
    if(document.getElementById('Name').value == '')
    {
        document.getElementById('Name').style.borderColor = '#FF0000';
        document.getElementById('Name').focus();
        alert('You forgot your name');
        return false;
    }
    else
    {
        document.getElementById('Name').style.borderColor = '#63797e';
    }
    
    if(document.getElementById('Msg').value == '')
    {
        document.getElementById('Msg').style.borderColor = '#FF0000';
        document.getElementById('Msg').focus();
        alert('You forgot the message');
        return false;
    }
    else
    {
        document.getElementById('Msg').style.borderColor = '#63797e';
    }
   
    RemoveHTML()
} 

function ConferanceCheck()
{
    if(document.getElementById('Body').value == '')
    {
        document.getElementById('Body').style.borderColor = '#FF0000';
        document.getElementById('Body').focus();
        alert('You forgot the message');
        return false;
    }
    else
    {
        document.getElementById('Body').style.borderColor = '#63797e';
    }
   
    RemoveHTML()
} 

function IsNumeric(p_strexpression) 
{
    var nums = "0123456789 ,.";
        if (p_strexpression.length==0)return(false);
        for (var n=0; n < p_strexpression.length; n++)
        {
            if(nums.indexOf(p_strexpression.charAt(n))==-1)return(false);
        }
    return(true);
}

function RemoveHTML()
{
    var l_strReplacer = /(<([^>]+)>)/gi;
    if (document.getElementsByTagName)
    {
        var l_objInputs = document.getElementsByTagName("input");
        var l_intCounter = 0;
        while(l_intCounter < l_objInputs.length)
        {
            l_objInputs[l_intCounter].value = l_objInputs[l_intCounter].value.replace(l_strReplacer," "); 
            l_intCounter++;
        }
        
        l_intCounter = 0;
        l_objInputs = document.getElementsByTagName("textarea");
        while(l_intCounter < l_objInputs.length)
        {
            l_objInputs[l_intCounter].value = l_objInputs[l_intCounter].value.replace(l_strReplacer," "); 
            l_intCounter++;
        }
    }
    return true;
}

function StartFadeImg(p_strId)
{
    $(document).ready(function(){
        var l_objFadeDiv = document.getElementById(p_strId+'_0');
           
        l_objFadeDiv.parentNode.style.height = l_objFadeDiv.offsetHeight + 'px';

        l_objFadeDiv.style.filter = 'alpha(opacity=100)';
        l_objFadeDiv.style.opacity = 1;
        for (var i=0, l=l_objFadeDiv.childNodes.length;i<l;i++)
        {
            if (l_objFadeDiv.childNodes[i].tagName == 'DIV')
            {
                l_objFadeDiv.childNodes[i].style.filter = 'alpha(opacity=100)';
                l_objFadeDiv.childNodes[i].style.opacity = 1;
            }
        }    
        
        if(document.getElementById(p_strId+'_1'))
        {         
            setTimeout("FadeImg('" + p_strId + "',0,1,0)", 2500);
        }
    });
}

function FadeImg(p_strId, p_intStart, p_intNext, p_intOpac)
{    
    var l_objCurrentFadeDiv = document.getElementById(p_strId + '_' + p_intStart);
    var l_objNextFadeDiv = document.getElementById(p_strId + '_' + p_intNext);
    var l_intCurrentOpac = 100 - p_intOpac;

    if (p_intOpac == 0)
    {        
        var l_intCounter = 0;
        while(document.getElementById(p_strId+'_'+l_intCounter))
        {
            if (l_intCounter != p_intStart)
            {
                document.getElementById(p_strId+'_'+l_intCounter).style.filter = 'alpha(opacity=0)';
                document.getElementById(p_strId+'_'+l_intCounter).style.opacity = 0;
            }
            l_intCounter = l_intCounter + 1
        }
        
        l_objCurrentFadeDiv.parentNode.style.height = Math.max(l_objCurrentFadeDiv.offsetHeight, l_objNextFadeDiv.offsetHeight) + 'px'
    }
    
    
    l_objCurrentFadeDiv.style.filter = 'alpha(opacity=' + l_intCurrentOpac + ')';
    l_objCurrentFadeDiv.style.opacity = l_intCurrentOpac/100;
    for (var i=0;i<l_objCurrentFadeDiv.childNodes.length;i++)
    {
        if (l_objCurrentFadeDiv.childNodes[i].tagName == 'DIV')
        {
            l_objCurrentFadeDiv.childNodes[i].style.filter = 'alpha(opacity=' + l_intCurrentOpac + ')';
            l_objCurrentFadeDiv.childNodes[i].style.opacity = l_intCurrentOpac/100;
        }
    }
    l_objNextFadeDiv.style.filter = 'alpha(opacity=' + p_intOpac + ')';
    l_objNextFadeDiv.style.opacity = p_intOpac/100;
    for (var i=0;i<l_objNextFadeDiv.childNodes.length;i++)
    {
        if (l_objNextFadeDiv.childNodes[i].tagName == 'DIV')
        {
            l_objNextFadeDiv.childNodes[i].style.filter = 'alpha(opacity=' + p_intOpac + ')';
            l_objNextFadeDiv.childNodes[i].style.opacity = p_intOpac/100;
        }
    }
    
    p_intOpac = p_intOpac + 5;
    if(p_intOpac < 101)
    {
        l_objTimer = setTimeout("FadeImg('" + p_strId + "'," + p_intStart + "," + p_intNext + "," + p_intOpac + ")", 70);
    }
    else
    {
        l_objCurrentFadeDiv.parentNode.style.height =l_objNextFadeDiv.offsetHeight + 'px'
        
        p_intStart = p_intNext;

        if(document.getElementById(p_strId + '_' + (p_intNext + 1)))
        {
            p_intNext = p_intNext +1;
        }
        else
        {
            p_intNext = 0;
        }
        
        
        l_objTimer = setTimeout("FadeImg('" + p_strId + "'," + p_intStart + "," + p_intNext + ",0)", 5000);
    }
}