/* preload SWF for IE7 */
function load_swf($ID, $filename, $width, $height){
	document.getElementById($ID).innerHTML = '<object type="application/x-shockwave-flash" data="' + $filename + '" width="' + $width + '" height="' + $height + '"><param name="menu" value="false" /><param name="movie"	value="' + $filename + '" /><param name="wmode" value="transparent" /></object>';
}
function show_object($object) {
	$object.style.visibility = "visible";
}
function hide_object($object) {
	$object.style.display = "none";
}

function equalize_thumbs() {
	var thumb_max_height=0;
	var div=document.getElementsByTagName('div');
	for(var z=0; z<div.length; z++) {
		if(div[z].className=='thumbnail_list equalize_thumbs') {
			var thumb=div[z].getElementsByTagName('a');
			var thumb_width = thumb[0].offsetWidth + 20;
			var thumb_inline = Math.floor((div[z].offsetWidth + 20)/thumb_width);
			var thumb_rows = Math.ceil(thumb.length/thumb_inline);
			for (i=0; i<thumb_rows; i++) {
				for (n=0; n<thumb_inline; n++) {
					var id = (i*thumb_inline)+n;
					var e = thumb[id];
					if (e) {
						if (thumb_max_height <= e.offsetHeight ) { 
							thumb_max_height = e.offsetHeight;
						}
					}
				}
				for (n=0; n<thumb_inline; n++) {
					var id = (i*thumb_inline)+n;
					var e = thumb[id];
					if (e) {
						e.style.height = thumb_max_height+"px";
					}
				}
				thumb_max_height = 0;
			}
		}
	}
}
function equalize_products() {
	var title_max_height=0;
	var thumb_max_height=0;
	var box_max_height=0;
	var div=document.getElementsByTagName('div');
	for(var z=0; z < div.length; z++) {
		if(div[z].className=='products_list equalize_thumbs') {
			var thumb=div[z].getElementsByTagName('div');
			var thumb_width = thumb[0].offsetWidth + 20;
			var thumb_inline = Math.floor((div[z].offsetWidth+40)/thumb_width);
			var thumb_rows = Math.ceil(thumb.length/thumb_inline);
			
			for (i=0; i < thumb_rows; i++) {
				for (n=0; n < thumb_inline; n++) {
					var id = (i*thumb_inline)+n;
					var e = thumb[id];
					if (e) {	
						var children = e.childNodes;
						for(x=0; x < children.length; x++){
							a = children[x];
							if(a.className == 'title'){				
								if(title_max_height <= a.offsetHeight ) { 
									title_max_height = a.offsetHeight;
								}							
							}
							if(a.className == 'thumb'){				
								if(thumb_max_height <= a.offsetHeight ) { 
									thumb_max_height = a.offsetHeight;
								}							
							}							
							if(a.className == 'bottom'){																	
								if (box_max_height <= a.offsetHeight ) { 
									box_max_height = a.offsetHeight;
								}							
							}								
						}						
					}
				}
				for (n=0; n<thumb_inline; n++) {
					var id = (i*thumb_inline)+n;
					var e = thumb[id];
					if (e) {
						var children = e.childNodes;
						for(x=0; x < children.length; x++){
							a = children[x];
							if(a.className == 'title'){
								a.style.height = title_max_height+"px";
							}
							if(a.className == 'thumb'){								
								a.style.height = thumb_max_height+"px";
								//pic = a.getElementsByTagName('img');
								//pic[0].style.marginTop = (100-pic[0].offsetHeight)/2+"px";
								//pic[0].style.marginBottom = (100-pic[0].offsetHeight)/2+"px";
							}
							if(a.className == 'bottom' && a && box_max_height > 20){								
								a.style.height = (box_max_height) + "px";														
							}	
						}											
					}
				}
				title_max_height=0;
				thumb_max_height=0;
				box_max_height=0;
			}
		}
	}
}

function getElementsByClassName(classname, node) { if (!node) { node = document.getElementsByTagName('body')[0]; } var a = [], re = new RegExp('\\b' + classname + '\\b'); els = node.getElementsByTagName('*'); for (var i = 0, j = els.length; i < j; i++) { if ( re.test(els[i].className) ) { a.push(els[i]); } } return a; }



function writeFlash(filename, width, height){
	var background		=(arguments[3])?arguments[3]:'#FFFFFF';
	document.writeln('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="'+width+'" height="'+height+'"  align="middle"><param name="allowScriptAccess" value="sameDomain" /><param name="movie" value="'+filename+'" /><param name="quality" value="high" /><param name="bgcolor" value="'+background+'" /><embed src="'+filename+'" quality="high" bgcolor="'+background+'" width="'+width+'" height="'+height+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>');
}

function refresh_kcaptcha(url,obj) {
	if(url.href){
		document.getElementById(obj).src=url.href+ '&' + Math.random();
	}
	return false;
}

function hide_extra_name() {
	document.getElementById('extra_name').style.display = 'none';
}



