/**
 * Main script for the BonusThemes.com Corez Template
 *
 * @package bt_corez
 * @version 1.0
 * @copyright BonusThemes.com 2008
 * @link http://www.bonusthemes.com/goto/bt_corez
 */


function addEvent(obj, event, func)
{
	if (obj.addEventListener)
		obj.addEventListener(event, func, false);
	else if (obj.attachEvent)
		obj.attachEvent('on' + event, func);
}

function page_init()
{
	if (document['cmenu_items']) {
		document['mc'] = new CMenu({
			iname: 'mc',

			side: 'down',
			orientation: 'right',

			animate: true,
			anim_step: 10,
			anim_interval: 40,

			transparency: true,
			transparency_ie6: false,

			min_opacity: 0,
			max_opacity: 90,

			panel_offset1_x: 0,
			panel_offset1_y: 0,
			panel_offset2_x: 5,
			panel_offset2_y: 0,

			separator_class: 'cmenu_separator',
			panel_class: 'cmenu_panel',
			panel_tl_class: 'cmenu_tl',
			panel_tc_class: 'cmenu_tc',
			panel_tr_class: 'cmenu_tr',
			panel_ml_class: 'cmenu_ml',
			panel_mr_class: 'cmenu_mr',
			panel_bl_class: 'cmenu_bl',
			panel_bc_class: 'cmenu_bc',
			panel_br_class: 'cmenu_br',

			mi_empty_normal_class: 'cmenu_mi_empty_normal',
			mi_empty_hover_class: 'cmenu_mi_empty_hover',
			mi_full_normal_class: 'cmenu_mi_full_normal',
			mi_full_hover_class: 'cmenu_mi_full_hover'

		});
	
		var len = document['cmenu_items'].length;
		if (len > 0) {
			for (var i = 0; i < len; i++) {
				var item = document['cmenu_items'][i];
		
				if (typeof item.parent_id == 'undefined')
					this[item.id] = document['mc'].add_item(item);
				else
					this[item.id] = this[item.parent_id].add_item(item);
			}
		
			document['mc'].run();
		}
	}


	document['brdcell_params'] = {
		anim_interval: 50,
		climb_step: 5,
		hover_step: 5,
		norm_color: '#1a1d1f',
		hover1_color: '#7189a2',
		hover2_color: '#2971a7'
	};

	document['brdcells'] = { };
	for (var i = 0, len = document['brdcell_names'].length; i < len; i++) {
		document['brdcell_params'].iname = document['brdcell_names'][i];
		document['brdcells'][document['brdcell_names'][i]] = new BorderCell(document['brdcell_params']);
	}
}

addEvent(window, 'load', page_init);


var goto_top_type = -1;
var goto_top_itv = 0;

function goto_top_timer()
{
	var y = goto_top_type == 1 ? document.documentElement.scrollTop : document.body.scrollTop;
	var moveby = 15;

	y -= Math.ceil(y * moveby / 100);
	if (y < 0)
		y = 0;

	if (goto_top_type == 1)
		document.documentElement.scrollTop = y;
	else
		document.body.scrollTop = y;

	if (y == 0) {
		clearInterval(goto_top_itv);
		goto_top_itv = 0;
	}
}

function goto_top()
{
	if (goto_top_itv == 0) {
		if (document.documentElement && document.documentElement.scrollTop)
			goto_top_type = 1;
		else if (document.body && document.body.scrollTop)
			goto_top_type = 2;
		else
			goto_top_type = 0;

		if (goto_top_type > 0)
			goto_top_itv = setInterval('goto_top_timer()', 50);
	}
}
