function Photo_Gallery() { this.loaded = 0; this.queryitems = []; this.auto = 0; this.staff = 0; this.slideshow = new Array(); this.slideshow[0] = new Array(); this.slideshow[1] = new Array(); this.slideshow[2] = new Array(); this.slideshow[3] = 300; this.slideshow[4] = 300; this.slideshow[5] = new Array(1,0,0); } function photo_gallery_initialize() { with (this) { if (Site.loaded == 1) { loaded = 1; root = "http://www.cersf.ca/"; CompileQuery(); } else { window.setTimeout('Photos.Initialize()',10); } } } function photo_gallery_compilequery() { var fields; with (this) { if (loaded == 1) { fields = document.body.getElementsByTagName("INPUT"); for (i = 0; i < fields.length; i++) { if (fields[i].id != "" && fields[i].name != "") { if (fields[i].id.search(/s-/gi) != -1) { queryitems[fields[i].id] = new Array(fields[i].name,fields[i].value); } } } if (queryitems['s-auto']) { auto = queryitems['s-auto'][1]; auto = (auto == "1" || auto == "-1" ? auto : "-1"); } } } } function photo_gallery_addtoquery(item,value,s) { with (this) { if (loaded == 1) { if (item) { if (item.id.search(/s-/gi) != -1) { item.value = value; CompileQuery(); if (s == 1 && auto == "1") { SubmitQuery(); } } } } } } function photo_gallery_submitquery() { var query = "http://www.cersf.ca/photos/?x=1&"; with (this) { if (loaded == 1) { for (i in queryitems) { if (queryitems[i][1] != "") { query += queryitems[i][0]+"="+queryitems[i][1]+"&"; } } query = query.substr(0,query.length-1); location.href = query; } } } function photo_gallery_keypress(e) { var evt = e || window.event; var key = evt.which || evt.keyCode; with (this) { if (key == 13) { SubmitQuery(); } } } function photo_gallery_addfileupload() { var field; var desc; var errors; var entries; var count; var i = 1; var x = 0; var div; var copy = ""; with (this) { field = $('photo_file_1'); desc = $('photo_desc_1'); errors = $('photo_errors_1'); entries = $('photo_entries'); count = $('photo_count'); if (field && desc && entries && errors && count) { while (x == 0) { if ($('photo_file_'+i)) { i++; } else { x = i; } } if (x < 11) { div = document.createElement("div"); div.id = "photo_file_"+x; copy = field.innerHTML.replace(/photo_desc_1/gi,"photo_desc_"+x); copy = copy.replace(/photo_errors_1/gi,"photo_errors_"+x); copy = copy.replace(/File #1/gi,"File #"+x); div.innerHTML = copy; entries.insertBefore(div,null); if ($('photo_errors_'+x)) { $('photo_errors_'+x).style.visibility = "hidden"; $('photo_errors_'+x).style.display = "none"; } count.innerHTML = x; } } } } function photo_gallery_slideshow(p,opt) { var holder; var n = ""; var w = 0; var h = 0; var img; var change = 0; var test = new Array(); test[0] = 0; test[1] = 0; var resize = ""; var percent = 0; var z = ""; with (this) { if (slideshow[0].length == 0 && p) { slideshow[0] = p[0]; // list of file names slideshow[1] = p[1]; // list of widths slideshow[2] = p[2]; // list of heights slideshow[3] = p[3]; // maximum width slideshow[4] = p[4]; // maximum height } holder = $('photos_slideshow_holder'); if (holder) { switch (opt) { case "pause": slideshow[5][2] = 1; break; case "start": if (slideshow[5][2] == 1) { slideshow[5][2] = 0; window.setTimeout('Photos.SlideShow()',10); } break; case "next": if (slideshow[5][0] != 1) { slideshow[5][1] = (slideshow[5][1]+1 > (slideshow[0].length-1) ? 0 : slideshow[5][1]+1); change = 1; } break; case "previous": if (slideshow[5][0] != 1) { slideshow[5][1] = (slideshow[5][1]-1 < 0 ? (slideshow[0].length-1) : slideshow[5][1]-1); change = 1; } break; default: if (slideshow[5][2] != 1) { if (slideshow[5][0] != 1) { slideshow[5][1] = (slideshow[5][1]+1 > (slideshow[0].length-1) ? 0 : slideshow[5][1]+1); change = 1; } slideshow[5][0] = 0; if (change == 0) { window.setTimeout('Photos.SlideShow()',2000); } } break; } if (change == 1) { n = slideshow[0][slideshow[5][1]]; w = slideshow[1][slideshow[5][1]]; h = slideshow[2][slideshow[5][1]]; holder.innerHTML = ""; test[0] = (w > slideshow[3] ? (w-slideshow[3]) : 0); test[1] = (h > slideshow[4] ? (h-slideshow[4]) : 0); if (test[0] == 0 && test[1] == 0) { resize = "-"; } else { resize = ((test[0]/w) == (test[1]/h) ? "w" : ((test[0]/w) > (test[1]/h) ? "w" : "h")); } if (resize != "-") { switch (resize) { case "w": percent = 1-((w - slideshow[3])/w); w = Utility.Round((w*percent),0); h = Utility.Round((h*percent),0); if (h > slideshow[4]) { percent = 1-((h - slideshow[4])/h); w = Utility.Round((w*percent),0); h = Utility.Round((h*percent),0); } break; case "h": percent = 1-((h - slideshow[4])/h); w = Utility.Round((w*percent),0); h = Utility.Round((h*percent),0); if (w > slideshow[3]) { percent = 1-((w - slideshow[3])/w); w = Utility.Round((w*percent),0); h = Utility.Round((h*percent),0); } break; } } if (staff == 1) { z += "Original: "+slideshow[1][slideshow[5][1]]+"x"+slideshow[2][slideshow[5][1]]+"
"; z += "New: "+w+"x"+h; //$('slideshow_test').innerHTML = z; } holder.innerHTML = "\"\""; window.setTimeout('Photos.SlideShow()',6000); } } else { window.setTimeout('Photos.SlideShow()',20); } } } Photo_Gallery.prototype.Initialize = photo_gallery_initialize; Photo_Gallery.prototype.CompileQuery = photo_gallery_compilequery; Photo_Gallery.prototype.AddToQuery = photo_gallery_addtoquery; Photo_Gallery.prototype.SubmitQuery = photo_gallery_submitquery; Photo_Gallery.prototype.KeyPress = photo_gallery_keypress; Photo_Gallery.prototype.AddFileUpload = photo_gallery_addfileupload; Photo_Gallery.prototype.SlideShow = photo_gallery_slideshow; var Photos = new Photo_Gallery(); Photos.Initialize();