gallery1count = 14;
gallery2count = 33;
gallery3count = 39;
gallery4count = 13;

function over(o){o.src = o.src.substr(0, (o.src.length - 4)) + '_ro' + o.src.substr(o.src.length - 4);}
function out(o){o.src = o.src.substr(0, (o.src.length - 7)) + o.src.substr(o.src.length - 4);}

function tn(set,num)
{
var gallery;

switch(set)
{
case 1: gallery = 'weddings'; break;
case 2: gallery = 'parties'; break;
case 3: gallery = 'ce'; break;
case 4: gallery = 'ue'; break;
default: //do nothing
}

document.getElementById('main_image').src = '/images/' + gallery + '/' + gallery + num + '.jpg';

while (num > 6)
{
num -= 6;	
}

document.getElementById('tn1').style.opacity = '0.4';
document.getElementById('tn2').style.opacity = '0.4';
document.getElementById('tn3').style.opacity = '0.4';
document.getElementById('tn4').style.opacity = '0.4';
document.getElementById('tn5').style.opacity = '0.4';
document.getElementById('tn6').style.opacity = '0.4';

document.getElementById('tn' + num).style.opacity = '1.0';
}

function setchange(set)
{

var gallery;
var html;
var html2;
var color;
var colorGray = '#6e6d6c';
var pages;
var x;

switch(set)
{
case 1: gallery = 'weddings'; color = '#a45691'; pages = 3; break;
case 2: gallery = 'parties'; color = '#399693'; pages = 6; break;
case 3: gallery = 'ce'; color = '#98cd7e'; pages = 7; break;
case 4: gallery = 'ue'; color = '#3b6589'; pages = 3; break;
default: //do nothing
}

switch(set)
{
case 1:
html2 = '<a href="#" onclick="page(1,1,3);" id="page_left">&laquo;</a>';
html2 += '<a href="#" onclick="page(1,1,3);" id="pager_1" style="font-weight: bold;">1</a>';
html2 += '<a href="#" onclick="page(1,2,3);" id="pager_2">2</a>';
html2 += '<a href="#" onclick="page(1,3,3);" id="pager_3">3</a>';
html2 += '<a href="#" onclick="page(1,3,3);" id="page_right">&raquo;</a>';
document.getElementById('hyperlink1').style.color = color;
document.getElementById('hyperlink2').style.color = colorGray
document.getElementById('hyperlink3').style.color = colorGray
document.getElementById('hyperlink4').style.color = colorGray
break;
case 2:
html2 = '<a href="#" onclick="page(2,1,6);" id="page_left">&laquo;</a>';
html2 += '<a href="#" onclick="page(2,1,6);" id="pager_1" style="font-weight: bold;">1</a>';
html2 += '<a href="#" onclick="page(2,2,6);" id="pager_2">2</a>';
html2 += '<a href="#" onclick="page(2,3,6);" id="pager_3">3</a>';
html2 += '<a href="#" onclick="page(2,4,6);" id="pager_4">4</a>';
html2 += '<a href="#" onclick="page(2,5,6);" id="pager_5">5</a>';
html2 += '<a href="#" onclick="page(2,6,6);" id="pager_6">6</a>';
html2 += '<a href="#" onclick="page(2,6,6);" id="page_right">&raquo;</a>';
document.getElementById('hyperlink1').style.color = colorGray
document.getElementById('hyperlink2').style.color = color;
document.getElementById('hyperlink3').style.color = colorGray
document.getElementById('hyperlink4').style.color = colorGray
break;
case 3:
html2 = '<a href="#" onclick="page(3,1,7);" id="page_left">&laquo;</a>';
html2 += '<a href="#" onclick="page(3,1,7);" id="pager_1" style="font-weight: bold;">1</a>';
html2 += '<a href="#" onclick="page(3,2,7);" id="pager_2">2</a>';
html2 += '<a href="#" onclick="page(3,3,7);" id="pager_3">3</a>';
html2 += '<a href="#" onclick="page(3,4,7);" id="pager_4">4</a>';
html2 += '<a href="#" onclick="page(3,5,7);" id="pager_5">5</a>';
html2 += '<a href="#" onclick="page(3,6,7);" id="pager_6">6</a>';
html2 += '<a href="#" onclick="page(3,7,7);" id="pager_7">7</a>';
html2 += '<a href="#" onclick="page(3,7,7);" id="page_right">&raquo;</a>';
document.getElementById('hyperlink1').style.color = colorGray
document.getElementById('hyperlink2').style.color = colorGray
document.getElementById('hyperlink3').style.color = color;
document.getElementById('hyperlink4').style.color = colorGray
break;
case 4:
html2 = '<a href="#" onclick="page(4,1,4);" id="page_left">&laquo;</a>';
html2 += '<a href="#" onclick="page(4,1,4);" id="pager_1" style="font-weight: bold;">1</a>';
html2 += '<a href="#" onclick="page(4,2,4);" id="pager_2">2</a>';
html2 += '<a href="#" onclick="page(4,3,4);" id="pager_3">3</a>';
html2 += '<a href="#" onclick="page(4,3,4);" id="page_right">&raquo;</a>';
document.getElementById('hyperlink1').style.color = colorGray
document.getElementById('hyperlink2').style.color = colorGray
document.getElementById('hyperlink3').style.color = colorGray
document.getElementById('hyperlink4').style.color = color;
break;
default: //do nothing
}

document.getElementById('paging').innerHTML = html2;

html = '<div id="tn1" class="tns">';
html += '<a href="#" onclick="tn(' + set + ',1);"><img src="/images/' + gallery + '/' + gallery + '_tn1.jpg" alt="Thumbnail 1" id="tnimg1" style="border-color: ' + color + '" /></a>';
html += '</div>';
html += '<div id="tn2" class="tns">';
html += '<a href="#" onclick="tn(' + set + ',2);"><img src="/images/' + gallery + '/' + gallery + '_tn2.jpg" alt="Thumbnail 2" id="tnimg2" style="border-color: ' + color + '" /></a>';
html += '</div>';
html += '<div id="tn3" class="tns">';
html += '<a href="#" onclick="tn(' + set + ',3);"><img src="/images/' + gallery + '/' + gallery + '_tn3.jpg" alt="Thumbnail 3" id="tnimg3" style="border-color: ' + color + '" /></a>';
html += '</div>';
html += '<div id="tn4" class="tns">';
html += '<a href="#" onclick="tn(' + set + ',4);"><img src="/images/' + gallery + '/' + gallery + '_tn4.jpg" alt="Thumbnail 4" id="tnimg4" style="border-color: ' + color + '" /></a>';
html += '</div>';
html += '<div id="tn5" class="tns">';
html += '<a href="#" onclick="tn(' + set + ',5);"><img src="/images/' + gallery + '/' + gallery + '_tn5.jpg" alt="Thumbnail 5" id="tnimg5" style="border-color: ' + color + '" /></a>';
html += '</div>';
html += '<div id="tn6" class="tns">';
html += '<a href="#" onclick="tn(' + set + ',6);"><img src="/images/' + gallery + '/' + gallery + '_tn6.jpg" alt="Thumbnail 6" id="tnimg6" style="border-color: ' + color + '" /></a>';
html += '</div>';

document.getElementById('main_image').src = '/images/' + gallery + '/' + gallery + '1.jpg';
document.getElementById('tn_container').innerHTML = html;

}

function page(set,page,total)
{
var gallery;
var html;
var offset;
var num1;
var num2;
var num3;
var num4;
var num5;
var num6;
var color;
var pages;
var imagecount;
var x;


switch(set)
{
case 1: gallery = 'weddings'; color = '#a45691'; pages = 3; imagecount = gallery1count; break;
case 2: gallery = 'parties'; color = '#399693'; pages = 6; imagecount = gallery2count; break;
case 3: gallery = 'ce'; color = '#98cd7e'; pages = 7; imagecount = gallery3count; break;
case 4: gallery = 'ue'; color = '#3b6589'; pages = 3; imagecount = gallery4count; break;
default: //do nothing
}

offset = (page - 1) * 6;

num1 = offset + 1;
num2 = offset + 2;
num3 = offset + 3;
num4 = offset + 4;
num5 = offset + 5;
num6 = offset + 6;

html = '<div id="tn1" class="tns">';

html += '<a href="#" onclick="tn(' + set + ',' + num1 + ');"><img src="/images/' + gallery + '/' + gallery + '_tn' + num1 + '.jpg" alt="Thumbnail 1" id="tnimg1" style="border-color: ' + color + '" /></a>';
html += '</div>';
html += '<div id="tn2" class="tns">';
html += '<a href="#" onclick="tn(' + set + ',' + num2 + ');"><img src="/images/' + gallery + '/' + gallery + '_tn' + num2 + '.jpg" alt="Thumbnail 2" id="tnimg2" style="border-color: ' + color + '" /></a>';
html += '</div>';
html += '<div id="tn3" class="tns">';
html += '<a href="#" onclick="tn(' + set + ',' + num3 + ');"><img src="/images/' + gallery + '/' + gallery + '_tn' + num3 + '.jpg" alt="Thumbnail 3" id="tnimg3" style="border-color: ' + color + '" /></a>';
html += '</div>';
html += '<div id="tn4" class="tns">';
html += '<a href="#" onclick="tn(' + set + ',' + num4 + ');"><img src="/images/' + gallery + '/' + gallery + '_tn' + num4 + '.jpg" alt="Thumbnail 4" id="tnimg4" style="border-color: ' + color + '" /></a>';
html += '</div>';
html += '<div id="tn5" class="tns">';
html += '<a href="#" onclick="tn(' + set + ',' + num5 + ');"><img src="/images/' + gallery + '/' + gallery + '_tn' + num5 + '.jpg" alt="Thumbnail 5" id="tnimg5" style="border-color: ' + color + '" /></a>';
html += '</div>';
html += '<div id="tn6" class="tns">';
html += '<a href="#" onclick="tn(' + set + ',' + num6 + ');"><img src="/images/' + gallery + '/' + gallery + '_tn' + num6 + '.jpg" alt="Thumbnail 6" id="tnimg6" style="border-color: ' + color + '" /></a>';
html += '</div>';

document.getElementById('main_image').src = '/images/' + gallery + '/' + gallery + (1 + offset) + '.jpg';
document.getElementById('tn_container').innerHTML = html;

if (num2 > imagecount){document.getElementById('tn2').style.display = 'none';}
else{document.getElementById('tn2').style.display = 'inline';}

if (num3 > imagecount){document.getElementById('tn3').style.display = 'none';}
else{document.getElementById('tn3').style.display = 'inline';}

if (num4 > imagecount){document.getElementById('tn4').style.display = 'none';}
else{document.getElementById('tn4').style.display = 'inline';}

if (num5 > imagecount){document.getElementById('tn5').style.display = 'none';}
else{document.getElementById('tn5').style.display = 'inline';}

if (num6 > imagecount){num6 = 'blank';document.getElementById('tn6').style.display = 'none';}
else{document.getElementById('tn6').style.display = 'inline';}

//bold current pager

for (x=0;x<=total;x++)
{
if (x==page)
{
document.getElementById('pager_' + x).style.fontWeight = 'bold';
}
if ((x != page) & (x > 0))
{
document.getElementById('pager_' + x).style.fontWeight = '400';
}
}



}
