var isMSIE = /*@cc_on!@*/false;
function objectAttachEvent(obj, event, func) {
	if (isMSIE) {
		obj.attachEvent('on' + event, func);
	}
	else {
		obj.addEventListener(event, func, false);
	}
}

function randomize() {
    var randomnumber = Math.floor(Math.random() * 10000001);
    return randomnumber;
}

function initMap(map) {
	if (map == undefined || $('#' + map).length == 0) {
		return false;
	}
	$('#' + map + ' area').cluetip({
		width : 426,
		height : 'auto',
		cluezIndex : 97,
		positionBy : 'top',
		topOffset : 0,
		leftOffset : -215,
		local : true,
		hideLocal : true,
		attribute : 'alt',
		titleAttribute : '',
		splitTitle : '',
		showTitle : false,
		cluetipClass : 'default',
		hoverClass : '',
		waitImage : false,
		arrows : false,
		dropShadow : false,
		sticky : true,
		mouseOutClose : true,
		activation : 'hover',
		clickThrough : false,
		hoverIntent: {    
			sensitivity : 5,
			interval : 100,
			timeout : 0
		}
	});
}

function initHelps() {
	if ($('.help').length == 0) {
		return false;
	}
	$('.help').cluetip({
		width : 426,
		height : 'auto',
		cluezIndex : 10000,
		positionBy : 'top',
		topOffset : 0,
		leftOffset : -215,
		local : true,
		hideLocal : true,
		attribute : 'rel',
		titleAttribute : '',
		splitTitle : '',
		showTitle : false,
		cluetipClass : 'default',
		hoverClass : '',
		waitImage : false,
		arrows : false,
		dropShadow : false,
		sticky : false,
		mouseOutClose : false,
		activation : 'hover',
		clickThrough : false,
		hoverIntent: {    
			sensitivity : 5,
			interval : 100,
			timeout : 0
		}
	});
}

$(function ()
{
    initHelps();
    $('input[type="submit"], input[type="reset"]').each(function ()
    {
        if ($(this).parent('span').hasClass('button'))
        {
            $(this).removeAttr('value');
        }
    });

    $().prettyPhoto({
        theme: 'light_square'
    });



    $('.hider .off').hide();
    $('.hider').click(function ()
    {
        if ($(this).children('span.on').is(':visible'))
        {
            $('.' + $(this).attr('rel')).hide('slow');
            $(this).children('span.on').hide();
            $(this).children('span.off').show();
        }
        else
        {
            $('.' + $(this).attr('rel')).show('slow');
            $(this).children('span.on').show();
            $(this).children('span.off').hide();
        }
    });

    $(".button2 a").wrapInner("<strong />").append("<span></span>");

    KeyListener.init();
});

function chbModeChecked(id)
{
    var chbModeTab = document.getElementById("ctl00_PlaceHolderMain_ctrLoader_ctl00_chbModeTab");
    var chbModeGra = document.getElementById("ctl00_PlaceHolderMain_ctrLoader_ctl00_chbModeGra");

    if ("ctl00_PlaceHolderMain_ctrLoader_ctl00_" + id  == "ctl00_PlaceHolderMain_ctrLoader_ctl00_chbModeTab")
    {
        chbModeGra.checked = !chbModeTab.checked;
    }
    else
    {
        chbModeTab.checked = !chbModeGra.checked;
    }
}

function getSearchEmpty(text) {
    //var txt = document.getElementById('ctl00$ctrPageSearchBox$ctl00');
    var txt = $("#searchbox input[type='text']");
   	if (txt[0].value == text)
   	   txt[0].value = '';
}

function getSearchDefault(text) {
    //var txt = document.getElementById('ctl00$ctrPageSearchBox$ctl00');
    var txt = $("#searchbox input[type='text']");
    if (txt[0].value == '')
    	txt[0].value = text;
}

KeyListener = {

    init: function ()
    {
        $('#searchbox').bind('keypress', function (e)
        {
            var key = e.charCode ? e.charCode : e.keyCode ? e.keyCode : 0;
            var target = e.target.tagName.toLowerCase();
            if (key === 13 && target === 'input')
            {
                e.preventDefault();
                var button = $("#searchbox a").eq(0);
                if (button.length > 0)
                {
                    if (typeof (button.get(0).onclick) == 'function')
                    {
                        button.trigger('click');
                    } else if (button.attr('href'))
                    {
                        window.location = button.attr('href');
                    } else
                    {
                        button.trigger('click');
                    }
                }
            }
        });
    }
};

