﻿    var hash;
    var back = '';
    if (window.location.hash==''){hash='Home';}else{hash=window.location.hash;}
    if (hash.indexOf('#') != -1){hash = hash.substring(1);}
    function home(e)
        {   
        page('Home');
        setTimeout("$('#divHome').fadeIn(250)",250);
        return false;
        }
    function quote(model)
        {
        page('Quote');
        setTimeout("$('#divQuote').fadeIn(250)",250);
        if (model == 'undefined'){model='';}
        document.getElementById('txtStyle').value = model;
        return false;
        }
    function services()
        {
        page('Services');
        setTimeout("$('#divServices').fadeIn(250)",250);
        return false;
        }
    function contact()
        {
        page('Contact');
        setTimeout("$('#divContact').fadeIn(250)",250);
        return false;
        }
//Scripts for Left Buttons
    function allProducts()
        {
        // nahodim P
        var p = hash;
        if (p.indexOf('1') != -1){p = '1'};
        if (p.indexOf('2') != -1){p = '2'};
        if (p.indexOf('3') != -1){p = '3'};
        if (p.indexOf('4') != -1){p = '4'};
        if (p.indexOf('5') != -1){p = '5'};
        if (p!=1 && p!=2 && p!=3 && p!=4 && p!=5)
            {if(p!='Product'){document.getElementById('ib' + p).src = 'http://alpha-usb.com/images/buttons/btn_' + p + '.jpg';}}
        $('#div' + p).fadeOut(250);
        // Pagers set --------------------------------------------------
        $('#topPrev').fadeOut(250);
        $('#btmPrev').fadeOut(250);
        //product page ibPic visibility fix
        document.getElementById('ibPic2').style.visibility = 'visible';
        document.getElementById('ibPic3').style.visibility = 'visible';
        document.getElementById('ibPic4').style.visibility = 'visible';
        document.getElementById('ibPic5').style.visibility = 'visible';
        document.getElementById('ibPic6').style.visibility = 'visible';
        document.getElementById('ibPic7').style.visibility = 'visible';
        // ---- vklyuchaem
        setTimeout("$('#topNext').fadeIn(250)",250);
        setTimeout("$('#btmNext').fadeIn(250)",250);
        setTimeout("$('#divProducts').fadeIn(250)",250);
        setTimeout("$('#div1').fadeIn(250)",250);
        document.getElementById('ibAll_products').src = 'http://alpha-usb.com/images/buttons/btn_All_Products2.jpg';
        document.getElementById('ibProducts').src = 'http://alpha-usb.com/images/buttons/btn_Products2.jpg';
        // Hash set ----------------------------------------------------
        window.location.hash = '#products.page1'
        hash = "products.page1"
        return false;           
        }
    function topSellers()
        {
        page('Topsellers');
        setTimeout("$('#divTopsellers').fadeIn(250)",250);
        // extra stuff
        setTimeout("$('#divProducts').fadeIn(250)",250);
        return false;        
        }
    function plastic()
        {
        page('Plastic');
        setTimeout("$('#divPlastic').fadeIn(250)",250);
        // extra stuff
        setTimeout("$('#divProducts').fadeIn(250)",250);
        return false;        
        }
    function metal()
        {
        page('Metal');
        setTimeout("$('#divMetal').fadeIn(250)",250);
        // extra stuff
        setTimeout("$('#divProducts').fadeIn(250)",250);
        return false;        
        }
    function pens()
        {
        page('Pens');
        setTimeout("$('#divPens').fadeIn(250)",250);
        // extra stuff
        setTimeout("$('#divProducts').fadeIn(250)",250);
        return false;        
        }
    function swivel()
        {
        page('Swivel');
        setTimeout("$('#divSwivel').fadeIn(250)",250);
        // extra stuff
        setTimeout("$('#divProducts').fadeIn(250)",250);
        return false;        
        }
    function leather()
        {
        page('Leather');
        setTimeout("$('#divLeather').fadeIn(250)",250);
        // extra stuff
        setTimeout("$('#divProducts').fadeIn(250)",250);
        return false;        
        }
    function compact()
        {
        page('Compact');
        setTimeout("$('#divCompact').fadeIn(250)",250);
        // extra stuff
        setTimeout("$('#divProducts').fadeIn(250)",250);
        return false;        
        }
    function product(model)
        {
        // nahodim P
        var p = hash;
        back = hash;
        if (p.indexOf('1') != -1){p = '1'};
        if (p.indexOf('2') != -1){p = '2'};
        if (p.indexOf('3') != -1){p = '3'};
        if (p.indexOf('4') != -1){p = '4'};
        if (p.indexOf('5') != -1){p = '5'};
        // ----- rabochaya chast
        if (p==1 || p==2 || p==3 || p==4 || p==5)
            {
            document.getElementById('ibAll_products').src = 'http://alpha-usb.com/images/buttons/btn_All_Products.jpg';
            // Pagers set --------------------------------------------------
            $('#topPrev').fadeOut(250)
            $('#btmPrev').fadeOut(250)
            $('#topNext').fadeOut(250)
            $('#btmNext').fadeOut(250)
            }
        else // с других продуктов
            {
            document.getElementById('ib' + p).src = 'http://alpha-usb.com/images/buttons/btn_' + p + '.jpg';
            }
        document.getElementById('ibProducts').src = 'http://alpha-usb.com/images/buttons/btn_Products.jpg';
        $('#div' + p).fadeOut(250);
        $('#divProducts').fadeOut(250);
        // ---- vklyuchaem
        document.getElementById('ibProducts').src = 'http://alpha-usb.com/images/buttons/btn_Products2.jpg';
        document.getElementById('imgProduct').src = 'http://alpha-usb.com/images/loader.gif'; 
        document.getElementById('ibPic1').src = 'http://alpha-usb.com/images/loader.gif'; 
        document.getElementById('ibPic2').src = 'http://alpha-usb.com/images/loader.gif'; 
        document.getElementById('ibPic3').src = 'http://alpha-usb.com/images/loader.gif'; 
        document.getElementById('ibPic4').src = 'http://alpha-usb.com/images/loader.gif'; 
        document.getElementById('ibPic5').src = 'http://alpha-usb.com/images/loader.gif'; 
        document.getElementById('ibPic6').src = 'http://alpha-usb.com/images/loader.gif'; 
        document.getElementById('ibPic7').src = 'http://alpha-usb.com/images/loader.gif'; 
        window.location.hash = '#Product';
        hash = "Product";
        // - PRODUCT PAGE SETTINGS -------------------------------------
        document.getElementById("imgProduct").src = "http://alpha-usb.com/images/big/" + model + "_1.jpg";
        // materials
        if (model.indexOf('PL') != -1)
            {document.getElementById('lblMaterials').innerHTML = 'Plastic';}
        else
            {document.getElementById('lblMaterials').innerHTML = 'Metal, Plastic';}
        // dimentions
        if (model=='PL-01')
            {document.getElementById('lblDimentions').innerHTML = '72mm x 20mm x 7mm';}
        if (model=='PL-02')
            {document.getElementById('lblDimentions').innerHTML = '67mm x 20mm x 7mm';}
        if (model=='PL-03')
            {document.getElementById('lblDimentions').innerHTML = '45mm x 45mm x 15mm';}
        if (model=='SWM-01')
            {document.getElementById('lblDimentions').innerHTML = '57mm x 20mm x 10mm';}
        // imprinting
        if (model=='PL-01' || model=='PL-02' || model=='SWM-01' || model=='PL-11')
            {document.getElementById('lblImprinting').innerHTML = '4 Color, Full Color';}
        if (model.indexOf('ME') != -1)
            {document.getElementById('lblImprinting').innerHTML = '4 Color, Laser Engraving';}
        // product pictures
        document.getElementById('ibPic1').src = 'http://alpha-usb.com/images/big/' + model + '_1.jpg';
        document.getElementById('ibPic2').src = 'http://alpha-usb.com/images/big/' + model + '_2.jpg';
        document.getElementById('ibPic3').src = 'http://alpha-usb.com/images/big/' + model + '_3.jpg';
        document.getElementById('ibPic4').src = 'http://alpha-usb.com/images/big/' + model + '_4.jpg';
        document.getElementById('ibPic5').src = 'http://alpha-usb.com/images/big/' + model + '_5.jpg';
        document.getElementById('ibPic6').src = 'http://alpha-usb.com/images/big/' + model + '_6.jpg';
        document.getElementById('ibPic7').src = 'http://alpha-usb.com/images/big/' + model + '_7.jpg';
        // onclientclicks set
        document.getElementById('ibPic1').onclick = function(){document.getElementById('imgProduct').src='http://alpha-usb.com/images/big/' + model + '_1.jpg';return false;}
        document.getElementById('ibPic2').onclick = function(){document.getElementById('imgProduct').src='http://alpha-usb.com/images/big/' + model + '_2.jpg';return false;}
        document.getElementById('ibPic3').onclick = function(){document.getElementById('imgProduct').src='http://alpha-usb.com/images/big/' + model + '_3.jpg';return false;}
        document.getElementById('ibPic4').onclick = function(){document.getElementById('imgProduct').src='http://alpha-usb.com/images/big/' + model + '_4.jpg';return false;}
        document.getElementById('ibPic5').onclick = function(){document.getElementById('imgProduct').src='http://alpha-usb.com/images/big/' + model + '_5.jpg';return false;}
        document.getElementById('ibPic6').onclick = function(){document.getElementById('imgProduct').src='http://alpha-usb.com/images/big/' + model + '_6.jpg';return false;}
        document.getElementById('ibPic7').onclick = function(){document.getElementById('imgProduct').src='http://alpha-usb.com/images/big/' + model + '_7.jpg';return false;}
        //--
        document.getElementById('ibGoQuote1').onclick = function(){quote(model);return false;}
        // product colors
        if (model.indexOf('PL') != -1){colorer(1)}
        if (model.indexOf('ME') != -1){colorer(2)}
        if (model.indexOf('SWM') != -1){colorer(2)}
        if (model.indexOf('Pen') != -1){colorer(3)}
        if (model.indexOf('LR') != -1){colorer(3)}
        if (model.indexOf('CT') != -1){colorer(1)}
        // specs set
        if (model.indexOf('CT') != -1){document.getElementById('lblSpecs1').innerHTML = '1GB, 2GB, 4GB, 8GB, 16GB';}
        else {document.getElementById('lblSpecs1').innerHTML = '64MB, 128MB, 256MB, 512MB, 1GB, 2GB, 4GB, 8GB, 16GB';}
        setTimeout("$('#divProduct').fadeIn(250)",250);
        return false;
        }
    function goBack()
        {
        if (back.indexOf('page') != -1){allProducts();return false;}
        if (back=='Topsellers'){topSellers();return false;}
        if (back=='Plastic'){plastic();return false;}
        if (back=='Metal'){metal();return false;}
        if (back=='Pens'){pens();return false;}
        if (back=='Swivel'){swivel();return false;}
        if (back=='Leather'){leather();return false;}
        if (back=='Compact'){compact();return false;}
        }
//Pager Scripts
    function next()
        {
        if (hash == 'products.page4')
            {
            hash = 'products.page5'
            window.location.hash = '#products.page5'
            $('#div4').fadeOut(250);
            setTimeout("$('#div5').fadeIn(250)",250);
            }
        if (hash == 'products.page5')
            {
            $("#topNext").fadeOut(250);
            $("#btmNext").fadeOut(250);
            }
        if (hash == 'products.page3')
            {
            hash = 'products.page4'
            window.location.hash = '#products.page4'
            $("#div3").fadeOut(250);
            setTimeout("$('#div4').fadeIn(250)",250);
            }
        if (hash == 'products.page2')
            {
            hash = 'products.page3'
            window.location.hash = '#products.page3'
            $("#div2").fadeOut(250);
            setTimeout("$('#div3').fadeIn(250)",250);
            }
        if (hash == 'products.page1')
            {
            hash = 'products.page2'
            window.location.hash = '#products.page2'
            $("#div1").fadeOut(250);
            setTimeout("$('#div2').fadeIn(250)",250);
            $("#topPrev").fadeOut(0);
            $("#btmPrev").fadeOut(0);          
            $("#topPrev").fadeIn(250);
            $("#btmPrev").fadeIn(250);
            }
        // too fast click protection
        document.getElementById('topNext').onclick = '';
        setTimeout("document.getElementById('topNext').onclick = next",400);
        document.getElementById('btmNext').onclick = '';
        setTimeout("document.getElementById('btmNext').onclick = next",400);
        }
    function prev()
        {
        if (hash == 'products.page2')
            {
            hash = 'products.page1'
            window.location.hash = '#products.page1'
            $("#div2").fadeOut(250);
            setTimeout("$('#div1').fadeIn(250)",250);
            $("#topPrev").fadeOut(250);
            $("#btmPrev").fadeOut(250);
            }
        if (hash == 'products.page3')
            {
            hash = 'products.page2'
            window.location.hash = '#products.page2'
            $("#div3").fadeOut(250);
            setTimeout("$('#div2').fadeIn(250)",250);
            }
        if (hash == 'products.page4')
            {
            hash = 'products.page3'
            window.location.hash = '#products.page3'
            $("#div4").fadeOut(250);
            setTimeout("$('#div3').fadeIn(250)",250);
            }
        if (hash == 'products.page5')
            {
            hash = 'products.page4'
            window.location.hash = '#products.page4'
            $("#div5").fadeOut(250);
            setTimeout("$('#div4').fadeIn(250)",250);
            $("#topNext").fadeIn(250);
            $("#btmNext").fadeIn(250);
            }
        // too fast click protection
        document.getElementById('topPrev').onclick = '';
        setTimeout("document.getElementById('topPrev').onclick = prev",600);
        document.getElementById('btmPrev').onclick = '';
        setTimeout("document.getElementById('btmPrev').onclick = prev",600);
        }
// Scripts for quote page
    function quote_submit()
        {
        // prescript
        document.getElementById('lblReport').innerHTML = '';
        // нет контактных данных
        if ((document.getElementById('txtEmail').value == '') && (document.getElementById('txtPhone').value == ''))
            {
            document.getElementById('lblReport').innerHTML = 'Please provide your contact info';
            return false;
            }
        else // есть контактные данные
            {
            // неверный формат имэйла
            if (document.getElementById('txtEmail').value != '')
                {
                if (document.getElementById('txtEmail').value.indexOf('@') == -1 || document.getElementById('txtEmail').value.indexOf('.') == -1)
                    {
                    document.getElementById('lblReport').innerHTML = 'Invalid E-mail address';
                    return false;
                    }
                }
            document.getElementById('imgLoader').style.visibility='visible';
            document.getElementById('ibSubmit').src='http://alpha-usb.com/images/buttons/ibSubmit2.png';
            }
        //script
        var xmlhttp;
        name = document.getElementById('txtName').value
        style = document.getElementById('txtStyle').value
        capacity = document.getElementById('txtCapacity').value
        quantity = document.getElementById('txtQuantity').value
        email = document.getElementById('txtEmail').value
        phone = document.getElementById('txtPhone').value
        comments = document.getElementById('txtComments').value
        imprint = document.getElementById('cbImprint').checked
        lanyard = document.getElementById('cbLanyard').checked
        keyring = document.getElementById('cbKeyring').checked
        giftbox = document.getElementById('cbGiftbox').checked
        preload = document.getElementById('cbPreload').checked
        callme = document.getElementById('cbCallme').checked
        ip = document.getElementById('lblIP').innerHTML
        host =  document.getElementById('lblHOST').innerHTML
        keyword =  document.getElementById('lblKEYWORD').innerHTML
        if (window.XMLHttpRequest)
            {
            // code for IE7+, Firefox, Chrome, Opera, Safari
            xmlhttp=new XMLHttpRequest();
            }
        else
            {
            // code for IE6, IE5
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange=function()
            {
            if(xmlhttp.readyState==4)
                {
                document.getElementById('lblReport').innerHTML = xmlhttp.responseText;
                document.getElementById('imgLoader').style.visibility = 'hidden'
                document.getElementById('ibSubmit').src = 'http://alpha-usb.com/images/buttons/ibSubmit.png'
                }
            }
        xmlhttp.open('GET','quoteprocessor.aspx?name='+name+'&style='+style+'&capacity='+capacity+'&quantity='+quantity+'&email='+email+'&phone='+phone+'&comments='+comments+'&imprint='+imprint+'&lanyard='+lanyard+'&keyring='+keyring+'&giftbox='+giftbox+'&preload='+preload+'&callme='+callme+'&IP='+ip+'&HOST='+host+'&KEYWORD='+keyword,true);
        xmlhttp.send(null);
        return false;
        }
// other functions -----------------
    function page(e)
        {
        // nahodim P
        var p = hash;
        if (p.indexOf('1') != -1){p = '1'};
        if (p.indexOf('2') != -1){p = '2'};
        if (p.indexOf('3') != -1){p = '3'};
        if (p.indexOf('4') != -1){p = '4'};
        if (p.indexOf('5') != -1){p = '5'};
        // ----- rabochaya chast
        if (p==1 || p==2 || p==3 || p==4 || p==5)
            {
            document.getElementById('ibAll_products').src = 'http://alpha-usb.com/images/buttons/btn_All_Products.jpg';
            // Pagers set --------------------------------------------------
            $('#topPrev').fadeOut(250)
            $('#btmPrev').fadeOut(250)
            $('#topNext').fadeOut(250)
            $('#btmNext').fadeOut(250)
            }
        else // с других продуктов
            {if (p!='Product'){document.getElementById('ib' + p).src = 'http://alpha-usb.com/images/buttons/btn_' + p + '.jpg';}}
        document.getElementById('ibProducts').src = 'http://alpha-usb.com/images/buttons/btn_Products.jpg';
        $('#div' + p).fadeOut(250);
        //product page ibPic visibility fix
        document.getElementById('ibPic2').style.visibility = 'visible';
        document.getElementById('ibPic3').style.visibility = 'visible';
        document.getElementById('ibPic4').style.visibility = 'visible';
        document.getElementById('ibPic5').style.visibility = 'visible';
        document.getElementById('ibPic6').style.visibility = 'visible';
        document.getElementById('ibPic7').style.visibility = 'visible';
        // ---- vklyuchaem
        document.getElementById('ib' + e).src = 'http://alpha-usb.com/images/buttons/btn_' + e + '2.jpg';
        if (e == 'Home' || e == 'Quote' || e == 'Services' || e == 'Contact')
            {
            $('#divProducts').fadeOut(250);
            }
        else
            {
            document.getElementById('ibProducts').src = 'http://alpha-usb.com/images/buttons/btn_Products2.jpg';
            }
        // Hash set ----------------------------------------------------
        window.location.hash = '#' + e;
        hash = e;
        return false;
        }
    function colorer(mode)
        {
        if (mode==1)
            {
            document.getElementById('imgColor1').style.visibility = 'visible';
            document.getElementById('imgColor2').style.visibility = 'visible';
            document.getElementById('imgColor3').style.visibility = 'visible';
            document.getElementById('imgColor4').style.visibility = 'visible';
            document.getElementById('imgColor5').style.visibility = 'visible';
            document.getElementById('imgColor6').style.visibility = 'visible';
            document.getElementById('imgColor7').style.visibility = 'visible';
            }
        if (mode==2)
            {
            document.getElementById('imgColor1').style.visibility = 'visible';
            document.getElementById('imgColor2').style.visibility = 'visible';
            document.getElementById('imgColor3').style.visibility = 'visible';
            document.getElementById('imgColor4').style.visibility = 'visible';
            document.getElementById('imgColor5').style.visibility = 'visible';
            document.getElementById('imgColor6').style.visibility = 'hidden';
            document.getElementById('imgColor7').style.visibility = 'hidden';
            }
        if (mode==3)
            {
            document.getElementById('imgColor1').style.visibility = 'visible';
            document.getElementById('imgColor2').style.visibility = 'visible';
            document.getElementById('imgColor3').style.visibility = 'visible';
            document.getElementById('imgColor4').style.visibility = 'hidden';
            document.getElementById('imgColor5').style.visibility = 'hidden';
            document.getElementById('imgColor6').style.visibility = 'hidden';
            document.getElementById('imgColor7').style.visibility = 'hidden';
            }
        }