// © SMF-Media.com
// script.js
// Handler for uploading files using Yahoo UI Uploader
//
// Users of this software are bound by the terms of the
// SMG license. You can view it in the license_smg.txt file,
// or online at http://smf-media.com/smg/license.php
//  
// Support and updates for this software can be found at          
// http://smf-media.com

if (typeof(is_chrome) == 'undefined')
{
	var ua = navigator.userAgent.toLowerCase();
	var is_chrome = ua.indexOf('chrome') != -1;
	var is_safari = ua.indexOf('applewebkit') != -1 && !is_chrome;
}
function fixPictureSize(id)
{
	var pics = document.getElementById(id);
	if (pics == null || pics == 'undefined')
		return false;

	var clu = pics.getElementsByTagName('ul');
	for (var i = 0; i < clu.length; i++)
		if (clu[i].className.indexOf('pics') > -1)
			pics = clu[i];

	var lis = pics.getElementsByTagName('li');
	var max_width = 0, max_height = 0;
	for (i = 0; i < lis.length; i++)
	{
		if (lis[i].clientHeight > max_height + 12)
			max_height = lis[i].clientHeight - 12;
		if (lis[i].clientWidth > max_width + 12)
			max_width = lis[i].clientWidth - 12;
	}
	for (i = 0; i < lis.length; i++)
	{
		lis[i].style.height = max_height + 'px';
		lis[i].style.width = max_width + 'px';
	}
}
function selectText(box)
{
	box.focus();
	box.select();
}
function ajaxRating()
{
	var value = document.getElementById('rating').value;
	var url = document.getElementById('ratingForm').action + ';xml';
	document.getElementById('ratingElement').innerHTML = '<img src="' + smf_default_theme_url + '/images/mgallery/loading.gif" border="0" alt="Loading" />';
	sendXMLDocument(url, 'rating=' + value, ajaxRating2);
}
function ajaxRating2(XMLDoc)
{
	var newElement = XMLDoc.getElementsByTagName('ratingObject')[0].firstChild.nodeValue;
	document.getElementById('ratingElement').innerHTML = newElement;
}
