lv_prg = new Array('','http://www.oncity.cc/ava/im_index.php?','http://www.oncity.cc/ava/avatar/index.php?','http://www.oncity.cc/ava/home/home.php?type=shop','http://www.oncity.cc/ava/music/index.php?','http://www.oncity.cc/ava/photo.php','http://www.oncity.cc/ava/home/home.php?type=modi','http://www.oncity.cc/ava/exchange/index.php?','http://www.oncity.cc/ava/game/index.php?','http://www.oncity.cc/ava/usercard/index.php?');
my_friend_str = '';
var oo_online = new Array();
var oo_nickList = new Array();

function show_my_friend(s) {
	if(my_friend_str!='') {
		document.writeln(s);
	}
}

function defaul_home(){
	this.home.style.behavior='url(#default#homepage)';this.home.setHomePage('http://www.oncity.cc');
}
var focusok=false;
if (navigator.appName == "Netscape"){
	focusok=true;
}
vers=navigator.appVersion;
if (navigator.appName == "Microsoft Internet Explorer"){
 pos=vers.lastIndexOf('.'); 
 vers=vers.substring(pos-1,vers.length); 
}
proper_version=parseFloat(vers); 

if(proper_version>=5){
	focusok=true;
}


function openNewWindow(fileName,windowName,theWidth,theHeight)
 {
	if (windowName == "newMessageWindow") 
	{
		uniqueName = new Date();
		windowName = uniqueName.getTime();
	}
window.open(fileName,windowName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,width="+theWidth+",height="+theHeight)
}


function createWindow(cUrl,cName,cFeatures) {
	var xWin = window.open(cUrl,cName,cFeatures);
}

function u(cName) {
	open_im(cName,'');
}
function newpost(url) {
	createWindow(url,'newpost','scrollbars=yes,resizable=no,width=580,height=390');
}

function send(url) {
	centerPopup( 'http://www.oncity.cc/main/message.php?'+url , "send", 658, 373, "no" );
}

function sms_user_send(url) {
	centerPopup('http://sms.oncity.cc/sms_chat.php?'+url, '_blank',443,293,'no');
}

function sms_myself() {
	centerPopup('http://sms.oncity.cc/sms_chat.php', 'sms_myself',443,433,'no');
}

function send1(url) {
	createWindow('http://www.oncity.cc/message_send.jsp?'+url,'send','scrollbars=yes,resizable=no,width=480,height=320');
}

function open_player(htmlurl,r){
	newwin=window.open("http://music.oncity.cc/player.php?"+htmlurl,"oncity_song","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=381,height=498");
	newwin.focus();
}

function add_icon(id) {
	centerPopup( 'http://bbs.oncity.cc/user_icon.php?add_icon='+id , "add_icon", 100, 50, "no");
}

function open_im(name,d,prg) {
	
	if(d==undefined) {
		d='';
	}

	if(prg==undefined) {
		prg='';
	} else {
		prg=escape(prg);
	}

	if(d=='photo') { 
		window.open('http://im.oncity.cc/main.php?name='+name+'&d='+d+'&p='+prg,'_blank','');
	} else {
		window.open('http://im.oncity.cc/main.php?name='+name+'&d='+d+'&p='+prg,'_blank','width=950,height=628,top=30,left=60,resizable=no,status=no,toolbar=no,scrollbars=no,menubar=no,location=no');
	}
}

function flist(url) {
	if(url==undefined) {
		open_im('','u_friend');
	} else {
		createWindow('http://im.oncity.cc/show_friend.php?type=add&close=1&u_'+url,'flist','scrollbars=no,resizable=no,width=350,height=260');
	}
}


function flist_add(name) {
	createWindow('http://www.oncity.cc/myinfo/flist.jsp?name='+name,'flist','scrollbars=yes,resizable=no,width=195,height=320');
}

function open_note() {
//	createWindow('http://www.oncity.cc/myinfo/tools/my_note.jsp','my_note','scrollbars=no,resizable=no,width=370,height=270');
	open_im('','u_notepad');
}

function open_fav() {
	createWindow('http://www.oncity.cc/myinfo/tools/bookmark.jsp','my_bookmark','scrollbars=no,resizable=no,width=450,height=320');
}

function open_comm() {
	createWindow('http://www.oncity.cc/myinfo/tools/comm.jsp','my_comm','scrollbars=yes,resizable=no,width=450,height=320');
}

function sms() {
	createWindow('http://www.oncity.cc/sms/','sms','scrollbars=yes,resizable=no,width=450,height=250');
}


function open_reg(url) {
	window.open(url,'Register','status=0,menubar=0,toolbar=0,height=435,width=600,left=120,top=80');
}


function ask(msg) {
	
	if( msg=='' ) {
		msg='真的要这样做吗？';
	}

	if (confirm(msg)) {
		return true;
	} else {
		return false;
	}
}

function ask_url(title,url) {
	if (confirm(title)) {
		this.location=url;
	}
}

function sendform()
{
	var strchoice="";
	for(var i=0;i<document.srhform.mid.length;i++)	{
		if (document.srhform.mid[i].checked){
			strchoice=strchoice+document.srhform.mid[i].value+",";
		}
	}
	if (!document.srhform.mid.length)	{
		if (document.srhform.mid.checked)	{
			strchoice=document.srhform.mid.value+",";
		}

	}
	strchoice=strchoice.substring(0,strchoice.length-1);
	document.srhform.delete_list.value=strchoice;
	return false;
}

function unselectall()
{
    if(document.srhform.all.checked){
	document.srhform.all.checked = document.srhform.all.checked&0;
    } 	
}
function selectall()
{
    var length = document.srhform.mid.length;

    document.srhform.all.checked = document.srhform.all.checked|0;
    if (length == 0 ){
          return;
    }

	if (length ==undefined) document.srhform.mid.checked =document.srhform.all.checked;

    if (length ==1 )
    {
       document.srhform.mid.checked=document.srhform.all.checked;
    }
    if (length>1)
    {
      for (var i = 0; i < length; i++)
       {
        document.srhform.mid[i].checked=document.srhform.all.checked;         
       }
    }

}
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


function chatlogin(port) {	
	createWindow('http://www.oncity.cc/chatjoin2.jsp?port='+port,'chat','width=790,height=545,toolbar=no,top=0,left=0,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes');
}

function bbsopen(url) {	
	createWindow(url,'bbs','width=790,height=545,toolbar=no,top=0,left=0,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes');
}

function bbsopen2(cid) {	
	if(cid>0) {
		createWindow('bbs.jsp?cid='+cid,'_blank','');
	}
}


function getdate()
{
	var todayx=new Date();
	yearx=todayx.getYear();
	
	monthx=todayx.getMonth()+1;
	dayx=todayx.getDate();
	if (monthx <= 9) {monthx="0" + monthx;}
	if (dayx <=9) {dayx="0" + dayx;}
	
	datex="_"+yearx+"_"+monthx+"_"+dayx;
	return datex;
}

function gostar2(starx)
{
	url="http://appastro.qq.com/cgi-bin/astro_qq_luck?type=day&astro="+starx;
	window.open(url,"","width=185,height=450");
	return false;
}

function random(number) {
	return Math.floor(Math.random() * number);
}


function open_win2(url,wn,w,h){
	NewWindow(url,wn,w,h,'no');
}

function NewWindow(mypage,myname,w,h,scroll){
	LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-h)/2 - 20 : 0;
	settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll;
	win = window.open(mypage,myname,settings)
}

function opentown() {
	open_win2('http://www.oncity.cc/newtown/index3.php','oncity_town_win',740,488);
}

function opentown2(map_id, msg) {
	if(confirm(msg)){
		open_win2('http://www.oncity.cc/newtown/index3.php?map_id='+map_id,'oncity_town_win',740,488);
	}
}

function openworld() {
	centerPopup('http://www.oncity.cc/world/index.php','citywindow',800,545);
}


function centerPopup(mypage, myname, w, h, scroll) { 
	var winl = (screen.width - w) / 2; 
	var wint = (screen.height - h) / 2 -20; 
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no,toolbar=no' 
	win = window.open(mypage, myname, winprops) 
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); } 
}

function show_home_shop() {
	centerPopup('http://www.oncity.cc/world/furniture_shop.php', 'home_shop', 800, 534, 'no');
}

function show_home(name) {
	centerPopup('http://www.oncity.cc/world/home.php?name='+name, 'home_show', 800, 526, 'no');
}


function ShowFooter(name)
{
	document.write('<BR><BR>');
}

function search( str,search_range ){
	if( str.length >= 2 ) {
		var ss = "http://61.142.80.168:8088/search?dir="+search_range+"&q="+str+"&start=0&num=10&index=FullIndex&outputFormat=HTML&encoding=GBK&orderStyle=DocID" ;
		open( ss,"_blank" ) ;
	}else{
		alert( "搜索内容最少要2字符" ) ;
	}
}

function header2() {

	var snect = "<table height=34 cellspacing=0 cellpadding=0 width=100% background=http://ktv.oncity.cc/images/sc_bg.gif border=0>"+
				"<tr><td width=90><img height=34 src=http://ktv.oncity.cc/images/sc_logo.gif width=150 border=0></td>"+
				"<td>&nbsp; </td></tr></table>" ;
	document.writeln(snect);
}

function user_ava_flash(param) {
	
	swf="http://img3.oncity.cc/face.swf";
	w=0;h=0;
	w0=150;	h0=180;
	param1='';param2='';style_param='';
	quality='low';
	scale='scale';

	var p_array = param.split(";");
	
	for (i=0; i < p_array.length; i++) {
		var sl=p_array[i].split("=");
		if(sl.length==2) {
			switch(sl[0]) {
				case "head":
					if(sl[1]=='yes') {
						swf="http://img3.oncity.cc/head.swf";
						w0=60;
						h0=60;
					}
					break;
				case "bbs":
					if(sl[1]=='yes') {
						swf="http://img3.oncity.cc/head_bbs.swf";
					}
					break;
				case "code":
					param1=param1+'&s='+sl[1];
					break;
				case "name":
					param1=param1+'&b='+sl[1];
					break;
				case "quality":
					quality=sl[1];
					break;
				case "scale":
					scale=sl[1];
					break;
				case "bg":
					if(sl[1]=='yes') {
						param1=param1+'&bg=1';
					}
					break;
				case 'border':
					if(sl[1]=='yes') {
						color="solid Black";
					} else {
						color=sl[1];
					}
					style_param='style="border :1px '+color+';"';
					break;
				case 'w':
					w=sl[1];
					break;
				case 'h':
					h=sl[1];
					break;
			}
		}
	}
	
//	swf=swf+'?'+param1;
	if(w && h) {
	} else {
		w=w0;
		h=h0;
	}
	s='<OBJECT classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" WIDTH='+w+' HEIGHT='+h+' '+style_param+'><param name="scale" value='+scale+'><PARAM NAME=allowscriptaccess VALUE=always><PARAM NAME=movie VALUE='+swf+'><param name="FlashVars" value="'+param1+'"><PARAM NAME=wmode VALUE=transparent><PARAM NAME=quality VALUE='+quality+'><PARAM NAME=bgcolor VALUE=#FFFFFF><EMBED scale='+scale+' FlashVars='+param1+' wmode=transparent src='+swf+' quality='+quality+' bgcolor=#FFFFFF WIDTH='+w+' HEIGHT='+h+' TYPE="application/x-shockwave-flash" PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer" allowscriptaccess=always '+style_param+'></EMBED></OBJECT>';
	document.write(s);
}




function comment_reply(reply_id,comment_id) {
	var title=window.prompt("请输入回复的内容(100字以内):","");
	if(title!=null) {
		var n=title.length;
		if( n==0 || n>100) {
			alert('回复内空不能为空或大于100个字，请重填.');
		} else {
			this.location.href='http://hompy.oncity.cc/comment.php?type=reply&comment_id='+comment_id+'&reply_id='+reply_id+'&about='+title;
		}
	}
}

function bbs_send2friend(id,where_name) {
	var title=window.prompt("请输入推荐的好友名单，多个好友请使用半角的“,”进行分隔","");
	if(title!=null) {
		var pattern=/，/;
		var result=pattern.test(title);
		this.location.href="javascript:open_win2('http://im.oncity.cc/report2.php?id="+id+"&name="+title+"&where="+where_name+"&send2friend=1','推荐到精华',50,50)";
	}
}


function copyToClp(obj){
	 if (obj.type == "text" || obj.type == "textarea"){
			 var oControlRange = obj.createTextRange();
	 }else{
			 var oControlRange = document.body.createTextRange();
	   oControlRange.moveToElementText(obj);
	  }
	oControlRange.execCommand("copy");
	alert('已复制连接到粘贴版.');
}

function copyToClipBoard(url){
 window.clipboardData.setData("Text",url); 
 alert("复制成功，请在需要粘贴的地方点鼠标右键选粘贴");
}

function go_shop(shop_id,goods_id){
	window.location=lv_prg[shop_id]+'&show_id='+goods_id;	
}

function go_ava_show(id) {
	this.location='http://hompy.oncity.cc/ava_show.php?id='+id;
}

function sel_unall()
{
    if(document.f.all.checked){
		document.f.all.checked = false;
    } 	
}
function sel_all() {
 var chkcount = 0;
	 for(var i=0;i < document.f.sel_id.length;i++)
	 {
		document.f.sel_id[i].checked=document.f.all.checked; 
	 }

}

function sel_submit() {
 var ids='';
 var c_size=document.f.sel_id.length;
	if(c_size!=undefined) {
	 for(var i=0;i < document.f.sel_id.length;i++)
	 {
		if(document.f.sel_id[i].checked==true) 
		{
		   if(ids) ids=ids+',';
		   ids=ids+document.f.sel_id[i].value;
		} 
	 }
	} else {
		if( f.sel_id.checked==true ) ids=f.sel_id.value;
	}

	 if(ids=='') { 
		 alert('您没有选取任何内容！');
		 return false;
	 } else {
		f.ids.value=ids;
		return true;
	 }
}

function town_go(id) {
	town_b1.location='http://www.oncity.cc/newtown/go.php?go_id='+id;
}

function openNewDiary() {
	openNewWindow('show_diary.php?type=new&popup=1','postDiaryWindows',520,630);
}

function openNewBlog() {
	openNewWindow('show_blog.php?type=new&popup=1','postBlogWindows',520,600);
}

function ShowKeep(title) {
document.write("<a href=\"javascript:d=document;t=d.selection?(d.selection.type!='None'?d.selection.createRange().text:''):(d.getSelection?d.getSelection():'');void(keyit=window.open('http://im.oncity.cc/keep/save_url.php?t='+escape(d.title)+'&u='+escape(d.location.href),'keyit','scrollbars=no,width=480,height=530,left=75,top=20,status=no,resizable=yes'));keyit.focus();\"><font color=#303880>收藏至</font><font color=#FF0000>我的网摘!</font></a>");
}

function add2Keep(title,url) {
	window.open('http://im.oncity.cc/keep/save_url.php?t='+escape(title)+'&u='+escape(url),'_blank','scrollbars=no,width=480,height=530,left=75,top=20,status=yes,resizable=no', 'OnCityKeep');
}

function open_radio_player(){
	var oncity_radio=window.open("http://www.oncity.cc/music/radio_player.php","oncity_radio","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=300,height=465");
	oncity_radio.focus();
}

function show_avatar_box(code) {
	window.open('http://www.oncity.cc/ava/avatar/?t=fg&code='+code,'_blank','', '');
}

function noenter() {
  return !(window.event && window.event.keyCode == 13); 
}

function show_love(id) {
	window.open('http://love.oncity.cc/view.php?id='+id,'_blank','','');
}


//OC js code
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && 
  navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
  document.write('<SCRIPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('Sub msgOpenWinFlash_FSCommand(ByVal command, ByVal args)\n');
  document.write(' call msgOpenWinFlash_DoFSCommand(command, args)\n');
  document.write('end sub\n');
  document.write('</SCRIPT\> \n');
}

function msgOpenWinFlash_DoFSCommand(command, args){
	//alert(command+"---"+args);
	if(command=="alert"){
		alert(args);
	}
}

function open_oc_win(sentTo){
	document.getElementById("msgOpenWinFlash").SetVariable("_root.userName",sentTo);
	document.getElementById("msgOpenWinFlash").GotoFrame(9);
	//return false;
}

function msgOpenWinFlash_code() {
//	document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="0" height="0" id="msgOpenWinFlash"><param name="allowScriptAccess" value="always"/><param name="movie" value="http://www.oncity.cc/msg/msgOpenWin.swf"><param name="quality" value="high"><embed src="http://www.oncity.cc/msg/msgOpenWin.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="0" height="0" name="msgOpenWinFlash" swliveconnect="true" allowScriptAccess="always"></embed></object>');
}


function showWWInfo(style, onlineArr, nickArr, showInline) {

	var onlineMsg  = "点此可以实时与OC网友交流";
	var offlineMsg = "点此可以留言给OC网友";
	
	if (!onlineArr) {
		onlineArr = new Array();
	}
	if (!nickArr) {
		nickArr = new Array();
	}
	if (!style) {
		style = 'Large';
	}
	var onlinePic = 'http://m.oncity.cc/im/ocmsg/msg_boy.gif';
	var offlinePic = 'http://m.oncity.cc/im/ocmsg/msg_off.gif';


	var os = document.getElementsByTagName("span");
	for (var i = 0; i < os.length; ++i) {
		var o = os[i];
		if (o && o.className) {
			var cls = o.className;
			if (cls.indexOf('WWOnline') == 0) {
				var id = cls.substring(8);
				if (onlineArr[id]) {
					o.innerHTML='<a href="javascript:open_oc_win('+"'"+nickArr[id]+"')\"><img src="+onlinePic+' border=0 alt="'+onlineMsg+'" title="'+onlineMsg+'" /></a>';

				}else {
					o.innerHTML='<a href="javascript:send('+"'op=add&name="+nickArr[id]+"')\"><img src="+offlinePic+' border=0 alt="'+offlineMsg+'" title="'+offlineMsg+'" /></a>';
				}

			}
		}
	}
}


function showFriendList() {
	NewWindow("http://im.oncity.cc/friend.php","ocFList",260,500,"yes");
}

function open_oo() {
	window.open('http://www.oncity.cc/msg/main.php','oncity_oo_win','scrollbars=no,width=266,height=420,left=675,top=120,status=no,resizable=no');
}

function dw_box(str) {
	document.write('<table border="0" cellspacing="0" cellpadding="0"><tr><td width="5" height="5"><img src="http://m.oncity.cc/mm/k_01.gif" width="5" height="5"></td><td background="http://m.oncity.cc/mm/k_02.gif"><img src="http://m.oncity.cc/mm/k_02.gif" width="5" height="5"></td><td width="11"><img src="http://m.oncity.cc/mm/k_03.gif" width="11" height="5"></td></tr><tr><td background="http://m.oncity.cc/mm/k_04.gif"><img src="http://m.oncity.cc/mm/k_04.gif" width="5" height="5"></td><td>'+str+'</td><td background="http://m.oncity.cc/mm/k_05.gif"><img src="http://m.oncity.cc/mm/k_05.gif" width="11" height="5"></td></tr><tr><td height="11"><img src="http://m.oncity.cc/mm/k_06.gif" width="5" height="11"></td><td background="http://m.oncity.cc/mm/k_07.gif"><img src="http://m.oncity.cc/mm/k_07.gif" width="5" height="11"></td><td><img src="http://m.oncity.cc/mm/k_08.gif" width="11" height="11"></td></tr></table>');
}


function InsertFlash(name, url, w, h , bgcolor , FlashVars , transparent , style) {


	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,0,0" width="'+ w +'" height="'+ h +'" id="'+ name +'" align="middle" '+ style +'/>';
	str +='<param name="allowScriptAccess" value="always" />';
	str +='<param name="movie" value="'+ url +'" />';
	str +='<param name="menu" value="false" />';
	str +='<param name="quality" value="high" />';
	str +='<param name="FlashVars" value="'+ FlashVars +'" />';
	if (transparent=='yes') { 
		str +='<param name="wmode" value="transparent" />';
		var ss = '';
		ss = ' wmode="transparent" ';
	}

	str +='<param name="bgcolor" value="'+ bgcolor +'" />';
	str +='<embed src="'+ url +'" FlashVars="'+ FlashVars +'" quality="high" bgcolor="'+ bgcolor +'" width="'+ w +'" height="'+ h +'" name="'+ name +'" align="middle" '+ ss +' allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	str +='</object>';

	document.write(str);
}