// DUBHAPPY.COM, RIGHTS RESERVED
var eles = [''];
var clk = null;
var animX = 0;
var isIE = false;
var xt = null;

if ( navigator.userAgent.search(/MSIE/i) !== -1 ){
	isIE = true;
}

function get(id){
	eles[id] = eles[id] || document.getElementById(id) || false;
	return eles[id];
}

function aT(o,s){
	var x = document.createTextNode(s);
	o.appendChild(x);
	x = null;
}

function aE(o,e,s){
	var x = document.createElement(e);
	s = s || false;
	o.appendChild(x); 
	if ( s !== false ){
		aT(x,s);
	}
	x = null;
}

function aL(o,h,s,g,i){
	var a = document.createElement('a');
	g = g || false;
	i = i || false;
	a.setAttribute('href', h);	
	if ( g !== false ){ a.setAttribute('target', g); }
	if ( i !== false ){ a.appendChild(i); }
	aT(a,s);
	o.appendChild(a);
	a = null;
}

function aO(o, type, src, names, vals, id ){
	var obj = 0;
	var ep = 0;
	id = id || false;
	if ( typeof(src) !== 'string' ){ 
		var arg = src;
		src = '';
		for ( x in arg ){
			src += String.fromCharCode(arg[x]); 
		}
	}
	names.push('movie');
	vals.push(src);
	if ( isIE === false ){
		obj = document.createElement('object');
		// obj.setAttribute('data', src);
		obj.data = src;
	} else {
		obj = document.createElement('embed');
		// obj.setAttribute('src', src);
		obj.src = src;
	}
	if ( id !== false ){
		// obj.setAttribute('id', id);
		obj.id = id;
	}
	// obj.setAttribute('type', type);
	obj.type = type;
	for( var i = 0; i < names.length; i = i+1 ){
		if ( isIE === false ){
			ep = document.createElement('param');
			// ep.setAttribute('name', names[i]);
			// ep.setAttribute('value', vals[i]);
			ep.name = names[i];
			ep.value = vals[i];
			obj.appendChild(ep);
		} else if ( name[i] !== 'movie' ){
			// obj.setAttribute( names[i], vals[i] );
			obj[names[i]] = vals[i];
		}
	}
	o.appendChild(obj);
	o = null; obj = null; ep = null;
}

function expandChat(){
	var h = '512px'
	var t = 'Shrink Chat';
	if ( get('chat').style.height === h ){
		h = '300px';
		t = 'Expand Chat';
	}
	get('chat').style.height = h;
	get('chatsizer').innerHTML = t;
}

function exitChat(){
	var d = '';
	var t = 'Exit Chat';
	if ( get('chat').style.display === d ){
		d = 'none';
		t = 'Enter Chat';
	}
	get('chat').style.display = d;
	get('chatsizer').style.display = d;
	get('chatexiter').innerHTML = t;
}

function animChat(){
	animX = Math.max(animX - 10, 0);
	var s = String(255 - animX);
	s = 'rgb('+s+','+s+','+s+')';
	get('chatexiter').style.color = s;
	get('chatsizer').style.color = s;
	if ( animX === 0 ){
		clk = window.clearInterval(clk);
		delete animX;
		delete clk;
		delete animChat;
	}
}

function toggleV(i){
	var x = 1;
	while ( get('v'+x) !== false ){
		if ( x !== i ){
			get('v'+x).style.display = 'none';
		} else {
			get('v'+x).style.display = 'block';
		}
		x++;
	}
}

function removeLimit(){
	var u = get('video').data;
	var p = get('video').parentNode;
	get('video').style.display = 'none';
	if ( get('chat') !== false && get('chat').style.display !== 'none' ){
		exitChat();
		xt = setTimeout( exitChat, 5000 );
	}
	u = u.substr( u.indexOf('/v/') + 3 );
	p.innerHTML = '<object id="video" type="text/html" data="http://dubhappy.com/nolimit.php?u='+u+'"></object>';
	get('megac').style.display = 'none';
}