function removeSpace(field)
{
	field.value = (field.value).replace(/^\s*|\s*$/g,'');
}

function isValidEmail(str) 
{
   return (str.indexOf(".") > 1) && (str.indexOf("@") > 0);
}

function trim(val)
{
	re=/\s+$|^\s+/g;
	with (val)
	{
		val=val.replace(re,"");
	}
	return val;
}

function ltrim(val)
{
	re=/^\s+/g;
	with (val)
	{
		val=val.replace(re,"");
	}
	return val;
}

function rtrim(val)
{
	re=/\s+$/g;
	with (val)
	{
		val=val.replace(re,"");
	}
	return val;
}

function Show_Img(img, w, h) 
{
	if(w<400){w=400;}

	if(img=="")
	{
		return; // set the options as you like
	}
	winleft = (screen.width - w - 22)/2; 
	wintop = (screen.height - h)/2 - 50; 
	if(typeof(SmallWin)!="undefined")
	{
		SmallWin.close();
	}
	SmallWin = window.open('./viewimg.php?img='+img, 'ImgWindow','scrollbars,resizable=no,height=' +(h+24)+ ',width=' +(w+24)+',top=' +wintop+ ',left=' +winleft+ ', margin=0');
	SmallWin.focus() 
	SmallWin.width=w;
	SmallWin.height=h;
}

function SWFDelegate(url,caption,gallery) {
   var objLink = document.createElement('a');
   objLink.setAttribute('href',url);
   
   if(gallery==1)
   {
   	objLink.setAttribute('rel','lightbox[gallery]');
   } else 
   {
   	objLink.setAttribute('rel','lightbox[images]');
   }
   
   objLink.setAttribute('title',unescape(unescape(caption)));
   Lightbox.prototype.start(objLink);
}

function setcenterframe()
{
	var arrayPageSize = getPageSize();
	//Element.setWidth('bg_hideTP', arrayPageSize[0]);
	//Element.setHeight('bg_hideTP', arrayPageSize[1]);
	
	if(arrayPageSize[1]>del_height+min_height)
	{
		var newheight=arrayPageSize[1]-del_height;
		document.getElementById('centerframe').height=newheight;
	} else
	{
		document.getElementById('centerframe').height=min_height;
	}
}

function get_radio_value(radiusname)
{
	var rad_val=0;
	var rname=eval(radiusname);

	for (var i=0; i < rname.length; i++)
	{
		if (rname[i].checked)
		{
			rad_val = rname[i].value;
		}
	}
	return rad_val;
}