/**

Classic Charms Lightbox2 Wrapper v3.1
Last Modified: October 14, 2008

**/

if ({defVal:42}.defVal==42) {

var CCLB3 = { defVal : 42 };

CCLB3.gBaseUrl = "http://site.classic-charms.com/imgs/lightbox2/newsite/";
CCLB3.gDone = false;

CCLB3.includeScript = function(url) {

document.write("<scr"+"ipt language='javascript' type='text/javascript' src='"+url+"'></scr"+"ipt>");

};

CCLB3.includeStylesheet = function(url) {

document.write("<lin"+"k rel='stylesheet' type='text/css' href='"+url+"'/>");

};

CCLB3.ale = function(func) { /** from http://www.dustindiaz.com/top-ten-javascript/ **/
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
};

CCLB3.tostr = function(strobj) {

if (typeof(strobj)=="string") { return strobj; }
if (strobj.toString) { return strobj.toString(); }
return ("" + strobj + "");

};

CCLB3.hasAttr = function(el, at) {

if ((el==null)||(at==null)) { return false; }
if (typeof(el.hasAttribute)!="undefined") { return el.hasAttribute(at); }
if (typeof(el.getAttribute(at))=="undefined") { return false; }
if (el.getAttribute(at)==null) { return false; }
return true;

};

CCLB3.fixTitle = function(el) {

if (el.getElementsByTagName("img").length<=0) { return; }
var elImg = el.getElementsByTagName("img").item(0);
if ((!elImg)||(elImg==null)) { return; }
var elImgAlt = null;
elImgAlt = elImg.getAttribute("alt");
if (elImgAlt==null) { elImgAlt = ""; }
el.setAttribute("title", elImgAlt);

};

CCLB3.removeOnclick = function(el) {

el.setAttribute("onclick", "");
el.onclick = function() {};

};

CCLB3.applyLightbox = function(el) {

this.removeOnclick(el);
this.fixTitle(el);
el.setAttribute("rel", "lightbox[ccItem]");

};

CCLB3.triggerMainLightbox = function() {

if ((window.ccMyLightbox)&&(window.ccMyLightbox.start)) {

window.ccMyLightbox.start(document.getElementById("scMainImage"));

} else {

window.alert("To enlarge, please click the image itself.");

}

};

CCLB3.lightboxAble = function(el) {

if ((!el)||(el==null)) { return false; }
if (this.hasAttr(el, "onclick")==false) { return false; }
if (this.tostr(el.getAttribute("onclick")).toLowerCase().indexOf("scshowimg")==(-1)) { return false; }
if (this.tostr(el.onclick).toLowerCase().indexOf("scshowimg")==(-1)) { return false; }
if (this.tostr(el.getAttribute("href")).length<5) { return false; }

return true;

};

CCLB3.doInit = function() {

if (this.gDone==true) { return; }

if (document.getElementById("scMainImage")==null) { return; }

this.applyLightbox(document.getElementById("scMainImage"));

var cteButton = document.getElementById("main-item-image-wrapper").parentNode.childNodes.item(2);
cteButton.setAttribute("name", "cteButton");
cteButton.setAttribute("href", null);
if (cteButton.removeAttribute) { cteButton.removeAttribute("href"); }
this.removeOnclick(cteButton);
cteButton.onclick = function() { window.CCLB3.triggerMainLightbox(); };
cteButton.style.cursor = "pointer";

if (document.getElementById("scPage-insets")!=null) {
var it = 1;
for (it = 1; it < document.getElementById("scPage-insets").getElementsByTagName("a").length; it++) {
if (this.lightboxAble(document.getElementById("scPage-insets").getElementsByTagName("a").item(it))==false) { continue; }

this.applyLightbox(document.getElementById("scPage-insets").getElementsByTagName("a").item(it));

}
}

this.gDone = true;

};

CCLB3.doInit2 = function() {

if (this.gDone==true) { return; }
if (!document.getElementById) { return; }
if (!document.getElementsByTagName) { return; }
if (!document.createElement) { return; }
if (!document.body.getAttribute) { return; }

this.includeStylesheet(this.gBaseUrl + "css/lightbox.css")
this.includeScript(this.gBaseUrl + "js/prototype.js");
this.includeScript(this.gBaseUrl + "js/scriptaculous.js?load=effects,builder");
this.includeScript(this.gBaseUrl + "js/lightbox.js");

if (window.navigator.userAgent.toLowerCase().indexOf("msie")>=0) {
this.includeStylesheet(this.gBaseUrl + "css/lightbox_ie.css");
}

this.ale(function() { window.CCLB3.doInit(); });

};

if (window.CCLB3==CCLB3) {} else { window.CCLB3 = CCLB3; }
window.CCLB3.doInit2();

}