function openUploader(type,params)
{
	var qs = new Hash();

	qs.set("t",type);

	if(params!=null)
	{
		params = $H(params);
		var keys = params.keys();
		for(i=0;i<keys.size();i++)
		{
			qs.set( keys[i], params.get(keys[i]) );
		}
	}


	u=window.open("/upload/index.php?"+qs.toQueryString(), "uploader","toolbar=0,menubar=0,resizable=1,location=0,status=0,scrollbars=1,width=800,height=400");
	u.opener=self;
}

var ua={
	ie:function(){return this._ie;},
	firefox:function(){return this._firefox;},
	opera:function(){return this._opera;},
	safari:function(){return this._safari;},
	windows:function(){return this._windows;},
	osx:function(){return this._osx;},
	populate:function() {
		var agent=/(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Iceweasel).(\d+\.\d+))|(?:Opera.(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))/.exec(navigator.userAgent);
		var os=/(Mac OS X;)|(Windows;)/.exec(navigator.userAgent);
		if(agent) {
			ua._ie=agent[1]?parseFloat(agent[1]):NaN;
			ua._firefox=agent[2]?parseFloat(agent[2]):NaN;
			ua._opera=agent[3]?parseFloat(agent[3]):NaN;
			ua._safari=agent[4]?parseFloat(agent[4]):NaN;
		}
		else {
			ua._ie=ua._firefox=ua._opera=ua._safari=NaN;
		}
		if(os) {
			ua._osx=!!os[1];
			ua._windows=!!os[2];
		}
		else {
			ua._osx=ua._windows=false;
		}
	},
	adjustBehaviors:function()
	{
		onloadRegister(addSafariLabelSupport);
		if(ua.ie()<7) {
			try {
				document.execCommand('BackgroundImageCache',false,true);
			}
			catch(ignored){}
		}
	}
};


function show() {
	for(var i=0;i<arguments.length;i++)
	{
		var element=ge(arguments[i]);
		if(element&&element.style)
			element.style.display='';
	}
	return false;
}

function hide() {
	for(var i=0;i<arguments.length;i++) {
		var element=ge(arguments[i]);
		if(element&&element.style)
			element.style.display='none';
	}
	return false;
}

function shown(el) {
	el=ge(el);
	return(el.style.display!='none');
}

function toggle() {
	for(var i=0;i<arguments.length;i++)
	{
		var element=ge(arguments[i]);
		element.style.display=(element.style.display=='block')?'none':'block';
	}
	return false;
}

function linkbuster()
{
	return false;
}

function noenter()
{
	return !(window.event && window.event.keyCode == 13); 
}

function remove_node(node)
{
	if(node.removeNode)
		node.removeNode(true);
	else
	{
		for(var i=node.childNodes.length-1;i>=0;i--)
			remove_node(node.childNodes[i]);
		node.parentNode.removeChild(node);
	}
	return null;
}

function findX(obj)
{
	var curleft=0;
	if(obj.offsetParent)
	{
		while(obj.offsetParent)
		{
			curleft+=obj.offsetLeft;
			obj=obj.offsetParent;
		}
	}
	else if(obj.x)
		curleft+=obj.x;
	return curleft;
}

function findY(obj)
{
	var curtop=0;
	if(obj.offsetParent)
	{
		while(obj.offsetParent)
		{
			curtop+=obj.offsetTop;
			obj=obj.offsetParent;
		}
	}
	else if(obj.y)
		curtop+=obj.y;
	return curtop;
}

function mousePosX(e)
{
	var posx=0;
	if(!e)
		var e=window.event;
	if(e.pageX)
		posx=e.pageX;
	else if(e.clientX&&document.body.scrollLeft)
		posx=e.clientX+document.body.scrollLeft;
	else if(e.clientX&&document.documentElement.scrollLeft)
		posx=e.clientX+document.documentElement.scrollLeft;
	else if(e.clientX)
		posx=e.clientX;
	return posx;
}

function mousePosY(e)
{
	var posy=0;
	if(!e)
		var e=window.event;
	if(e.pageY)
		posy=e.pageY;
	else if(e.clientY&&document.body.scrollTop)
		posy=e.clientY+document.body.scrollTop;
	else if(e.clientY&&document.documentElement.scrollTop)
		posy=e.clientY+document.documentElement.scrollTop;
	else if(e.clientY)
		posy=e.clientY;
	return posy;
}

function elementX(obj)
{
	var curleft=0;
	if(obj.offsetParent)
	{
		while(obj.offsetParent)
		{
			curleft+=obj.offsetLeft;
			obj=obj.offsetParent;
		}
	}
	else if(obj.x)
		curleft+=obj.x;
	return curleft;
}

function elementY(obj)
{
	var curtop=0;
	if(obj.offsetParent)
	{
		while(obj.offsetParent)
		{
			curtop+=obj.offsetTop;
			obj=obj.offsetParent;
		}
	}
	else if(obj.y)
		curtop+=obj.y;
		return curtop;
}

function onloadRegister(handler)
{
	if(window.onload)
	{
		var old=window.onload;
		window.onload=function()
			{
				old();
				handler();
			};
	}
	else
	{
		window.onload=handler;
	}
}

function placeholderSetup(id)
{
	var el=$(id);
	if(!el)
		return;
	var ph=el.getAttribute("placeholder");
	if(ph&&ph!="")
	{
		el.value=ph;
		el.style.color='#777';
		el.is_focused=0;
		el.onfocus=placeholderFocus;
		el.onblur=placeholderBlur;
	}
}

function placeholderFocus()
{
	if(!this.is_focused)
	{
		this.is_focused=1;
		this.value='';
		this.style.color='#000';
		var rs=this.getAttribute("radioselect");
		if(rs&&rs!="")
		{
			var re=document.getElementById(rs);
			if(!re)
			{
				return;
			}
			if(re.type!='radio')
				return;
			re.checked=true;
		}
	}
}

function placeholderBlur()
{
	var ph=this.getAttribute("placeholder");
	if(this.is_focused&&ph&&this.value=="")
	{
		this.is_focused=0;
		this.value=ph;
		this.style.color='#777';
	}
}

function htmlspecialchars(text)
{
	return text?text.toString().replace(/&/g,'&amp;').replace(/"/g,'&quot;').replace(/'/g,'&#039;').replace(/</g,'&lt;').replace(/>/g,'&gt;'):'';
}
/*"*/

function escape_js_quotes(text)
{
	if(!text) {
		return;
	}
	return text.replace(/\\/g,'\\\\').replace(/\n/g,'\\n').replace(/\r/g,'\\r').replace(/"/g,'\\x22').replace(/'/g,'\\\'').replace(/</g,'\\x3c').replace(/>/g,'\\x3e').replace(/&/g,'\\x26');
}

function trim(str)
{
	var delim=arguments.length>1 ? arguments[1] : ' ';
	for(var i=0,c=str.length-delim.length;i<=c;i+=delim.length)
	{
		if(str.substring(i,i+delim.length)!=delim)
		{
			break;
		}
	}
	for(var j=str.length,c=Math.max(i,delim.length-1);j>c;j-=delim.length)
	{
		if(str.substring(j-delim.length,j)!=delim)
		{
			break;
		}
	}
	return str.substring(i,j);
}

function escapeURI(u)
{
	if(encodeURIComponent)
	{
		return encodeURIComponent(u);
	}
	if(escape)
	{
		return escape(u);
	}
}

function goURI(href)
{
	window.location.href=href;
}

function is_email(email)
{
	return/^[\w!.%+]+@[\w]+(?:\.[\w]+)+$/.test(email);
}

function getViewportWidth()
{
	var width=0;
	if(document.documentElement&&document.documentElement.clientWidth)
	{
		width=document.documentElement.clientWidth;
	}
	else if(document.body&&document.body.clientWidth)
	{
		width=document.body.clientWidth;
	}
	else if(window.innerWidth)
	{
		width=window.innerWidth-18;
	}
	return width;
};

function getViewportHeight()
{
	var height=0;
	if(document.documentElement&&document.documentElement.clientHeight)
	{
		height=document.documentElement.clientHeight;
	}
	else if(document.body&&document.body.clientHeight)
	{
		height=document.body.clientHeight;
	}
	else if(window.innerHeight)
	{
		height=window.innerHeight-18;
	}
	return height;
};

function getRadioFormValue(obj)
{
	for(i=0;i<obj.length;i++)
	{
		if(obj[i].checked)
		{
			return obj[i].value;
		}
	}
	return null;
}
function checkAgree()
{
	if(document.frm.pic.value)
	{
		if(document.frm.agree.checked)
		{
			document.frm.submit();
		}
		else
		{
			show("error");
		}
	}
}

function isIE()
{
	return(navigator.userAgent.toLowerCase().indexOf("msie")!=-1);
}

function getTableRowShownDisplayProperty()
{
	if(isIE())
	{
		return'inline';
	}
	else
	{
		return'table-row';
	}
}


function showTableRow()
{
	for(var i=0;i<arguments.length;i++)
	{
		var element=$(arguments[i]);
		if(element&&element.style)
			element.style.display=getTableRowShownDisplayProperty();
	}
	return false;
}

function getParentRow(el)
{
	el=$(el);
	while(el.tagName&&el.tagName!="TR")
	{
		el=el.parentNode;
	}
	return el;
}

function stopPropagation(e)
{
	if(!e)
		var e=window.event;
	e.cancelBubble=true;
	if(e.stopPropagation)
	{
		e.stopPropagation();
	}
}

function show_standard_status(status)
{
	s=$('standard_status');
	if(s)
	{
		var header=s.firstChild;
		header.innerHTML=status;
		show('standard_status');
	}
}

function hide_standard_status()
{
	s=$('standard_status');
	if(s)
	{
		hide('standard_status');
	}
}

function remove_node(node)
{
	if(node.removeNode)
		node.removeNode(true);
	else
	{
		for(var i=node.childNodes.length-1;i>=0;i--)
			remove_node(node.childNodes[i]);
		node.parentNode.removeChild(node);
	}
	return null;
}

function adjustImage(obj,stop_word,max)
{
	var pn=obj.parentNode;
	if(stop_word==null)
		stop_word='note_content';
	if(max==null)
	{
		while(pn.className.indexOf(stop_word)==-1)
			pn=pn.parentNode;
		if(pn.offsetWidth)
			max=pn.offsetWidth;
		else
			max=400;
	}
	obj.className=obj.className.replace('img_loading','img_ready');
	if(obj.width>max)
	{
		if(window.ActiveXObject)
		{
			try
			{
				var img_div=document.createElement('div');
				img_div.style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src="'
									+obj.src.replace('"','%22')+'", sizingMethod="scale")';
				img_div.style.width=max+'px';
				img_div.style.height=((max/obj.width)*obj.height)+'px';
				if(obj.parentNode.tagName=='A')
					img_div.style.cursor='pointer';
				obj.parentNode.insertBefore(img_div,obj);
				obj.removeNode(true);
			}
			catch(e)
			{
				obj.style.width=max+'px';
			}
		}
		else
			obj.style.width=max+'px';
	}
}
function getmousexy(event,image)
{
	pos_x = mousePosX(event)-findX(image);
	pos_y = mousePosY(event)-findY(image);

	temp = Array();
	temp[0] = pos_x;
	temp[1] = pos_y;
	return temp;
}


function set_opacity(obj,opacity)
{
	try
	{
		obj.style.opacity=(opacity==1 ? '' : opacity);
		obj.style.filter=(opacity==1 ? '' : 'alpha(opacity='+opacity*100+')');
	}
	catch(e)
	{
	
	}
	obj.setAttribute('opacity',opacity);
}

function get_opacity(obj)
{
	return obj.opacity ? obj.opacity : 1;
}

function focus_login()
{
	var email=$("email");
	var pass=$("pass");
	var dologin=$("doquicklogin");
	if(email&&pass)
	{
		if(email.value!=""&&pass.value=="")
		{
			pass.focus();
		}
		else if(email.value=="")
		{
			email.focus();
		}
		else if(email.value!=""&&pass.value!="")
		{
			dologin.focus();
		}
	}
}

function array_indexOf(arr,val,index)
{
	if(!index)
	{
		index=0;
	}
	for(var i=index;i<arr.length;i++)
	{
		if(arr[i]==val)
		{
			return i;
		}
	}
	return-1;
}

function showLoadingOverlay()
{
	var loadOverlayHTML = '<p><div style="text-align:center;padding:10px;">';
	loadOverlayHTML += '<img src="http://static.picmember.com/images/whiteloader.gif" width="48" height="48" border="0" alt="Loading...">';
	loadOverlayHTML += '<br>';
	loadOverlayHTML += 'Loading...';
	loadOverlayHTML += '<br>';
	loadOverlayHTML += '</div></p>';
	new Effect.Opacity('pagecontainer',{duration:0.5, from: 1.0, to: 0.3});
	return (new pop_dialog()).show_prompt('Loading...',loadOverlayHTML);
}
function showloader()
{
	showLoadingOverlay();
}


var _motbrOC = ''; /*Original Color*/
var _motbrNC = '#d1c7bf'; /*New Color*/

function _mouseOverTblRow(row)
{
	var cells = $(row).descendants();
	_motbrOC = cells[0].style.backgroundColor;
	for(i=0;i<cells.length;i++)
	{
		if(cells[i].localName=="TD")
		{
			cells[i].style.backgroundColor = _motbrNC;
		}
	}
}
function _mouseOutTblRow(row)
{
	var cells = $(row).descendants();
	for(i=0;i<cells.length;i++)
	{
		if(cells[i].localName=="TD")
		{
			cells[i].style.backgroundColor = _motbrOC;
		}
	}
}



