﻿var _isIe = navigator.appName == "Microsoft Internet Explorer" ? true : false;
function copyText(id) {
	try{
		var targetText = document.getElementById(id);
		targetText.focus();
		targetText.select();
		var clipeText = targetText.createTextRange();
		clipeText.execCommand("Copy");
	}catch(e){}
}

function fontList(objName){
	document.write('<select name="'+objName+'" style="width:110px;"><option value="04b_08" >04b_08</option><option value="04b_09" selected>04b_09</option><option value="04b_11" >04b_11</option><option value="04b_20" >04b_20</option><option value="04b_21" >04b_21</option><option value="04b_25" >04b_25</option><option value="Arial">Arial</option><option value="Arial Black">Arial Black</option><option value="Courier">Courier</option><option value="Script">Script</option></select>')
}

function fontSizeList(objName){
document.write('<select name="'+objName+'"><option value="5" selected>5</option><option value="6">6</option><option value="9">7</option><option value="11">8</option><option value="12">9</option><option value="13">10</option><option value="14">11</option><option value="15">12</option><option value="17">13</option><option value="20">14</option><option value="23">16</option><option value="26">18</option></select>')
}

function sortsList(objName){
document.write('<select name="'+objName+'"><option value="0">选择分类</option><option value="1">动物</option><option value="2">风景</option><option value="3">卡通</option><option value="4">人物</option><option value="5">物件</option><option value="6">美女</option><option value="7">艺术</option><option value="8">IT类</option></select>');
}

function YahooKeys(url){
	return URLDecode(url.split(':')[4]);
}

function YahooLink(url){
	
	endIndex=url.lastIndexOf("&");
	url=url.substring(0,endIndex); 
	//url = url.substring(0，6)+'.htm';
	return url+'.htm';
}

function OpenWin(theURL,w,h){
	 window.open(theURL,'','left=100,top=100,width='+w+',height='+h+',resizable=1,scrollbars=1, status=1, toolbar=0, menubar=0');
}

function createDomDoc(){        
    if(_isIe){
        var signatures=["Msxml2.DOMDocument.5.0","Msxml2.DOMDocument.4.0","Msxml2.DOMDocument.3.0","Msxml2.DOMDocument","Microsoft.XmlDom"];
        for(var i=0;i<signatures.length;i++){try{ this.domDoc=new ActiveXObject(signatures[i]);return this.domDoc;}catch(e){}}
        return null;
    }
    else
    {
        return document.implementation.createDocument("","",null);
    }
}

function GetAttributeText(allXML,textName){
	var obj=allXML.getAttribute(textName);
	if (obj)return obj;
	else return "";
}

function clickIco(obj,bt){
	if(bt.value==0){
		bt.value=1;
		obj.style.border = '1px solid #000000';
	}else{
		bt.value=0;
		obj.style.border = '1px solid #FFFFFF';
	}
}

function showNum(obj){
	var num = obj.value;
	if(num==1){
		$('#today').hide(); $('#yesterday').hide(); $('#total').show();
	}
	if(num==2){
		$('#today').show(); $('#yesterday').hide(); $('#total').show();
	}
	if(num==3){
		$('#today').show(); $('#yesterday').show(); $('#total').show();
	}
	
}

function ShowDialog(url, width, height, frmField) {
	var obj = eval('myForm1.'+frmField)
	var obj2 =new Object();
	obj2.color='#'+obj.value;
	var tmp = showModalDialog(url, obj2, "dialogWidth:" + width + "px;dialogHeight:" + height + "px;help:no;scroll:no;status:no")
	if (tmp)obj.value=tmp.substr(1,6) ;
}

function logout(){
	if(confirm('确定要退出吗？')){
		$.post('dofrom.aspx', { act: 103}, function(code) {
			if(code==2){
			window.location='http://mall.alisoft.com/apps/mysoft/mySoft!show.jspa';}else{window.location='default.aspx';}
		});
	}
}

function getMousePostion(){
    var obj = document.getElementById('postionX');
    if(obj != null)
        obj.value = event.offsetX+1;
    
    obj = document.getElementById('postionY');
    if(obj != null)
        obj.value = event.offsetY+1;
}

function increase(obj){obj.value=Number(obj.value)+1;}
function decrease(obj){obj.value=Number(obj.value)-1;}

function selectskin(){
	jBox.open('iframe-jBoxID','iframe','selectskin.aspx','选择计数器式样','width=562,height=360,center=true,minimizable=false,resize=false,draggable=false,model=false,scrolling=false');
}

function auditskin(gid){
	var skin = $('#link_'+gid);
	skin.html('<a>请稍后..</a>');
	$.post('dofrom.aspx', { act: 501, skinid : gid }, function(code) {
		if(code==1){
			alert('恭喜您计数器已经通过审核！');
			skin.html('<a>已审核</a>');
		}else if(code==-2){
			alert('等级不够自助审核，请联系客户帮您审核!');
			skin.html('<a>未审核</a>');
		}
		else{
			alert('等级不够自助审核，请联系客户帮您审核!');
			skin.html('<a>审核失败</a>');
		}
	});
}

function favskin(gid){
	var skin = $('#link_'+gid);
	skin.html('请稍后..');
	$.post('dofrom.aspx', { act: 502, skinid : gid }, function(code) {
		if(code==1){
			skin.html('收藏成功');
		}else{
			skin.html('收藏');
			if(code==0){
				alert('该计数器式样您已经收藏过了！');
			}else if(code==2){
				alert('您的个人收藏夹已经满了，最多收藏30个，请删除一些！');
			}else{
				alert('您还没有登录，请先登录');window.location='login.aspx';
			}
		}
	});
}

function delfavskin(gid){
	var skin = $('#link_'+gid);
	skin.html('请稍后..');
	$.post('dofrom.aspx', { act: 503, skinid : gid }, function(code) {
		if(code==1){
			$('#item'+gid).hide();
		}else{
			skin.html('移除失败');
		}
	});
}

function taobaopage(str){
	str = str.replace('http://auction1.taobao.com/auction', '');
	str = str.replace('http://item.taobao.com/auction','');
	str = str.replace('http://store.taobao.com/shop','');
	str = str.replace('http://shop.mall.taobao.com','');
	return str;
}

function selectDate(iYear,iMonth,iDay){
	yearID=iYear;
	monthID=iMonth;
	dayID=iDay;
	page=1;
	RequestFlashAJAX();
}

function listPageNumLink(){
	var str='';
	for(i=1;i<1+parseInt(totalPage);i++){
		if(page==i){
		    str=str+'<li class="active">'+i+'</li>';
		}else{
		    str=str+'<li><a href="javascript://" onclick="page='+i+';RequestFlashAJAX();">'+i+'</a></li>';
		}
	}
	$('#pagination-flickr').show();
	$("#pagination-flickr").html(str);
}

function RequestCallback(){

    var objXml = null;
    var xmlDoc = null;
    var Elements = 0;
    var Count = 0;
    xmlDoc = createDomDoc();
    xmlDoc.async = false;
    xmlDoc.loadXML(flashAJAX.getFlash().GetVariable("retText"));
    
    objXml = xmlDoc;
	xmlDoc = null;
    Elements = objXml.getElementsByTagName("v");
    Count = Elements.length;
    
    for(i=0;i<Count;i++){
		iList[i]=GetAttributeText(Elements[i],"i");aList[i]=GetAttributeText(Elements[i],"a");nList[i]=GetAttributeText(Elements[i],"n");tList[i]=GetAttributeText(Elements[i],"t");
	}
	
	if(Count/pageSize>parseInt(Count/pageSize))
		totalPage=parseInt(Count/pageSize)+1;
	else
		totalPage=parseInt(Count/pageSize);
	
    if (page > totalPage) page = totalPage;
    if (page < 1) page = 1;
    
	var i = pageSize*(page-1);
	
	var str = '';
	if(vip==3) str +='<table width="100%" class="jstable">';
	else str +='<table width="100%">';
	str +='<thead><tr><th class="th1" colspan="4"><span style="float:left">受访页面('+yearID+'-'+monthID+'-'+dayID+')</span><span style="float:right">总页面数:'+Count+'</span></th></tr><tr class="odd">';
	str += '<th width="45%" class="all_left"><strong>受访页面</strong></th>';
	if(vip==3)str += '<th width="10%"><strong>关键词</strong></th>';
	str += '<th width="10%"><strong>时间</strong></th><th width="13%"><strong>IP</strong></th><th width="20%"><strong>来自的地区</strong></th></tr></thead>';
	var s = Count - 1;
	while(i<Count && i<pageSize*page){
	   
	   str=str+'<tr>';
	   str=str+'<td class="num4">';
	   if(vip==3){
		   str=str+'<a href="' + YahooLink(nList[s-i]) + '" target="_blank">' + taobaopage(nList[s-i]) + '</a></td>';
	   }else{
		   str=str+'<a href="' + nList[s-i] + '" target="_blank">' + taobaopage(nList[s-i]) + '</a></td>';
	   }
	   if(vip==3)str=str+'<td class="key">' + YahooKeys(nList[s-i]) + '</td>';
	   str=str+'<td class="num5">' + tList[s-i] + '</td>';
	   str=str+'<td class="num5">' + iList[s-i] + '</td>';
	   str=str+'<td class="num3">' + aList[s-i] + '</td>';
	   str=str+'</tr>';
	   
	   i++;
	}
	str=str+'</table>';
	objXml = null;

	$('#fromPagelist').show();
    $('#loading').hide();
    $('#fromPagelist').html(str);
    
    listPageNumLink();
}