function urlcheck(url){
	var arg = url.match(new RegExp("(.+?\).(gif|jpg|JPG|GIF)"));
	if (arg!=null){
		selectpf(url);
		$('#bgurl').val('');
		chide('urlbg');	
		
	}else{
		$('#url_err').show();
	}
	
}

function showpf(){
	
	$('#pf').toggle();
	if ($('#pf').css("display")!='none'){
		$('#pf').show();
		listpf();
	}
}
function listpf(){
	$('#pful').html('');
	for(var i=0;i<4;i++){
		if (pf_index>=pf_length) pf_index = 0;
		if (pf_index<0) pf_index = pf_length;
		tmp = pf_index + i;
		tmp = tmp % pf_length;
		$('#pful').append("<li>"+$($('#pflist').children().get(tmp)).html()+"</li>");
	}
	var quan = "";
	for(var i=0;i<3;i++){
		if (pf_index/4 == i){
			quan += '<img src="http://img.openv.tv/www/20081209/images/quan.gif" width="8" height="8" style="cursor:pointer" />';
		}else{
			quan += '<img src="http://img.openv.tv/www/20081209/images/quan1.gif" width="8" height="8" onclick="javascript:pf_index = '+i*4+';listpf();" style="cursor:pointer" />';
		}
	}
	$('#listpf_page').html(quan);
}

function selectpf(pf){
	var jpg_path = pf.match(new RegExp("(.+?\).(gif|jpg|JPG|GIF)"));
	if (jpg_path!=null){
		if (jpg_path[1].indexOf("http://img.openv.tv/www/20081209/images/s_")!=-1){
			pf = "http://img.openv.tv/www/20081209/images/"+jpg_path[1].substr(jpg_path[1].indexOf("s_")+2)+"."+jpg_path[2];
			
		}
	}
    var Days = 180;
    var exp  = new Date();
    exp.setTime(exp.getTime() + Days*24*60*60*1000);
    //$(document.body).css("background","url("+pf+") ");
    //$(document.body).css("background","");
    $("#bgimg").attr("src",pf).show().css("height",$(window).height());
    
	document.cookie = "pf="+pf+";expires="+exp.toGMTString()+";";
}
function showurlbg(){
	var w1 = $('#pf').css("width");
	w1_int = w1.substr(0,w1.indexOf("px"));
	var w2  = $('#urlbg').css("width");
	w2_int = w2.substr(0,w2.indexOf("px"));
	$('#urlbg').css({position: "absolute",left:($('#xz').offset().left+(w1_int-w2_int)/2)+"px"});
	$('#urlbg').show();
}
function chide(id){
	$('#'+id).hide();
}
var pre_div;
function showInfo(type,show_div,n){
			var show_div = $(show_div);
			if (type=='list'){
				//show_div = $(show_div).parent().parent();
			}

			var ref = $('#r_'+n).html();
			var content = $("#list_"+n).html();
			
			var div;
			var rtn = '';
			var swf = '<embed width="130" height="98" type="application/x-shockwave-flash" flashvars="'+ref+'" src="http://img.openv.tv/www/swf/ls/singleload_68_51.swf" allowfullscreen="true" quality="high" allowscriptaccess="always"/>';


			if (type=='box'){
				div = document.createElement("div");
				$(div).addClass("list list2");

				rtn = '    <div class="img">'+swf+'</div>\
							<div class="clear"></div>\
							<dl>'+content+'</dl>';
			}else{
				div = document.createElement("li");
				$(div).addClass("list_s1");
				rtn = '<div class="img">'+swf+'</div>\
						<dl>'+content+'</dl>';
			}

			$(div).attr("id","info");

			
			if ($('#info')){
				$('#info').remove();
				if (pre_div!=null){
					pre_div.show();
				}
			}
			$(div).html(rtn);
			//if (type=='box'){
				$(div).css({ position: "absolute",top: show_div.offset().top+"px", left: show_div.offset().left+"px", zIndex: "66"});
			//}else{
				//show_div.hide();
			//}			
			show_div.before($(div));
			show_div.attr("id","hide_div");	
			$('#info').hover(function(){
				pre_div = show_div;
				
			},function(){
				//if (type=='box'){
					$(this).remove();
					pre_div.show();
				//}
			})
			

}
function slike(){
	var nums = $('#nums').val();
	var sort = $('#sort').val();
	var ltype = $("#ltype").val();
	document.cookie = "num="+nums+";";
	document.cookie = "sort="+sort+";";
	document.cookie = "ltype="+ltype+";";
	
}
function dlike(){
	$('#nums').val('20');
	$('#sort').val('relevance');
	$("#ltype").val('list');
	slike();
}
function search(){
	$('#p').val('');
	$('#q').val($('#q2').val());
	$('#form1').submit();
	return false;
	
}