﻿function browserDetect(){
	var sUA = navigator.userAgent.toLowerCase();
	var sIE = sUA.indexOf("msie");
	var sOpera = sUA.indexOf("opera");
	var sMoz = sUA.indexOf("gecko");
	if (sOpera != -1) return "opera";
	if (sIE != -1){
		nIeVer = parseFloat(sUA.substr(sIE + 5));
		if (nIeVer >= 6) return "ie6";
		else if (nIeVer >= 5.5) return "ie55";
		else if (nIeVer >= 5 ) return "ie5";
	}
	if (sMoz != -1)	return "moz";
	return "other";
};
function isIE()
{
	return browserDetect().indexOf('ie') > -1;
}

var Browser = new Object();
Browser.isIE = window.ActiveXObject ? true : false;
function openDialog(url,name,width,height) 
{
	if(Browser.isIE) 
	{
			window.open(url, name, "Top=100, Left=200, width="+width+",height="+height+",help=off,status=yes,scroll=yes,scrollbars=yes,status=no,modal=yes");
	} 
	else 
	{
		alert("抱歉:您目前不是IE浏览器，请更换到IE浏览器下更改个人头像!");		
	}
}
function getIcon() {
	var ret = window.showModalDialog("http://www.bluecat.net.cn/Common/ImageUp.aspx?u=customFace&s=153600&w=500&h=500",null,"dialogWidth:450px;dialogHeight:200px;");
	//var ret = openDialog('http://localhost/newmedia/newmedia/MyBluecat/PersonalInfo/ChangeFaceImg.aspx?un='+uname,'upicon','440','600');
	if(ret!=undefined) {
		$('faceimg').src  = ret + "?v=" + Math.floor(100 * Math.random() + 1);
		var iIndex = ret.indexOf('customFace');
		//alert(ret.substring(iIndex));
		$('hidface').value = ret.substring(iIndex);
		
	}
}

function getHomeImg() {
	var ret = window.showModalDialog("http://www.bluecat.net.cn/Common/ImageUp.aspx?u=MyBluecatImg&s=2097152&w=1000&h=170",null,"dialogWidth:450px;dialogHeight:200px;");
	//var ret = openDialog('http://localhost/newmedia/newmedia/MyBluecat/PersonalInfo/ChangeFaceImg.aspx?un='+uname,'upicon','440','600');
	if(ret!=undefined) {
		$('homeimg').src  = ret + "?v=" + Math.floor(100 * Math.random() + 1);
		var iIndex = ret.indexOf('Upfile/MyBluecatImg');
		//alert(ret.substring(iIndex));
		$('hidhomeimg').value = ret.substring(iIndex);
		
	}
}

function autoSelect(itm, val){
	var o=$(itm);
	for (i=0;i<o.options.length;i++){
		if(o.options[i].value==val){
			o.selectedIndex = i;
			break;
		}
	}

}
function addoptions(obj,text,val){
	var o=$(obj);
	var opt = document.createElement('OPTION');
	opt.text = text;
	opt.value = val;
	o.options.add(opt, o.length);
}
var maxage=80;
function chgage(){
	var age_f=$("age_from");
	var age_t=$("age_to");
	var cur_t=age_t.value;
	if(age_f.value>=1){
        len = age_f.value;
	}else{  len=1;}

	age_t.length=1;
	for(i=len;i<=maxage;i++){
		addoptions('age_to',i,i);
	}       
	autoSelect('age_to',cur_t);
}

function getSelectvalue(itm){
	var o=$(itm);
	alert(o);
	for (i=0;i<o.options.length;i++){
		alert("aaa");
		//if(o.options[i].selected){
			
		//	return o.options[i].value;
		//	break;
		//}
	}

}


var newWindow = null
function SoCangWinOpener(title,url)
{       
		if (! newWindow || newWindow.closed)
		{
			newWindow = window.open('http://www.bluecat.net.cn/mybluecat/socang/index.aspx?title='+encodeURIComponent(title)+'&url='+encodeURIComponent(url)+'&f=D1_C','PostBookmark','scrollbars=yes,width=780,height=555,left=80,top=80,status=yes,resizable=yes');
		}
		else
		{
			newWindow.focus();
		}
}

function SearchTagWinOpen(stag,tagcon)
{       
	//var url='http://localhost/newmedia/newmedia/Search/Tag/'+stag+'/t/'+encodeURIComponent(tagcon)+'/1';
	//alert(url);
	window.open('http://www.bluecat.net.cn/Search/Tag/'+stag+'/t/'+escape(tagcon)+'/1','');
		
}

function SearchWinOpen(key1,key2,tagcon,pageindex)
{       
	//var url='http://localhost/newmedia/newmedia/Search/Tag/'+stag+'/t/'+encodeURIComponent(tagcon)+'/1';
	//alert(url);
	if(pageindex==null || pageindex=="" || pageindex==0)
	{
		pageindex=1;
	}
	//alert("aaa");
	window.location.href='http://www.bluecat.net.cn/Search/Tag/'+key1+'/'+key2+'/'+escape(tagcon)+'/'+pageindex;
		
}

//去左空格; 
function ltrim(s){ 
	return s.replace( /^\s*/, ""); 
} 
//去右空格; 
function rtrim(s){ 
	return s.replace( /\s*$/, ""); 
} 

function $(objid){ 
	return document.getElementById(objid);
}