function shownewsticker()
{
	nt=document.getElementById("newsticker");
	list=nt.getElementsByTagName("li");
	if (list)
	{
		setelement=list[0];
		nextactive=false;
		for (var i=0;i<list.length;i++)
		{
			if (nextactive)
			{
				setelement=list[i];
				nextactive=false;
			}
			else
			if (list[i].className=="active")
			{
				list[i].className="";
				nextactive=true;				
			}
		}
		setelement.className="active";
	}
	window.setTimeout("shownewsticker()",3000);
	
}

function resizetobrowser()
{
	chheight=document.body.offsetHeight;
	//alert(chheight+":");

}

var navmenus=[];


function attachtreeclick(id)
{
	var navigation=document.getElementById(id);
	$("#"+id+" li.nourl > a").click(
		function() {$(this).parent().toggleClass("menuselect");return false;}
	)
	
	
}

function attachmenu(id)
{
	if (id)
	{
	navigation=document.getElementById(id);
	items=navigation.getElementsByTagName("li");
	for(var i=0;i<items.length;i++)
	{
		if(items[i].parentNode==navigation)
		{
			items[i].onmouseover=
				function ()
				{
					try
					{
					this.className='hover';document.getElementById('container').className='hideinput';
					}
					catch(err)
					{
					}
				}
			items[i].onmouseout=
				function ()
				{
					try
					{
					this.className='';document.getElementById('container').className='';
					}
					catch(err)
					{
					}
				}
		}
	}
        }
	else
	for(var i=0;i<navmenus.length;i++)
	{
		switch(navmenus[navmenus[i]])
		{
			case "treeclick":
				attachtreeclick(navmenus[i]);
				break;

			default:
				attachmenu(navmenus[i]);
				break;
		}
	}
}



function echeck(str){	
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1) return false
	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) return false;
	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) return false;
	if (str.indexOf(at,(lat+1))!=-1) return false;
	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) return false
	if (str.indexOf(dot,(lat+2))==-1) return false;
	if (str.indexOf(" ")!=-1) return false;
	return true					
}

mailform = {
hidden : true,
load : function(parent,after) {
	if(mailform.hidden)
	{
		var html = "<div name=\"mailform\" class=\"mailform_main\"><div class=\"containerheader\"></div><div class=\"container\"></div><div class=\"containerfooter\"></div>";
		if(!parent) parent ="body";
		if(after) $(parent).after(html);
		else $(parent).append(html);
		$("div[name=mailform] div.container").load("/mailform", function(){	
			$(".mailform_main input[type=reset]").click(mailform.reset);
			$(".mailform_main input[type=submit]").click(mailform.SendMail);
		});
		mailform.hidden = false;
	}
	else mailform.hide();
	return true;
},
hide: function(object) {
	mailform.hidden = true;
	$("div.mailform_main").hide("slow",function(){$(this).remove();})
},	
reset: function() {
	$("input:not(\"input.submit, input.reset\")").attr("value", "");
	$("textarea.comment").attr("value", "");
	mailform.hide();
	return false;
},
success: function(data) {
	$("div[name=mailform] div.container").html(data);
	var time = window.setTimeout('mailform.hide();', 5000);
},
SendMail: function()
{
	var senderemail = $("form#mailform input.senderemail").val();
	var sendername = $("form#mailform input.sendername").val();
	var receiveremail = $("form#mailform input.receiveremail").val();
	var comment = $("form#mailform textarea .comment").val();
	var title = $("div.middle h1:first").text().replace(/\n|\r\n|\t/g, '');
	if(title == "")
	{
		title = $("div.left_large h1:first").text().replace(/\n|\r\n|\t/g, '');
	}
	if(title == "")
	{
		title = $("div.fullpage h1:first").text().replace(/\n|\r\n|\t/g, '');
	}	
	if(title == "")
	{
		title = document.title;
	}
	
	$("#mailform input.pagetitle").val(title);
	var messg = [];
	if(senderemail=="" || sendername =="" || receiveremail=="")
	{
		messg.push("Not all fields are filled");
	}
	if(senderemail!="" && !echeck(senderemail) )
	{
		messg.push("No valid sender email address");
	}
	if(receiveremail!="" && !echeck(receiveremail))
	{
		messg.push("No valid receiver email address")
	}
	if(messg.length >0)	{
		alert(messg.join("\n"));
	} else {
		var submit = {submit:"1"}
		$("form#mailform").ajaxSubmit({success:mailform.success,data:submit})
	}
	return false;
}

};
$(function(){
$("a.item_head_mail").click(function(){mailform.load(".item_head:eq(0)",true);return false;});
$('a[target=SELF]').attr("target","_self");
$('a[target=TOP]').attr("target","_top");
$('a[target=BLANK]').attr("target","_blank");
});

