function bookmark(a)
{
    if (window.sidebar)
	{
        window.sidebar.addPanel(title,homepage, '');
		return true;
	}
    else if(window.opera && window.print)
    {
		a.href = homepage;
		a.rel = "sidebar";
		a.title = title;
		return true;
    }
    else if(document.all)
	{
        window.external.AddFavorite(homepage,title);
		return true;
	}
	
	var chr = 'CTRL-D';
	var agt=navigator.userAgent.toLowerCase();
	if(agt.substr(agt.indexOf('opera')+6,1) < 9) chr = 'CTRL-T';
	alert("Press '+chr+' to bookmark us!");
}

function get(id)
{
	return document.getElementById(id);
}

function toggle(theDiv)
{
    var elem = get(theDiv);
	
	if(elem.style.display == "none")
	{
		elem.style.display='';
		return true;
	}
	else
	{
		elem.style.display='none';
		return false;
	}
}
function submit_form()
{
	if(get('upload'))
	{
		if(!get('upload').value)
		{
			return false;
		}
	}
	if(get("l_adult_no"))
	{
		if(get("l_adult_no").checked || get("l_adult_yes").checked)
		{
			get('progress').style.display='';
			return true;
		}
		else
		{
			alert(text_alert);
			return false;
		}
	}
	return true;
}
function resize(src,id)
{
    var o = get("id_"+id);
    if (!o)
	{
        return;
	}
    var tmp = new Image;
    tmp.src = src.src;
    var scaled = get_scaled_size(tmp.width, tmp.height, 75, 75, true);
	var fix_x=Math.floor((75 - scaled[0]) / 2);
	var fix_y=Math.floor((75 + 15 - scaled[1]) / 2);
    var html = '<a href="'+get("hi_"+id).href+'" target="_blank"><img style="margin: '+fix_y+'px 0 0 '+fix_x+'px; position: absolute; clip: rect('+(0-fix_y)+'px,'+(75-fix_x)+'px,'+(75-fix_y)+'px,'+(0-fix_x)+'px)" src="' + src.src + '" width="' + scaled[0] + '" height="' + scaled[1] + '" title="' + src.title + '" /></a>';
    o.innerHTML  = html;
}

var PRELOAD = new Array();

function resize2(id)
{
	var src=get("id_"+id);
	
	if (!src)
	{
        return;
	}
	
	if(PRELOAD[id])
	{
		var tmp = PRELOAD[id];
	}
	else
	{
		var tmp = new Image;
		tmp.src = src.src;
		
		PRELOAD[id] = tmp;
	}
	
	while(!tmp.width)
	{
		setTimeout('resize2('+id+')',250);
		return false;
	}
	
    var scaled = get_scaled_size(tmp.width, tmp.height, 100, 100, true);
	var fix_x=Math.floor((100 - scaled[0]) / 2);
	var fix_y=Math.floor((100 + 15 - scaled[1]) / 2);
	
	var o=get("loading_"+id);
	if(o)
	{
		o.style.display='none';
	}
	
	src.width = scaled[0];
    src.height = scaled[1];
	src.style.margin = fix_y+'px 0px 0px '+fix_x+'px';
	src.style.clip = 'rect('+(1-fix_y)+'px,'+(100-fix_x)+'px,'+(100-fix_y)+'px,'+(1-fix_x)+'px)';
}
function uerror2(id)
{
}
function uerror(src,id)
{
    var o = get("id_"+id);
    if (!o)
	{
        return;
	}
    var html = '<img src="http://www.imageshack.us/common/images/thumbnail.gif" width="67" height="75" alt="' + src.alt + '" title="' + src.title + '"/>';
    o.innerHTML  = html;
}
function get_scaled_size(width, height, max_width, max_height, crop)
{
    if (width <= max_width && height <= max_height && !crop)
	{
        return [width, height];
	}
	
	if (crop)
    {
        max_width  += 15;
        max_height += 15;
    }

    height *= 1.0;
    width  *= 1.0;
    k = crop ? Math.max(max_width/width, max_height/height) : Math.min(max_width/width, max_height/height);;
    w = Math.floor(width * k);
    h = Math.floor(height * k);
    if (w == 0)
	{
        w = 1;
	}
    if (h == 0)
	{
        h = 1;
	}
    return [w, h];
}
function thumb_name(name)
{
    var pos = name.lastIndexOf('.');
    if (pos == -1)
        return '';
    return name.substr(0, pos) + '.th' + name.substr(pos);
}
function CopyField(field)
{
	if(document.all)
	{
		var temp = field.createTextRange();
		temp.execCommand("Copy");
		//alert('Code copied to clipboard. Use Ctrl-V to paste code to other hmtl page.');
	}
	else
	{
		alert('Right-click on text field and select "Copy" in popup menu to copy code.');
	}
}