function toggleObj(togObj,plus){
	$(togObj).slideToggle(300);
	if($(plus).attr('src')=='image/spread.gif'){
		$(plus).attr('src','image/shrink.gif');
	}else{
		$(plus).attr('src','image/spread.gif');
	}
}

function showPreview(val, id) {
	var showObj = $ID(id);
	if(typeof showObj == 'object') {
		val = val.replace(/ /ig, "&nbsp;");
		showObj.innerHTML = val.replace(/\r\n/ig, "<br />");
	}
}

function $ID(id) {
	return document.getElementById(id);
}

function OBJ(id) {
	return document.getElementById(id);
}

function MsgDiv(title,content,dragAbl,msgW,msgH){
	var userAgent = navigator.userAgent.toLowerCase();
	var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
	var is_moz = (navigator.product == 'Gecko') && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
	var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);

	var MsgObj = $ID("msg_drag");
	var HTMLmsg,H,W;
	 if(is_ie){
	 	 W = document.body.clientWidth; H = document.body.clientHeight;
	 }else if(is_moz){
	 	 W = document.body.scrollWidth; H = document.body.scrollHeight;		 	 
	 }
	 //alert(document.body.scrollLeft   +" w："+W);
	//半透明背景
	var div = document.createElement("div");
	div.id = "MsgBak";
	document.body.appendChild(div);
	 $ID('MsgBak').style.width = W + "px";
	 $ID('MsgBak').style.height = H + "px";
	 $ID('MsgBak').className = "MsgBak";
	 $ID('MsgBak').style.visibility="visible";
	 //alert($ID('MsgBak').style.width);

	if(MsgObj){
		$('#msg_drag').slideToggle(200);
	}else{
		 var div = document.createElement("div"); 
		 div.id = "msg_drag"; 
		 div.className = "drag"; 
		 div.style.left = Math.max((W - 800)/2) + "px";
		 div.style.top = Math.max((H - 300)/2) + "px";
		 document.body.appendChild(div);
		 MsgObj = div;
	}
	if($ID(content)){
		HTMLmsg = $ID(content).innerHTML;
	}else{
		HTMLmsg = content;
	}
	MsgObj.innerHTML = '<div id="contain" class="contain"><div id="dtit" class="dlgtit"><div id="tl"></div><div id="tc"><div id="tt">'+ title +'</div></div><div id="tr"></div><div id="xbtn" onclick="closeMWin();"></div></div>'+
		'<div id="dinner" class="dlginner">'+ HTMLmsg +'<br></div><div id="dfoot" class="dlgfoot"><div id="bl"></div><div id="bc"></div><div id="br"></div>'+
		'<div id="cbtn" style="visibility:hiddens;" onclick="closeMWin();"><span>关 闭</span></div><div id="obtn" style="visibility:hidden;" onclick="ok();"><span>确 定</span></div>'+
		'</div></div>';	
	if(msgW){$ID('dinner').style.width = msgW - 12 + "px";MsgObj.style.width = msgW + "px";MsgObj.style.left=Math.max((W - msgW)/2) + "px";}//自定义宽度
	if(msgH){$ID('dinner').style.height = msgH - 30 + "px";MsgObj.style.height = msgH + "px";MsgObj.style.top=Math.max((H - msgH)/2) + "px";}//自定义高度
	$ID('cbtn').onmouseout = $ID('obtn').onmouseout = $ID('xbtn').onmouseout = function(){ this.style.backgroundPosition = '0 0'; };
	$ID('obtn').onmouseover = $ID('cbtn').onmouseover = function(){ this.style.backgroundPosition = '0 -21px'; };
	$ID('xbtn').onmouseover = function(){ this.style.backgroundPosition = '0 -19px'; };
 	if(dragAbl){drag(MsgObj,$ID('dtit'));}
}

function closeMWin(){
  $('#msg_drag').slideToggle(200);
   document.body.removeChild($ID('MsgBak'));
   return false;
}

function drag(o,ot){
 ot.onmousedown=function(a){
  var d=document;if(!a)a=window.event;
  var x=a.layerX?a.layerX:a.offsetX,y=a.layerY?a.layerY:a.offsetY;
  if(ot.setCapture)
   o.setCapture();
  else if(window.captureEvents)
   window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);

  d.onmousemove=function(a){
   if(!a)a=window.event;
   if(!a.pageX)a.pageX=a.clientX;
   if(!a.pageY)a.pageY=a.clientY;
   var tx=a.pageX-x,ty=a.pageY-y;
   o.style.left=tx;
   o.style.top=ty;
  };

  d.onmouseup=function(){
   if(o.releaseCapture)
    o.releaseCapture();
   else if(window.captureEvents)
    window.captureEvents(Event.MOUSEMOVE|Event.MOUSEUP);
   d.onmousemove=null;
   d.onmouseup=null;
  };
 };
}

function showflashimg(url,width,height,images,links,texts){
	var borderwidth = width + 2;
	var borderheight = height + 2;
	if(!links){links='';}
	if(!texts){texts='';}
	var str = '';
	str += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,9,0" width="'+ width +'" height="'+ height +'">';
	str += '<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="'+url+'"><param name="quality" value="high"><param name="bgcolor" value="#ffffff">';
	str += '<param name="menu" value="false"><param name=wmode value="opaque">';
	str += '<param name="FlashVars" value="pics='+images+'&amp;links='+links+'&amp;texts='+texts+'&amp;borderwidth='+borderwidth+'&amp;borderheight='+borderheight+'&amp;textheight=0">';
	str += '<embed src="'+url+'" wmode="opaque" FlashVars="pics='+images+'&amp;links='+links+'&amp;texts='+texts+'&amp;borderwidth='+borderwidth+'&amp;borderheight='+borderheight+'&amp;textheight=0" menu="false" bgcolor="#ffffff" quality="high" width="'+ width +'" height="'+ height +'" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	str += '</object>';
	document.write(str);
}
			
//iframe包含
if (top.location != location) {
	top.location.href = location.href;
}
function redirect(url){
	window.location.replace(url);		
}
function Copyval(id){
	var val = $('#'+id).val();
	var temp = "微众会员招募:\n快快加入微众轻松实现网上赚钱！"+"\n"+val;
	if(window.clipboardData) {		
		var ok=window.clipboardData.setData("Text",temp);
		if(ok) alert("微众提醒你:\n网址"+val+"\n已经复制到您的剪贴板中\n您可以使用Ctrl + V ,粘贴到MSN或QQ上发给你的好友们吧 ！");
	} else {
		prompt("请手工复制网站地址:",val); 
	}
}
var forward = true;					
var speed = 10;
var delta = 1;
function Move(){
	var sv = document.getElementById('bulletindemo');
	var sv1 = document.getElementById('bulletindemo1');
	var sv2 = document.getElementById('bulletindemo2');
	if(forward)	{
		if(sv.scrollLeft + delta - sv1.offsetWidth-3 >=0){
			sv.scrollLeft = 0;
		}else{
			sv.scrollLeft = sv.scrollLeft+delta;
		}													
	}else{
		if(sv.scrollLeft - delta <= 0){
			sv.scrollLeft += sv1.offsetWidth+3;
		}else{
			sv.scrollLeft -= delta;
		}
	}
}										
function MoveStart(){
	clearInterval(bulletMyMar)
	bulletMyMar=setInterval(Move,speed);
}			
function MoveLeft(){					
	forward=true;	
	MoveStart();					
}
function MoveRight(){
	forward=false;
	MoveStart();					
}
function RequiredFiedValidate(controlId){
	var control = document.getElementById(controlId);
	if(control.value == "")	{
		control.select();
		return false;
	}else{
		return true;
	}
}
function RegularEmailValidate(controlId){
	var control = document.getElementById(controlId);
	var s = control.value;
	var patrn=/^([0-9a-zA-Z]([-.\w\+]*[0-9a-zA-Z_-])*@([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$/;
	if (!patrn.exec(s))	{
		control.select();
		control.focus();
		return false;
	}
	return true;
}
function CompareValidate(controlId1,controlId2)
{
	var control1 = document.getElementById(controlId1);
	var control2 = document.getElementById(controlId2);
	if(control1.value == control2.value){
		return true;
	}else{
		control2.select();
		control2.focus();
		return false;
	}
}
function showpao(id){
	msg = $(id).attr('msg');
	$(id)
	.qtip({
	   content: msg,
	   position: {
		  corner: {
			 tooltip: 'leftBottom',
			 target: 'topMiddle' 
		  }
	   },
	   show: {
		  when: false,
		  ready: true
	   },
	   hide:{focus:true},
	   style: {
		  border: {
			 width: 1,
			 radius: 2
		  },
		  padding: 5, 
		  textAlign: 'left',
		  tip: true,
		  name: 'blue'
	   }
	});	
}

Date.prototype.format = function(format)   
{   
   var o = {   
     "M+" : this.getMonth()+1, //month   
     "d+" : this.getDate(),    //day   
     "h+" : this.getHours(),   //hour   
     "m+" : this.getMinutes(), //minute   
     "s+" : this.getSeconds(), //second   
     "q+" : Math.floor((this.getMonth()+3)/3), //quarter   
     "S" : this.getMilliseconds() //millisecond   
   }   
   if(/(y+)/.test(format)) format=format.replace(RegExp.$1,   
     (this.getFullYear()+"").substr(4 - RegExp.$1.length));   
   for(var k in o)if(new RegExp("("+ k +")").test(format))   
     format = format.replace(RegExp.$1,   
       RegExp.$1.length==1 ? o[k] :    
         ("00"+ o[k]).substr((""+ o[k]).length));   
   return format;   
} 