var dom = 'http://' + document.domain;

$(document).ready(function(){
	CategoryNavigate = function(){
		location.href = $('#categorySelectbox').val(); 
	}

	$('.searchBtn').bind("click",function(e){
		e.preventDefault;
		switch( $(this).attr('id') )
		{
			case 'movieSearch':
				var t = 'movies';
				break;
			case 'picSearch':
				var t = 'pictures';
				break;
			default:
				var t = 'videos';
				break;
		}
		var f = 1;
		var q1 = document.getElementById('q'+f).value;
		
			q2 = q1.replace(/([^a-zA-Z0-9\ ]+)/gi, '');
			q = q2.split(' ').join('-');
			if(q==''){
				if(t=='videos'){
					location.href="http://www.cleancafe.com/";
					return false;
				}else{
					q='index';
				}
			}
			location.href="http://www.cleancafe.com/search/"+t+"/"+q+".html";

			return false;
	});

	$("#sorting div").bind("click",function(){
		if($(this).hasClass('sortSelected')==false){
			var url = $(this).attr('u');
			location.href=url;
		}
		return false;
	});

	
});

function adxjwstate(a){
	if(a.newstate=='PAUSED'||a.newstate=='IDLE'||a.newstate=='COMPLETED'){ 
		mouseOverAdShow = true; 
		adxadshow();
	}
	if(a.newstate=='PLAYING'||a.newstate=='BUFFERING'){
		adxadhide();
	}
};
function setVideo(file,preview,link,sponsor,stream){
	var so = new SWFObject('/tube/player.swf','player1','100%','500','9','#171616');
	so.addParam('allowscriptaccess','always');
	so.addParam('allowfullscreen','true');
	so.addParam('wmode','opaque');
	so.addVariable('file', file);
	//so.addVariable('image', preview);
	so.addVariable('autostart', 'false');
	so.addVariable('skin', '/v5/modieus.swf');
	so.addVariable('frontcolor', 'ffffff');
	so.addVariable('lightcolor', 'cc9900');
	so.addVariable('stretching', 'fill');
	so.addVariable('controlbar', 'over');
	so.addVariable('linktarget', '_blank');
	so.addVariable('link', escape(link));
	if(stream=='lighttpd'){
		so.addVariable('streamer', 'lighttpd');
		so.addVariable('type', 'video');
	}else{
		so.addVariable('provider', 'http');
	}
	
	so.write('ply');
};

playerReady = function playerReady(a){
	adxjwready(a);
	var player = document.getElementById(a.id);
		player.sendEvent('PLAY', 'true');
		player.sendEvent('PLAY', 'false');
};

function relVid(q,t){
	var html = "html";
	if(typeof(t)=="undefined"){
		location.href=dom+"/search/"+q+"."+html;
	}else{
		location.href=dom+"/"+t+"/"+q+"."+html;
	}
};

function resizeIframe(newHeight,id)
{
	if(id > '' && document.getElementById('ad'+id)){
		document.getElementById('ad'+id).style.height = parseInt(newHeight) + 10 + 'px';
	}
};

pic1= new Image(129,30); 
pic1.src="http://www.cleancafe.com/v6/images/sort.block.black.png";

pic2= new Image(129,30); 
pic2.src="http://www.cleancafe.com/v6/images/sort.block.yellow.png"; 

pic3= new Image(129,30); 
pic3.src="http://www.cleancafe.com/v6/images/sort.block.white.png"; 

