window.onload = function(){	if(getcookie('mavstart_font_size')){ setFontSize(getcookie('mavstart_font_size')); }	};

//layer hiddener
function shSec(id)
{
	if(!document.getElementById) return;
	var o=document.getElementById(id);
	if(o)
	{
		if(o.style.display=="block")
			o.style.display="none";
		else
			o.style.display="block";
	}
}

//show a layer
function hideL(id)
{
	if(!document.getElementById) return;
	var o=document.getElementById(id);
	o.style.display="none";
}

//hide a layer
function showL(id)
{
	if(!document.getElementById) return;
	var o=document.getElementById(id);
	o.style.display="block";
}

//popup opener
function go(wintype,w,h,command)
{
  st=new String("toolbar=no,directories=no,status=no,scrollbars=no,menubar=no,width="+w+",height="+h);
  picture=window.open(wintype+command,"picture",st);
  picture.window.focus();
}

//popup opener
function gox(wintype,w,h,command)
{
  st=new String("toolbar=yes,directories=no,status=yes,scrollbars=yes,menubar=yes,width="+w+",height="+h);
  picture=window.open(wintype+command,"picture",st);
  picture.window.focus();
}

//layer hiddener with iconchanger
function FShow(id,icono,iconc)
{
	if(!document.getElementById) return;
	var o=document.getElementById(id);
	var i=document.getElementById('b'+id);
	if(o)
	{
		if(o.style.display=="block")
		{
			o.style.display="none";
			i.src=iconc;
		}
		else
	 {
			o.style.display="block";
			i.src=icono;
	 }
	}
}

//printfunction
function printpage()
{
window.print();
}

//make an input empty
function emptyInput(id)
{
	if(!document.getElementById) return;
	var o=document.getElementById(id);
	o.value="";
}

//fill an input field
function fillInput(id,val)
{
	if(!document.getElementById) return;
	var o=document.getElementById(id);
	if(o.value=='') o.value=val;
}

//Setcookie
function setcookie(name, value, days, path, domain, secure)
{
	var expires = -1;
	if(typeof days == "number" && days >= 0)
	{
		var d = new Date();
		d.setTime(d.getTime()+(days*24*60*60*1000));
		expires = d.toGMTString();
	}
	value = escape(value);
	document.cookie = name + "=" + value + ";" + (expires != -1 ? " expires=" + expires + ";" : "") + (path ? "path=" + path : "") + (domain ? "; domain=" + domain : "") + (secure ? "; secure" : "");
}

//Delcookie
function delcookie(name)
{
	setcookie(name, "-", 0);
}

//Getcookie
function getcookie(name)
{
	var idx = document.cookie.indexOf(name+'=');
	if(idx == -1) { return null; }
	value = document.cookie.substring(idx+name.length+1);
	var end = value.indexOf(';');
	if(end == -1) { end = value.length; }
	value = value.substring(0, end); value = unescape(value);
	return value;
}

//Set font size cookie and style
function setFontSize(fs)
{
	document.body.style.fontSize=fs+"em";
	setcookie('mavstart_font_size', fs, 365, '/');
}

function exxiteTab(prefix,me,maxn)
{
	for(i=0; i < maxn; i++)
	{
	  o = document.getElementById(prefix+String(i));
	  o.className='tab';
	  o = document.getElementById('t'+prefix+String(i));
	  o.className='tabpanel';
	}
	o = document.getElementById(prefix+String(me));
	o.className='seltab';
	o = document.getElementById('t'+prefix+String(me));
	o.className='seltabpanel';
}

function calcHeight(mid)
{
  o = document.getElementById(mid);
  o.style.height=600;
  o.style.display='block';
  o1 = o.contentWindow;
  the_height=o1.document.body.scrollHeight;
  o.style.height=the_height;
}

// Leap year detector for date scripts
function exxiteLeapYear(year)
{
	if(year%4 == 0)
	{
		if(year%100 != 0)
		{
			return(true);
		}
		else
		{
			if(year%400 == 0){return(true);}else{return(false);}
		}
	}
  return(false);
}


function exxiteDateToUnixtime(oyear,omonth,oday,ohour,ominute)
{
		var humDate = new Date(Date.UTC(oyear,(omonth-1),oday,ohour,ominute,0));
		return(humDate.getTime()/1000.0);
}

//Date control javascript----------------------------
function exxiteDateControl(mid,control,syear,eyear)
{
	if(!document.getElementById) return;
	oyear=document.getElementById(mid+'_year');
	omonth=document.getElementById(mid+'_month');
	oday=document.getElementById(mid+'_day');
	ohour=document.getElementById(mid+'_hour');
	ominute=document.getElementById(mid+'_minute');
	ostamp=document.getElementById(mid+'_stamp');
	myear=parseInt(oyear.value);
	mmonth=parseInt(omonth.value);
	mday=parseInt(oday.value);
	mhour=parseInt(ohour.value);
	mminute=parseInt(ominute.value);
	leap=exxiteLeapYear(myear);
	if(control=='y')
	{
		oyear.options.length=0;
		for(i=syear; i<=eyear; i++)
		{
			  oyear.options[i-syear]=new Option(i,i);
			  if((i)==myear) oyear.selectedIndex=i-syear;
		}
	}
	if(control=='m' || (control=='y'))
	{
		if((mmonth==4) || (mmonth==6) || (mmonth==9) || (mmonth==11)) max=30;
	  if((mmonth==1) || (mmonth==3) || (mmonth==5) || (mmonth==7)  || (mmonth==8) || (mmonth==10)  || (mmonth==12)) max=31;
	  if(mmonth==2)
	  {
	  	max=28;
	  	if(leap) max=29;
	  }
	  oday.options.length=0;
	  for(i=0; i < max; i++)
		{
      	oday.options[i]=new Option(String(i+1),String(i+1));
		}
		if(mday>max) mday=2;
		oday.selectedIndex=mday-1;
	}
	var humDate = new Date(Date.UTC(myear,mmonth,mday,mhour,mminute,0));
	;
	ostamp.value=humDate.getTime()/1000.0;
}

function getPageSize()
{
	var xScroll, yScroll;
  if(window.innerHeight && window.scrollMaxY)
  {
	  xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	}
	else if(document.body.scrollHeight > document.body.offsetHeight)
	{ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
	}
	else
	{ // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;

	if(self.innerHeight)
	{	// all except Explorer
			if(document.documentElement.clientWidth)
			{
				windowWidth = document.documentElement.clientWidth;
			}
			else
			{
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight)
	{ // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
	}
	else if(document.body)
	{ // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
	}

		// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight)
	{
			pageHeight = windowHeight;
	}
	else
	{
			pageHeight = yScroll;
	}

		// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth)
	{
			pageWidth = xScroll;
	}
	else
	{
			pageWidth = windowWidth;
	}

	return [pageWidth,pageHeight];
}

function exxiteImageOn(gid,imgx,imgy)
	{
    //c=document.getElementById(gid+'p');
    //c.style.width=String(imgx)+'px';
    c=document.getElementById(gid+'c');
    ps=getPageSize();
    c.style.height=ps[1];
    c.style.display="block";
    c=document.getElementById(gid+'cc');
    c.style.top=document.body.scrollTop+50;
    c.style.display="block";
	}

	function exxiteImageOff(gid)
	{
    c=document.getElementById(gid+'c');
    c.style.display="none";
    c=document.getElementById(gid+'cc');
    c.style.display="none";
	}