/* common.js */

jQuery(function(){
	autoSize();
	jQuery(window).resize(function(){autoSize();});
})

//---------------------------functioin List------------------------------//

function autoSize(){
	var winWidth = $(window).width();
	var winHeight = $(window).height();
	$(".leftFrame").height(winHeight - 60);
	$(".rightFrame").width(winWidth - $(".leftFrame").width() - 8);
	$(".rightFrame").height(winHeight - 60);
} 
DZHseo={
	fontinit:function(size){//init font size
		jQuery("#subcon").toggleClass("f"+size);
	},
	seoShare:function(flag,urlxnV1,titlexnV1,sharebody,sid){//seo share
		if( flag=="xn" ){//xiao nei
			var u='http://share.xiaonei.com/share/buttonshare.do?link='+urlxnV1+'&amp;title='+encodeURIComponent(titlexnV1);
			window.open(u,'xiaonei','toolbar=0,resizable=1,scrollbars=yes,status=1,width=626,height=436');
		}else if( flag=="qzone" ){//qzone
			window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+encodeURIComponent('http://dzh.mop.com/topic/readSub_'+sid+'_0_0.html'),'_blank');
		}else if( flag == "hi" ){//hi
		
		}else if( flag == "kaixin" ){//kaixin
			window.open('http://www.kaixin001.com/repaste/share.php?rtitle='+encodeURIComponent('转自猫扑：'+titlexnV1)+'&amp;rurl='+encodeURIComponent(urlxnV1)+'&amp;rcontent='+sharebody+'--查看完整内容，请点击来源链接查看'); 
		}else if( flag == "douban" ){//dou ban
			 window.open('http://www.douban.com/recommend?title='+encodeURIComponent('转自猫扑：'+titlexnV1)+'&amp;url='+encodeURIComponent(urlxnV1));
		}else if( flag == "bai" ){//bai she hui
			window.open('http://bai.sohu.com/share/blank/addbutton.do?from=http://dzh.mop.com'+'&amp;link='+encodeURIComponent(urlxnV1)+'&amp;','_blank');
		}else if( flag == "sina" ){//sina
			window.open('http://v.t.sina.com.cn/share/share.php?title='+encodeURIComponent('转自猫扑：'+titlexnV1)+'&amp;url='+encodeURIComponent(urlxnV1)+'&amp;source=bookmark','_blank','width=450,height=400');
		}
	},
	seoCopy:function(msg,id){//复制本帖地址
		if (document.all){//判断Ie 
			var textcon = jQuery("#"+id).text();  
			textcon=textcon+"\n"+jQuery("#"+id).attr("href"); 
			window.clipboardData.setData('text', textcon);
			alert(msg);
		}else{
			alert("您的浏览器不支持剪贴板操作，请自行复制。"); 
		} 
	},
	seoCheckForm:function(){//检查表单
		var tuname = jQuery("#txtusername2").val();
		var tpwd = jQuery("#txtpassword2").val();
		var body = jQuery("#body").val();
		if( tuname == null || tuname == "" || tuname=="undefined" ){
			alert("请输入昵称!");
			return;
		}
		if( tpwd == null || tpwd == "" || tpwd=="undefined" ){
			alert("请输入密码!");
			return;
		}
		if( body == null || body == "" || body=="undefined" ){
			alert("请输入文本内容!");
			return;
		}
		jQuery("#formseo").attr("action","./replyactionv2.jsp")
		jQuery("#formseo").submit();
	},
	checkLogin:function(){
		var uname = jQuery("#user_name").val();
		var upwd = jQuery("#password").val();
		if( uname == null || uname == "" || uname=="undefined" ){
			alert("请输入昵称!");
			return;
		}
		if( upwd == null || upwd == "" || upwd=="undefined" ){
			alert("请输入密码!");
			return;
		}
		jQuery("#loginForm").attr("action","http://passport.mop.com/Login")
		jQuery("#loginForm").submit();
	},
	focusImg:function(){  
		var count = jQuery("#play_list a").size()
		jQuery("#play_list a:not(:first-child)").hide();
		jQuery("#play_info").html(jQuery("#play_list a:first-child").find("img").attr('alt'));
		//给其他的设置未选中的样式 
		jQuery("#play_text li").addClass("pic_seletOff"); 
		jQuery("#play_text li:first-child").removeClass("pic_seletOff"); 
		jQuery("#play_text li:first-child").toggleClass("pic_seletOn"); 
		jQuery("#play_info").click(function(){window.open(jQuery("#play_list a:first-child").attr('href'), "_blank")}); 
		jQuery("#play_text li").click(function(){
			var i =jQuery(this).text() - 1;
			n = i;
			if (i >= count) return;
			jQuery("#play_info").html(jQuery("#play_list a").eq(i).find("img").attr('alt'));
			jQuery("#play_info").unbind().click(function(){window.open(jQuery("#play_list a").eq(i).attr('href'), "_blank")})
			jQuery("#play_list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000); 
			//给其他的设置未选中的样式
			jQuery("#play_text li").removeClass("pic_seletOn"); 
			jQuery("#play_text li").addClass("pic_seletOff"); 
			//给当前设置选中的css样式  
			jQuery("#play_text li").eq(jQuery(this).text()-1).removeClass("pic_seletOff");
			jQuery("#play_text li").eq(jQuery(this).text()-1).addClass("pic_seletOn"); 
		}); 
		t = setInterval("showAuto("+count+")", 4000);
		jQuery("#play").hover(function(){clearInterval(t)}, function(){t = setInterval("showAuto()", 4000);}); 
	}, 
	addStatics:function(sid){//增加阅读次数统计数
		var url ="http://dzh.mop.com/stat/addvideo.jsp?f=412&v="+sid+"&jsoncallback=?";
		jQuery.getJSON(url,function(){});  
	} 
}
function showAuto(count){
	n = n >= (count - 1) ? 0 : ++n;
	jQuery("#play_text li").eq(n).trigger('click');  
	//给其他的设置未选中的样式
	jQuery("#play_text li").removeClass("pic_seletOn"); 
	jQuery("#play_text li").addClass("pic_seletOff"); 
	//给当前设置选中的css样式  
	jQuery("#play_text li").eq(n).removeClass("pic_seletOff");
	jQuery("#play_text li").eq(n).addClass("pic_seletOn");
} 
jQuery(document).ready(function(){
	for( var i=0;i < imgUrl.length;i++ ){
		jQuery("#play_list").append("<a href=\""+imgLink[i]+"\"><img border=\"0\" src=\""+imgUrl[i]+"\" alt=\"\"/></a>"); 
	}  
	var  t = n = 0;
	DZHseo.focusImg(); 
	DZHseo.addStatics(subject_id);
});



