        /* gallery */
        function loadGallery()
        {
         $('#rotator').cycle(
         {
          fx: 'fade',
          speed: 1500,
	  timeout: 8000,
          pause: 1,
          after: onAfter
         });
        }

        function onAfter()
        {
         var index = $('#rotator .slide').index(this);
         
         var activeJqueryElement = $($('#slidenumbers div').get(index));

         $('#slidenumbers div').attr("class", "");
         activeJqueryElement.attr("class", "active");
        }
            
        function checkSifrLoad()
        {
         if (totalElements == 0 || sIFR.replacements.length > 0)
         {
          loadGallery();
          clearInterval(loadGalleryInterval);

 // fix subpage height
 var stdfocus = $("#stdfocus");
if (stdfocus.length > 0)
{
 var focusHeight = stdfocus.position().top + stdfocus.outerHeight();
 var stdcontent = $("#stdcontent");
 if (stdcontent.length <= 0)
 {
  stdcontent = $("#stdcontentalt");
 }
 var contentHeight = stdcontent.position().top + stdcontent.outerHeight();
 $("#content").css("height", (focusHeight > contentHeight ? focusHeight : contentHeight));
}
         }
        }
            
        var totalElements = 0;
        var loadGalleryInterval;

        function sifrReplace(f, p)
        {
         totalElements += window.parseSelector(p.selector).length;
         sIFR.replace(f, p);
        }
        
        $(document).ready(function()
        {


if(typeof sIFR == "function")
{
 sIFR.replaceElement(named(
 {
  sSelector:"#stdmenu .selected",
  sFlashSrc:"/media/6/klavikabasicregular.swf",
  sColor:"#000000",
  sLinkColor:"#000000",
  sBgColor:"#FFFFFF",
  sHoverColor:"#000000",
  nPaddingTop:0,
  nPaddingBottom:0,
  sWmode:"transparent",
  sFlashVars:"textalign=left&offsetTop=0"
 }));
 sIFR.replaceElement(named(
 {
  sSelector:"#stdmenu span",
  sFlashSrc:"/media/6/klavikabasicregular.swf",
  sColor:"#666666",
  sLinkColor:"#666666",
  sBgColor:"#FFFFFF",
  sHoverColor:"#666666",
  nPaddingTop:0,
  nPaddingBottom:0,
  sWmode:"transparent",
  sFlashVars:"textalign=left&offsetTop=0"
 }));
 sIFR.replaceElement(named(
 {
  sSelector:"#stdcontent h1",
  sFlashSrc:"/media/493/klavikabasiclightitalic.swf",
  sColor:"#000000",
  sLinkColor:"#000000",
  sBgColor:"#FFFFFF",
  sHoverColor:"#000000",
  nPaddingTop:0,
  nPaddingBottom:0,
  sWmode:"transparent",
  sFlashVars:"textalign=left&offsetTop=0"
 }));
 sIFR.replaceElement(named(
 {
  sSelector:".quote",
  sFlashSrc:"/media/493/klavikabasiclightitalic.swf",
  sColor:"#000000",
  sLinkColor:"#000000",
  sBgColor:"#FFFFFF",
  sHoverColor:"#000000",
  nPaddingTop:0,
  nPaddingBottom:0,
  sWmode:"transparent",
  sFlashVars:"textalign=left&offsetTop=0"
 }));
 sIFR.replaceElement(named(
 {
  sSelector:"h1",
  sFlashSrc:"/media/3/klavikabasiclight.swf",
  sColor:"#000000",
  sLinkColor:"#000000",
  sBgColor:"#FFFFFF",
  sHoverColor:"#000000",
  nPaddingTop:0,
  nPaddingBottom:0,
  sWmode:"transparent",
  sFlashVars:"textalign=left&offsetTop=0"
 }));
 sIFR.replaceElement(named(
 {
  sSelector:"h2",
  sFlashSrc:"/media/6/klavikabasicregular.swf",
  sColor:"#999999",
  sLinkColor:"#999999",
  sBgColor:"#FFFFFF",
  sHoverColor:"#999999",
  nPaddingTop:0,
  nPaddingBottom:0,
  sWmode:"transparent",
  sFlashVars:"textalign=left&offsetTop=0"
 }));
}
/*
            // sIFR
            var klavikabasiclight = { src: '/media/3/klavikabasiclight.swf' };
            var klavikabasicregular = { src: '/media/6/klavikabasicregular.swf' };
            sIFR.activate(klavikabasiclight);
            sIFR.activate(klavikabasicregular);

            
            // menu
            sifrReplace(klavikabasiclight,
            {
                selector: '#menu',
                css: [
                    '.sIFR-root { text-align: right; }'
                    ,'a { text-decoration: none; color: #999999; }'
                    ,'a:hover { color: #000000; }'
                    ,'.selected { color: #000000; }'
                  ],
                wmode: 'transparent'
            });
            
            // tagline
            sifrReplace(klavikabasicregular,
            {
                selector: '#tagline',
                css: { '.sIFR-root': { 'color': '#a5a5a5' } },
                wmode: 'transparent'
            });

            // h1
            sifrReplace(klavikabasiclight,
            {
                selector: '#stdcontent h1',
                css: { '.sIFR-root': { 'color': '#000000', 'font-style':'italic' } },
                wmode: 'transparent'
            });
            
            // h1
            sifrReplace(klavikabasiclight,
            {
                selector: 'h1',
                css: { '.sIFR-root': { 'color': '#000000' } },
                wmode: 'transparent'
            });
            
            // h2
            sifrReplace(klavikabasicregular,
            {
                selector: 'h2',
                css: { '.sIFR-root': { 'color': '#999999' } },
                wmode: 'transparent'
            });

            // sub menu
            sifrReplace(klavikabasicregular,
            {
                selector: '#stdmenu div',
                css: [
                    ,'a { text-decoration: none; color: #666666; }'
                    ,'a:hover { color: #000000; }'
                    ,'.selected { color: #000000; }'
                  ],
                wmode: 'transparent'
            });
*/

            loadGalleryInterval = setInterval("checkSifrLoad()", 500);
            
            // watermark
	        $("#searchinput").watermark('Type search terms');
        });

$(document).ready(function()
{
	if ($("#stdmenu").length > 0)
	{
		var menuHeight = $("#stdmenu").height();
		var parent = $("#stdmenu").parent();
		var parentHeight = parent.height();
		if (parentHeight < menuHeight)
		{
			parent.css("height", menuHeight + "px");
			parent.css("position", "absolute");
			parent.css("z-index", "100");
		}
		if (parentHeight > menuHeight)
{
$("#stdmenu").css("height", parentHeight + "px");
parent.css("position", "absolute");
parent.css("z-index", "100");
}

var belowmenualt = $(".belowmenualt");
if (belowmenualt.length > 0)
{
	//belowmenualt.css("position", "relative");
	belowmenualt.css("position", "absolute");
	belowmenualt.css("top", (menuHeight+24) + "px");
}

	}
	$("#englishlink").click(function()
	{
		$.blockUI(
		{ 
			message: "Under construction...", 
			css: { top: '20%', padding: '20px', fontSize: '20px' }
		}); 
		setTimeout($.unblockUI, 2000); 
	});

$(".displayitemheader").mouseover(function()
{
 if ($("#content" + $(this).attr("id").substring(6)).is(":visible") == false)
 {
  $(this).css("backgroundColor", $(this).attr("mouseovercolor"));
 }
});
$(".displayitemheader").mouseout(function()
{
 if ($("#content" + $(this).attr("id").substring(6)).is(":visible") == false)
 {
  $(this).css("backgroundColor", "");
 }
});
/*
if ($("#stdmenu").length > 0 && $("#stdfocus").length > 0)
{
 var height = $("#stdmenu").height() + 24;
 var top = $("#stdfocus").css("top");
 top = top.substring(0, top.length - 2);
 if (height > top)
 {
  $("#stdfocus").css("top", height);
 }
}*/

});

function toggleVisibleItem(elemid, headerbgcolor)
{
 var elem = $("#content" + elemid);
 var header = $("#header" + elemid);

 if (elem.is(":visible") == true)
 {
  elem.hide(400);
  if (headerbgcolor != '')
  {
   header.css("background-color", "");
  }
 }
 else
 {
  elem.show(400);
  if (headerbgcolor != '')
  {
   header.css("background-color", headerbgcolor);
  }
 }

 if (headerbgcolor == '')
 {
  header.toggleClass("selectedheader");
 }
}
