var modOpacity = function (elem, value, increment, count) {
var sinValue = (Math.sin(value * (Math.PI/180))) / 2 + .5;
if (document.all)
	elem.style.filter="alpha(opacity=" + ((1-sinValue)*100) + ")";
else 
	elem.style.opacity = (1-sinValue);
if (count < 120)
	EventHandlers.setTimerFunction ([modOpacity, [elem, value+increment, increment, count+1]], (sinValue>.98)?400:((sinValue<.02)?200:10));
else
	elem.parentNode.removeChild(elem);
};

var showCoolness = function () {
var a = document.getElementById("photolink");
var pos = GeneralUtils.getPos(a);
var p = document.getElementById("cool");
GeneralUtils.moveElem (p, pos.x+a.offsetWidth, pos.y-78);
modOpacity (p, 90, 3, 0);
p.style.display = "";
};

var popupPhotoStyleInfo = {
	startPhrase: "ccg-",
	borderColor: "#333"
	};

var ccg_imageList = [
	{
	path: "/colorize/new/",
	ext: "jpg",
	bigExt: "png",
	styleInfo: popupPhotoStyleInfo,
	list: [
		["vespa", "A beautiful restored Vespa VBA<br><span style='font-size: .8em'>(from <a href=\"http://scooterhelp.com\" target=\"new\">scooterhelp.com</a>)", "#20f", "scooter"],
		["corvette", "50's Corvette<br><span style='font-size: .8em'>(photo origin unknown)</span>", "#f00", "car"],
		["sweater", "A girl in a knit top, <br><span style='font-size: .8em'>(from <a href=\"http://victoriassecret.com\" target=\"new\">victoriassecret.com</a>)</span>", "#d03", "top"],
		["smurf", "Smurfette!<br><span style='font-size: .8em'>(from <a href=\"http://victoriassecret.com\" target=\"new\">victoriassecret.com</a>)", "#44f", "skin"],
		["bird", "A bird from wikipedia", "#ff0", "bird"],
		["vette", "Another corvette", "#f00", "car"],
		["smartcar", "OMG this car's hella cute LOL!!1!", "#800", "toy"],
		["mixer", "A mixer", "#50f", "mixer"],
		["lips", "Lips", "#f06", "lipstick"]
		
		]
	}
	];
	
var ccgImageSizes = [
[
[324, 432, 53, 60],
[600, 371, 63, 60],
[424, 571, 60, 60],
[424, 572, 55, 60],
[410, 410, 60, 60],
[800, 600, 80, 60],
[399, 330, 72, 60],
[261, 315, 49, 60],
[373, 199, 53, 60]
]
];


//--------------------------------------------------
function copyInSizes (list, sizes) {
for (var j=0; j<list.length; j++) {
	var block = list[j];
	var sizesBlock = sizes[j];
	for (var i=0; i<block.list.length; i++) {
		var imageData = block.list[i];
		var sizeData = sizesBlock[i];
		imageData.wL = sizeData[0];
		imageData.hL = sizeData[1];
		imageData.wS = sizeData[2];
		imageData.hS = sizeData[3];
		if (sizeData[4]) {
			imageData.wM = sizeData[4];
			imageData.hM = sizeData[5];
			}
		}
	}
}

//----------------------------------------------------------
var showGallery = function () {
var blocks = ccg_imageList;
var el = GeneralUtils.createElementOld;
copyInSizes (blocks, ccgImageSizes);

var button = document.getElementById ("photolink");
var popup = new Popup(button, 4, "", "kcp-translucentBG");
var w = 10;
for (var blockNo=0; blockNo<blocks.length; blockNo++) {
	var block = blocks[blockNo];
	for (var i=0; i<block.list.length; i++) {
		var imageData = block.list[i];
		img = el("img", {style:{cssFloat: "left", styleFloat: "left", display: "inline", padding: "2px", margin: "4px", backgroundColor: "#fff", cursor: "pointer" }, src: block.path + imageData[0] + "-small.jpg"});
		w += imageData.wS + 11.3;
		block.list[i].thumbnailElem = img;
		EventHandlers.setEventHandler(img, "onclick",  [popuppic_loadImage, [block, i]]);
		popup.element.appendChild (img);
		}
	}
popup.element.style.width = w + "px";
popup.element.style.height = "90px";
var b;
popup.element.appendChild (el ("br", {style: {clear: "both"}}));
popup.element.appendChild (el ("div", {style: {fontWeight: "bold", color: "#fea", fontSize: "12px", marginLeft: "90px", cssFloat: "left", styleFloat: "left"}}, "read about this technique ",  el ("a", {href: "http://karmatics.com/node/21", target:"_new", style: {color: "#fd6"}}, "here")));
var b = el("input", {style: {cssFloat: "right", styleFloat: "right", position: "relative", top: "4px", marginRight: "160px"}, type: "button", value: "close"});
//var d = el ("center", null, b = el("input", {type: "button", value: "close"}));
popup.element.appendChild (b);
popup.element.appendChild (el ("br", {style: {clear: "both"}}));
EventHandlers.setEventHandler(b, "onclick",  [popup.kill, [], popup]);
	
popup.show();
popup.noKillByClick = true;
popuppic_setClickHandler ();

//checkSizes (sfsc_data.shopImageData);
};
