function validate_email( field )
{
	with (field)
	{
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if (apos<1||dotpos-apos<2)
		 	{ return false; }
		else
			{ return true; }
	}
}

function validate_required( field )
{
	with (field)
	{
		if (value==null||value=="")
		  { return false; }
		else
		{ return true; }
	}
}

function buildJSONParam( form, button )
{
		var param = "";

		if( button )
		{
			param = '"' + button.name + '":"' + button.value + '"';
		}

		for(i=0; i < form.elements.length; i++)
		{
			if( form.elements[i].type != "button" && form.elements[i].type != "image" && form.elements[i].type != "submit" && form.elements[i].type != "reset")
			{
				if( form.elements[i].type == 'checkbox' )
				{
					if(param != "")
						param = param + ',';
					param = param + '"'+ form.elements[i].name + '":"' + (form.elements[i].checked==true?1:0) + '"';
				}else if( form.elements[i].type == 'radio' )
				{
					if( form.elements[i].checked == true )
					{
						if(param != "")
							param = param + ',';
						param = param + '"'+ form.elements[i].name + '":"' + form.elements[i].value + '"';
					}
				}
				else if( form.elements[i].type == 'textarea')
				{
					if(param != "")
						param = param + ',';
					param = param + '"'+ form.elements[i].name + '":'+YAHOO.lang.JSON.stringify(form.elements[i].value);
				}
				else
				{
					if(param != "")
						param = param + ',';
					param = param + '"'+ form.elements[i].name + '":"' + form.elements[i].value + '"';
				}
			}
		}

		return param;

};

function sendData( action, params, target )
{
	var action2 = '{"actions":[{"action":"' + action + '", "params":{'+ params + '}, "target":"' + target + '"}]}';
	//alert( action2 );
    MenuActionsManager.startActions(action2);
}

function toggleElem(id)
{
	elem = document.getElementById(id);
	if(null != elem)
	{
		if( elem.style.display == '' || elem.style.display == 'block')
		{
			elem.style.display = 'none';
		}else
		{
			elem.style.display = 'block';
		}
	}
}

function hideElem(id)
{
	elem = document.getElementById(id);

	if(null != elem)
	{
		elem.style.display = 'none';
	}
}

function showElem(id)
{
	elem = document.getElementById(id);

	if(null != elem)
	{
		elem.style.display = 'block';
	}
}

/*
 * return IE6, IE7, IE5, IE8, Mozilla
 */
function checkBrowser()
{
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
	 var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
	 if (ieversion>=8)
		 return "IE8";
	 else if (ieversion>=7)
		 return "IE7";
	 else if (ieversion>=6)
		 return "IE6";
	 else if (ieversion>=5)
		 return "IE5";
	}
	else if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Firefox/x.x or Firefox x.x (ignoring remaining digits);
		 var ffversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		 if (ffversion>=3)
			 return "FF3";
		 else if (ffversion>=2)
			 return "FF2";
		 else if (ffversion>=1)
			 return "FF1";
		}
	else if (/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ //test for Opera/x.x or Opera x.x (ignoring remaining decimal places);
		 var oprversion=new Number(RegExp.$1) // capture x.x portion and store as a number
		 if (oprversion>=10)
		  	return "OO10.x";
		 else if (oprversion>=9)
			 return "OO9.x";
		 else if (oprversion>=8)
			 return "OO8.x";
		 else if (oprversion>=7)
			 return "OO7.x";
	}
}

function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}

function toggleElem(id)
{
	elem = document.getElementById(id);
	if(null != elem)
	{
		if( elem.style.display == '' || elem.style.display == 'block')
		{
			elem.style.display = 'none';
		}else
		{
			elem.style.display = 'block';
		}
	}
}

function hideElem(id)
{
	elem = document.getElementById(id);

	if(null != elem)
	{
		elem.style.display = 'none';
	}
}

function showElem(id)
{
	elem = document.getElementById(id);

	if(null != elem)
	{
		elem.style.display = 'block';
	}
}




function getElementbyClass(classname){
ccollect=new Array()
var inc=0
var alltags=document.all? document.all : document.getElementsByTagName("*")
for (i=0; i<alltags.length; i++){
if (alltags[i].className==classname)
ccollect[inc++]=alltags[i]
}
}
function contractcontent(omit){
var inc=0
while (ccollect[inc]){
if (ccollect[inc].id!=omit)
ccollect[inc].style.display="none"
inc++
}
}
function expandcontent(cid){
if (typeof ccollect!="undefined"){
if (collapseprevious=="yes")
contractcontent(cid)
document.getElementById(cid).style.display=(document.getElementById(cid).style.display!="block")? "block" : "none"
}
}
function revivecontent(){
contractcontent("omitnothing")
selectedItem=getselectedItem()
selectedComponents=selectedItem.split("|")
for (i=0; i<selectedComponents.length-1; i++)
document.getElementById(selectedComponents[i]).style.display="block"
}
function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}
function getselectedItem(){
if (get_cookie(window.location.pathname) != ""){
selectedItem=get_cookie(window.location.pathname)
return selectedItem
}
else
return ""
}
function saveswitchstate(){
var inc=0, selectedItem=""
while (ccollect[inc]){
if (ccollect[inc].style.display=="block")
selectedItem+=ccollect[inc].id+"|"
inc++
}
document.cookie=window.location.pathname+"="+selectedItem
}




