//播放器
function GetPlayer(strFileUrl,strPreviewUrl,strPlayerName,intPlayerWidth,intPlayerHeight)
{
		var config_player_path = "http://static.onhouse.net/flash/flvplayer.swf";
		var config_player_logo = '';//"http://www.onhouse.net/Template/video/images/logo.png";
        var so = new SWFObject(config_player_path,'mpl',intPlayerWidth,intPlayerHeight,'9');
        so.addParam('allowfullscreen','true');			//是否允许全屏
        so.addParam('allowscriptaccess','always');		//是否允许js通讯
        so.addParam('wmode','opaque');					//背景模式
        so.addVariable('file',strFileUrl);				//播放文件路径
        so.addVariable('logo',config_player_logo);		//设置logo图片地址，支持透明png格式
        so.addVariable('bufferlength','3');				//设置缓冲时间
        so.addVariable('volume','80');					//设置默认音量
		so.addVariable("image",strPreviewUrl);
        so.write(strPlayerName);
}
function SendPlayer(width,height,title,url,divid){
	var swf_width=width;
	var swf_height=height;
	var swf_player="http://static.onhouse.net/flash/vcastr22.swf";
	var swf_text=title;
	var swf_file=url;
	html = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ swf_width +'" height="'+ swf_height +'">';
	html+='<param name="movie" value='+swf_player+'><param name="quality" value="high"><param name="allowFullScreen" value="true" />';
	html+='<param name="menu" value="false"><param name=wmode value="opaque">';
	html+='<param name="FlashVars" value="vcastr_file='+swf_file+'&vcastr_title='+swf_text+'&BarColor=0x000000&BarPosition=1&LogoText=www.onhouse.net&IsShowTime=1&IsAutoPlay=0&IsContinue=1&BufferTime=0">';
	html+='<embed src='+swf_player+' allowFullScreen="true" wmode="opaque" FlashVars="vcastr_file='+swf_file+'&vcastr_title='+swf_text+'&menu="false"&IsAutoPlay=1&BufferTime=2 quality="high" width="'+ swf_width +'" height="'+ swf_height +'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	html+='</object>';

	if(divid!=''){
		document.getElementById(divid).innerHTML=html;
	}else{
		document.write(html);
	}
}
//幻灯片
function GetFlash(focus_width,focus_height,pics,links,texts){
	 //var focus_width=210;
     //var focus_height=225;
     var text_height=20;
     var swf_height = focus_height+text_height;
	 var swf_file = "http://static.onhouse.net/flash/playswf.swf";

     var flashCode = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/hotdeploy/flash/swflash.cab#version=6,0,0,0" width="'+ focus_width +'" height="'+ swf_height +'">';
     flashCode = flashCode + '<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="'+swf_file+'"><param name="quality" value="high"><param name="bgcolor" value="#F0F0F0">';
     flashCode = flashCode + '<param name="menu" value="false"><param name=wmode value="opaque">';
     flashCode = flashCode + '<param name="FlashVars" value="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'">';
     flashCode = flashCode + '<embed src="'+swf_file+'" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+ focus_width +'" height="'+ swf_height +'" FlashVars="pics='+pics+'&links='+links+'&texts='+texts+'&borderwidth='+focus_width+'&borderheight='+focus_height+'&textheight='+text_height+'"></embed>';
     flashCode = flashCode + '</object>';
     document.write(flashCode);
}

function OpenFlashChart(chartid,chartwidth,chartheight,chartfile,charjson){
	var htmlstr = '<object id="'+chartid+'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+chartwidth+'" height="'+chartheight+'">';
	 htmlstr += '<param name="flashvars" value="data-file='+chartfile+'"/>';
	 htmlstr += '<param NAME="Movie" VALUE="'+chartfile+'">';
	 htmlstr += '<param NAME="Src" VALUE="'+chartfile+'">';
	 htmlstr += '<embed src="'+chartfile+'" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="'+chartwidth+'" height="'+chartheight+'";FlashVars="data-file='+chartfile+'"></embed>';
	 htmlstr += '</object>';
	document.write(htmlstr);
}
//copyToClipBoard(document.getElementById('btnCheck1').value);
function copyToClipBoard(txt) {
     if(window.clipboardData) {
             window.clipboardData.clearData();
             window.clipboardData.setData("Text", txt);
     } else if(navigator.userAgent.indexOf("Opera") != -1) {
          window.location = txt;
     } else if (window.netscape) {
          try {
               netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
          } catch (e) {
               alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
          }
          var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
          if (!clip)
               return;
          var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
          if (!trans)
               return;
          trans.addDataFlavor('text/unicode');
          var str = new Object();
          var len = new Object();
          var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
          var copytext = txt;
          str.data = copytext;
          trans.setTransferData("text/unicode",str,copytext.length*2);
          var clipid = Components.interfaces.nsIClipboard;
          if (!clip)
               return false;
          clip.setData(trans,null,clipid.kGlobalClipboard);
          alert("复制成功！")
     }
}

function addfavorite(){
    var url = document.location.href;
	var title = document.title;
	if( document.all ) {
		try{
			window.external.addFavorite(url, title);
		}
		catch(e1)  {
			try {
				window.external.addToFavoritesBar(url, title);
			}
			catch (e2){
				alert('加入收藏失败，请您手工加入。');
			}
		}
	} else if (window.external) {
		window.sidebar.addPanel(title, url,"");
	} else {
		alert('加入收藏失败，请您手工加入。');
	}

}

function setHomepage(){
	var url = document.location.href;
    if (document.all){
        document.body.style.behavior='url(#default#homepage)';
        document.body.setHomePage(url);
    }else if (window.sidebar){
        if(window.netscape){
            try{
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
            }catch (e){
                alert( "该操作被浏览器拒绝，如果想启用该功能，请在地址栏内输入 about:config,然后将项 signed.applets.codebase_principal_support 值该为true" );
            }
        }
        var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components. interfaces.nsIPrefBranch);
        prefs.setCharPref('browser.startup.homepage',url);
    }
}

function getOption(id,value,rUrl){
	 	//if (value==""){return;}
		var op = {
			type: "post",
			url: rUrl,
			dataType:'json',
			data: "value="+value+"&s="+new Date().getTime(),
			success: function(res){

				var list = res;
				var null_text="---请选择---";
	 			var cr=$(id).empty();
	 			if (list!=null){
	 				cr.append("<option value=''>"+null_text+"</option>");
	 				$(list).each(function(i,item){
	 					cr.append("<option value='"+item['regionId']+"'>"+item['name']+"</option>");
 					});
 				}
		  }}
		  $.ajax(op);
}

multiclock = function(timeleft, counter){
	var a = parseInt(jQuery("#"+timeleft).attr('diff'));
	if (!a>0) return;
	var b = (new Date()).getTime();
	var e = function() {
		var c = (new Date()).getTime();
		var ls = a + b - c;
		if ( ls > 0 ) {
			var ld = parseInt(ls/86400000) ; ls = ls % 86400000;
			var lh = parseInt(ls/3600000) ; ls = ls % 3600000;
			var lm = parseInt(ls/60000) ;
			var ls = parseInt(Math.round(ls%60000)/1000);

			if (ld>0) {
				var strhtml = '<span id="timeleft" diff="'+a+'"><b>'+ld+'</b>天<b>'+lh+'</b>小时<b>'+lm+'</b>分钟<b>'+ls+'</b>秒</span>';
			} else {
				var strhtml = '<span id="timeleft" diff="'+a+'"><b>'+lh+'</b>小时<b>'+lm+'</b>分钟<b>'+ls+'</b>秒</span>';
			}
			//var strhtml = '<span id="counter"><b>'+ld+'</b>天<b>'+lh+'</b>小时<b>'+lm+'</b>分钟<b>'+ls+'</b>秒</span>';
			jQuery("#"+counter).html(strhtml);
		} else {
			jQuery("#"+counter).stopTime('"+counter');
			jQuery("#"+counter).html('end');
			window.location.reload();
		}
	};
	jQuery("#"+counter).everyTime(996, counter, e);
};

function ajaxGetStr(url,type,value,AjaxID){
	$.ajax({
		   type:"GET",
		   url: url,
		   data: "type="+type+"&value="+value,
		   dataType:"html",
		   success:function(msg){
			  //alert(msg);
		   		$("#"+AjaxID).html(msg);
		   }
	})
}

function ajaxvote(url,type,value,ajaxid){
	$.ajax({
		type:"GET",
		url:url,
		data: "type="+type+"&value="+value,
		dateType:"html",
		success:function(msg){
			//alert(msg)
			var r=msg.split(",");
            if(r[0] == "Dig" ){
                alert("您已经投过票了不能再投了！");
				$("#"+ajaxid).html(r[1]);
            }else if(msg == "NoData"){
				alert("参数错误！");
			}else{
				$("#"+ajaxid).html(msg);
				alert("投票成功");
            }
		}
	})
}
