function $(e){return document.getElementById(e);}
function _s(e,v){$(e).value=v;}
function _sh(e,v){$(e).innerHTML=v;}
function _v(e){return $(e).value;}
function value(n){ ddl=document.getElementById(n);if(ddl&&ddl.selectedIndex>=0)return ddl.options[ddl.selectedIndex].value;return ''; }
function text(n){ ddl=document.getElementById(n);if(ddl&&ddl.selectedIndex>=0)return ddl.options[ddl.selectedIndex].text;return ''; }

function onFormType()
{
	var formtype = value('form_type_id');
	var form = $('addpostform');
	if(form)
	{
		form.action = '?type='+formtype;
		form.action.value = '';
		form.submit();
	}
	
}
function onFormOrder()
{
	var form = $('userorderform');
	if(form)
	{
		form.submit();
	}
}
function QuoteComment(id)
{
	var comment = $('comment_'+id);
	var body = $('commentdescription_'+id);
	var div = $('reply_'+id);
	if(body)
	{
		quote = comment.innerHTML;
		quote = quote.replace(/<br>/gi,'\n');
		quote = quote.replace(/&nbsp;/gi,' ');
		quote = '<qoute>'+ quote +'</qoute>';
		body.value += quote+'\n';
		div.style.display='';
		body.focus();
	}
}
var opera = Boolean(window["opera"]);
var MSIE = (navigator.appName.indexOf("Microsoft") != -1) && !opera;
var WIN = (navigator.userAgent.toLowerCase().indexOf("win") != -1);
var IEVersion = parseFloat(navigator.appVersion.split("MSIE")[1]);

function setHash(name) 
{
	location.hash = name;
	
}
function getHash()
{
	return location.hash;
}
function getLocation () {

	if ((IEVersion >= 5.5) && (IEVersion < 7)){
	
        //document.title = _title;
        var index = document.title.lastIndexOf("#");
        var hash = (index == -1) ? "" : document.title.substr(index);
        if (hash != current_loc) {
            current_loc = hash;
        }
    } else {
        var hash = document.location.hash;
        if (hash != current_loc) {
            current_loc = hash;
        }
    }
	
    return current_loc;
}
function autoOpenDiv()
{
	var hash  = getHash().replace(/#/,'');
	var div = $(hash);
	if(div)
		div.style.display='';
}
function showHide(id)
{

	$(id).style.display= $(id).style.display =='' ?'none':'';
}
function changeDisplay(id, value)
{

	$(id).style.display=value;
}
function changeClass(id,value)
{
	$(id).className = value;
}

function openTab(key)
{
	if(!tabs)return;
	for(var i=0; i<tabs.length; i++)
	{
		changeClass('tab_'+tabs[i], tabs[i]==key ? 'tabselected':'tab');
		changeDisplay('tabkey_'+tabs[i], tabs[i]==key ? '' :'none');
	}
}
function submitForm(id)
{
	if($(id))
		$(id).submit();

}
function submitOnEnter(e,id)
{
	
	if(!e)return;
	if(e.keyCode == 13) submitForm(id);
}
