﻿function OpenPopup(url,title,width,height){
    var wn;
    if (width>0 && height>0){
    }
    else{
        width=400;
        height=820;
    }

    if (title.length==0)
        title = 'popup'
        
    wn = window.open(url,title,'width=' + width + ',height=' + height + ',toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no');
    if (wn)
        wn.focus()
    else
        alert('Your browser does not seem to allow popup windows.\rYou need to enable popup windows for this site to operate correctly')
    //window.showModalDialog(url, null, 'center:yes;resizable:no;dialogHeight:' + height + 'px;dialogWidth:' + width + 'px;titlebar=no');
}

function browser(){
    if (navigator.userAgent.indexOf('Safari')>-1)
        return('safari')
    else{
        if (navigator.userAgent.indexOf('MSIE')>-1)
            return('ie')
        else if (navigator.userAgent.indexOf('Firefox')>-1)
            return('mozilla')
    }
}

function isIE(){
    if (browser()=='ie')
        return true
    else
        return false;
}

function isSafari(){
    if (browser()=='safari')
        return true
    else
        return false
}

function isMozilla(){
    if (browser()=='mozilla')
        return true
    else
        return false
}


// MENU FUNCTIONS //
function preload(ar){
    for (i=0;i<ar.length;i++){
        var img = new Image();
        img.src = ar[i];
    }
}

function preloadMenuImages(){
    var imgArr = new Array("img/menu/about_on.gif","img/menu/accessories_on.gif","img/menu/fonts_on.gif","img/menu/ideas_on.gif","img/menu/submissions_on.gif","img/menu/support_on.gif");
    preload(imgArr);
}

function preloadMenuAboutImages(){
    var imgArr = new Array("img/about/mnu_Clients_on.gif","img/about/mnu_Company_on.gif","img/about/mnu_Designers_on.gif","img/about/mnu_Gallery_on.gif","img/about/mnu_Services_on.gif","img/about/mnu_thisSite_on.gif");
    preload(imgArr);
}

function preloadMenuAccessoriesImages(){
    var imgArr = new Array("img/Accessories/mnu_catalogs_on.gif","img/Accessories/mnu_creativewear_on.gif","img/Accessories/mnu_Desktops_on.gif","img/Accessories/mnu_posters_on.gif");
    preload(imgArr);
}

function preloadMenuFontsImages(){
    var imgArr = new Array("img/Fonts/mnu_Credits_on.gif","img/Fonts/mnu_OpenType_on.gif","img/Fonts/mnu_Pdf_on.gif","img/Fonts/mnu_Sample_on.gif","img/Fonts/mnu_Styles_on.gif","img/Fonts/mnu_TestDrive_on.gif");
    preload(imgArr);
}

function preloadMenuSupportImages(){
    var imgArr = new Array("img/Support/mnu_Faq_on.gif","img/Support/mnu_HowTo_on.gif","img/Support/mnu_Keyboards_on.gif","img/Support/mnu_Languages_on.gif","img/Support/mnu_Licensing_on.gif","img/Support/mnu_OpenType_on.gif");
    preload(imgArr);
}


function imgOver(obj){
    if (obj.src.indexOf('_on.gif')==-1)
        obj.src = obj.src.replace('.gif','_on.gif')
    else
        obj.src = obj.src.replace('_on.gif','.gif')
}

function TopMenuSelect(whichOne){
    var imgs = document.getElementsByTagName('IMG')
    for (i=0;i<imgs.length;i++)
        if (imgs[i].id && imgs[i].id.substring(0,6) == 'topMnu')
            imgs[i].src = imgs[i].src.replace('_on.gif','.gif');

    document.getElementById('topMnu' + whichOne).src = document.getElementById('topMnu' + whichOne).src.replace('.gif','_on.gif');
}

function ShowSub(whichOne,highlightChild){
    try{
        //Hide All submenus
        var divs = document.getElementsByTagName('DIV');
        for (i=0;i<divs.length;i++)
            if (divs[i].id.substring(0,3)=='mnu')
               divs[i].style.display='none'
        
        //Now show the one
        document.getElementById('mnu' + whichOne).style.display='';

        if (highlightChild)
            for (i=0;i<document.getElementById('mnu' + whichOne).childNodes.length;i++){
                if(document.getElementById('mnu' + whichOne).childNodes[i].childNodes.length>0){
                    var img = document.getElementById('mnu' + whichOne).childNodes[i].childNodes[0];
                    if (img.src.indexOf(highlightChild + '.gif')>-1){
                        img.src = 'img/' + whichOne.toLowerCase() + '/mnu_' + highlightChild + '_on.gif';
                        img.parentNode.onmouseover = null;
                        img.parentNode.onmouseout = null;
                    }
                }
            }
    }
    catch(e){alert(e)}
}   


function HideSub(whichOne){
    document.getElementById('mnu' + whichOne).style.visibility='hidden';
}

function HideAllSubs(){
    var subs = document.getElementsByTagName('DIV')
    for (i=0;i<subs.length;i++)
        if (subs[i].id.indexOf('mnu')>-1)
            subs[i].style.visibility='hidden';
}