//var galleryImgCounts = new Array(9, 14, 12, 20, 4);

var galleryImgCounts = new Array(9, 14, 9, 20, 11);

var navImgCount = 8;



var preloadedImgs = new Array()



function preloadImages(){



    var i = 0;

    

    // Preload nav images.

    for (i; i < navImgCount; i++){

		

        preloadedImgs[i] = new Image()

		preloadedImgs[i].src = './img/nav_0' + (i + 1) + '_on.gif'

	}

    

    // Preload gallery images.

    for (j = 0; j < galleryImgCounts.length; j++){

    

        for (k = 0; k < galleryImgCounts[j]; k++){

        

	        preloadedImgs[i] = new Image()

	        preloadedImgs[i].src = './img/gallery/' + j + '_' + k + '.jpg'

            i+=1;

            

            preloadedImgs[i] = new Image()

            preloadedImgs[i].src = './img/gallery/' + j + '_' + k + '_th.jpg'

            i+=1;

        }

    }

}



function nav_in(id) {



    document.getElementById('nav_' + id).src = './img/nav_0' + id + '_on.gif';

}



function nav_out(id) {



    document.getElementById('nav_' + id).src = './img/nav_0' + id + '_off.gif';

}



function writeNav(navOn) {



    document.write(
			
			// With "Star" '<div id="common_nav_star"><nobr>&nbsp;</nobr></div>' +
				
        	'<div id="common_nav"><nobr>' +

            (navOn != '1' ? '<a href="index.html"><img onmouseover="nav_in(\'1\')" onmouseout="nav_out(\'1\')" id="nav_1" src="./img/nav_01_off.gif" alt="Home"         border="0" width="67"  height="53"></a>' : '<img src="./img/nav_01_on.gif" alt="Home"  width="67"  height="53">') +

            (navOn != '2' ? '<a href="weddings.html"><img onmouseover="nav_in(\'2\')" onmouseout="nav_out(\'2\')" id="nav_2" src="./img/nav_02_off.gif" alt="Weddings"     border="0" width="86"  height="53"></a>' : '<img src="./img/nav_02_on.gif" alt="Weddings"     width="86"  height="53">') +

            (navOn != '3' ? '<a href="parties.html"><img onmouseover="nav_in(\'3\')" onmouseout="nav_out(\'3\')" id="nav_3" src="./img/nav_03_off.gif" alt="Parties"      border="0" width="69"  height="53"></a>' : '<img src="./img/nav_03_on.gif" alt="Parties"      width="69"  height="53">') +

            (navOn != '4' ? '<a href="gift_boxes.html"><img onmouseover="nav_in(\'4\')" onmouseout="nav_out(\'4\')" id="nav_4" src="./img/nav_04_off.gif" alt="Gift Boxes"   border="0" width="96"  height="53"></a>' : '<img src="./img/nav_04_on.gif" alt="Gift Boxes"   width="96"  height="53">') +

            (navOn != '5' ? '<a href="specials.html"><img onmouseover="nav_in(\'5\')" onmouseout="nav_out(\'5\')" id="nav_5" src="./img/nav_05_off.gif" alt="Specials" 	   border="0" width="77"  height="53"></a>' : '<img src="./img/nav_05_on.gif" alt="Specials" 	 width="77" height="53">') +
            
            (navOn != '6' ? '<a href="our_cupcakes.html?gallerySelected=-1" ><img onmouseover="nav_in(\'6\')" onmouseout="nav_out(\'6\')" id="nav_6" src="./img/nav_06_off.gif" alt="Our Cupcakes" border="0" width="111" height="53"></a>' : '<img src="./img/nav_06_on.gif" alt="Our Cupcakes" width="111" height="53">') +

            (navOn != '7' ? '<a href="ingredients.html"><img onmouseover="nav_in(\'7\')" onmouseout="nav_out(\'7\')" id="nav_7" src="./img/nav_07_off.gif" alt="Ingredients"  border="0" width="93"  height="53"></a>' : '<img src="./img/nav_07_on.gif" alt="Ingredients"  width="93"  height="53">') +

            (navOn != '8' ? '<a href="prices.html"><img onmouseover="nav_in(\'8\')" onmouseout="nav_out(\'8\')" id="nav_8" src="./img/nav_08_off.gif" alt="Prices" border="0" width="58"  height="53"></a>' : '<img src="./img/nav_08_on.gif" alt="Prices" width="58"  height="53">') +       
            
			(navOn != '9' ? '<a href="other_stuff.html"><img onmouseover="nav_in(\'9\')" onmouseout="nav_out(\'9\')" id="nav_9" src="./img/nav_09_off.gif" alt="Other Stuff" border="0" width="95"  height="53"></a>' : '<img src="./img/nav_09_on.gif" alt="Other Stuff" width="95" height="53">') +                                             

            '<img alt="" src="./img/nav_end.gif" width="23" height="53">' +

        '</nobr></div>' +

    

        '<div id="common_header">' +

        '    <img alt="Cakeadoodledo" width="777" height="144" src="./img/header_bg.png">' +

        '</div>' +
    

		
		'<div id="common_nav_top_right">' +

            (navOn != 't1' ? '<a class="l_pink_ul" href="how_to_order.html">How to order</a>' : '<a class="pink_un">How to order</a>') + '<a class="light_grey">&nbsp;&nbsp;|&nbsp;&nbsp;</a>' +

            (navOn != 't2' ? '<a class="l_pink_ul" href="market.html">Market</a>' : '<a class="pink_un">Market</a>') + '<a class="light_grey">&nbsp;&nbsp;|&nbsp;&nbsp;</a>' +

			(navOn != 't3' ? '<a class="l_pink_ul" href="classes.html">Cupcake Classes</a>' : '<a class="pink_un">Cupcake Classes</a>') + '<a class="light_grey">&nbsp;&nbsp;|&nbsp;&nbsp;</a>' +
			
            (navOn != 't4' ? '<a class="l_pink_ul" href="contact.html">Contact</a>' : '<a class="pink_un">Contact</a>') +

        '</div>'

    );

}



function writeGallery(galleryName) {



    document.write(

    

        '<div id="common_gallery_title_grey">' +

            '<div id="common_gallery_title_white">' +

                '<span id="common_gallery_title_name"><a class="brown">' + galleryName + '</a></span>' +

                '<span id="common_gallery_title_previous"><a class="l_pink" href="javascript:galleryPrev()"><img alt="" width="5" height="5" src="./img/pink_arrows_double_left.gif" border="0">&nbsp;</a><a class="l_pink_ul" href="javascript:galleryPrev()">previous</a></span>' +

                '<span id="common_gallery_title_next"><a class="l_pink_ul" href="javascript:galleryNext()">next</a><a class="l_pink" href="javascript:galleryNext()">&nbsp;<img alt="" width="5" height="5" src="./img/pink_arrows_double_right.gif" border="0"></a></span>' +

            '</div>' +

       '</div>' +

       '<div id="common_gallery_main_grey">' +

            '<div id="common_gallery_main_white">' +

                '<div id="common_gallery_main_image">' +

                    '<img id="galleryImg" alt="" width="290" height="290" src="./img/gallery/' + galleryCurrent + '_' + imageCurrent + '.jpg" border="0">' +

                '</div>' +

            '</div>' +

        '</div>'

        

    );

}



function writeThumbs() {



    var writeString = '<img id="" alt="" src="./img/pixel_transp.gif" width="750" height="6"><br/>';

    

    var count = 0;

    

    for (var i = 0; i < galleryImgCounts.length; i++) {

    

        if (gallerySelected == i || gallerySelected == '-1') {

        

            for (var j = 0; j < galleryImgCounts[i]; j++, count++) {

            

                if (count % 5 == 0 && count != 0) {

                    writeString += '<br/><img id="" alt="" src="./img/pixel_transp.gif" width="750" height="10"><br/>';

                }

                

                writeString += '<a href="javascript:openGallery('+ i + ',' + j + ',' + gallerySelected + ')"><img id="our_cupcakes_thumb" alt="" width="142" height="142" src="./img/gallery/' + i + '_' + j + '_th.jpg" border="0"></a>';

                

                if ((count + 1) % 5 != 0) {

                    writeString += '<img id="" alt="" src="./img/pixel_transp.gif" width="10" height="142">';

                }

            }

        }

    }

            

    writeString += '<br/><img id="" alt="" src="./img/pixel_transp.gif" width="750" height="20">';

    

    document.write(writeString);

}



function openGallery(galleryCurrent, imageCurrent, gallerySelected) {



    window.open('gallery.html?galleryCurrent=' + galleryCurrent + '&imageCurrent=' + imageCurrent + '&gallerySelected=' + gallerySelected, 'cakeadoodledo', 'width=710,height=510');

}



function galleryPrev() {



    imageCurrent = (imageCurrent - 1) % galleryImgCounts[galleryCurrent];

    

    if (imageCurrent < 0) {

    

        if (gallerySelected == -1) {

            

            galleryCurrent = (galleryCurrent - 1) % galleryImgCounts.length;

            

            if (galleryCurrent < 0) {

                

                galleryCurrent = galleryImgCounts.length - 1;

            }

        }

        

        imageCurrent = galleryImgCounts[galleryCurrent] - 1;

    }

    

    document.getElementById('galleryImg').src = './img/gallery/' + galleryCurrent + "_" + imageCurrent + '.jpg';

}



function galleryNext() {



    imageCurrent = ((imageCurrent + 1) % galleryImgCounts[galleryCurrent]);

    

    if (imageCurrent == 0 && gallerySelected == -1) {

        galleryCurrent = (galleryCurrent + 1) % galleryImgCounts.length;

    }

    

    document.getElementById('galleryImg').src = './img/gallery/' + galleryCurrent + "_" + imageCurrent + '.jpg';

}



function gup(name) {



	var regexS = "[\\?&]"+name+"=([^&#]*)";

	var regex = new RegExp(regexS);

	var tmpURL = window.location.href;

	var results = regex.exec(tmpURL);

  

    if(results == null) {

        return "";

    } else {

        return parseInt(results[1]);

    }

}



//Mail

e1='mail';
e2='cakeadoodledo';
e3='co';
e4='uk';
e=e1+'&#64;'+e2+'&#46;'+e3+'&#46;'+e4;
a1='<a class="l_pink_ul" href="mai' + 'lto:';
a2='">';
a3='</a>';
