var Ant = {
    onLoad : function ()
    {
    },
	
	/**
	 * Copy parameters
	 */
	apply : function(o, c, defaults){
	    if(defaults){
	        apply(o, defaults);
	    }
	    if(o && c && typeof c == 'object'){
	        for(var p in c){
	            o[p] = c[p];
	        }
	    }
	    return o;
	}
}



function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}



/**
 * Video wall
 */
var Wall = {

    getXY : function (obj)
    {
        var xpos = 0, ypos = 0;
        if(obj.offsetParent)
        {
            while(1) 
            {
                xpos += obj.offsetLeft;
                ypos += obj.offsetTop;
                if (!obj.offsetParent) break;
                obj = obj.offsetParent;
            }
        }
        else if (obj.x || obj.y)
        {
            xpos = obj.x;
            ypos = obj.y;
        }
        return [xpos, ypos];
    },
    
    show : function (img, link)
    {
        this.m_hide = false;
        
        // copy link data
        var layer_link = $('layer-link');
        layer_link.href = link.href;
        
        // copy img data
        var layer_img = $('layer-img');
        layer_img.src = img.src;
        layer_img.alt = img.alt;
        layer_img.title = img.title;
        
        // show the layer
        var layer = $('layer');
        var xy = this.getXY(img);
        layer.style.left = (xy[0] - 24) + 'px';
        layer.style.top = (xy[1] - 18) + 'px';
        layer.style.display = 'block';
    },
    
    hide : function ()
    {
        // to smooth if user moves from one video to another
        // then don't hide (avoid flickering)
        this.m_hide = true;
        setTimeout(Wall._hide, 100);
    },
    
    _hide : function ()
    {
        if (Wall.m_hide)
        {
            $('layer').style.display = 'none';
            Wall.m_hide = false;
        }
    },
    
    m_hide : false
}


var Tabber = {
    
    _tabs : {},
    
    addTab : function (box, index, img1, img2)
    {
        this._tabs[box + "_" + index] = { active : img1, passive : img2 };
    },
    
    activate : function (box, tab, img1, img2)
    {
        if ($('box' + box + '-tab1').style.display != 'none')
            ca = 1;
        else
            ca = 2;
        if (tab == ca) return;
        
        var cca = box + "_" + ca;
        var cctab = box + "_" + tab;
        $('tab-img-' + box + '-' + ca).src = this._tabs[cca].passive;
        $('tab-img-' + box + '-' + tab).src = this._tabs[cctab].active;
        
        // swap tabs
        $('box' + box + '-tab' + ca).hide();
        $('box' + box + '-tab' + tab).show();
    }

}

