﻿function getPosition() {
    var top    = document.documentElement.scrollTop;
    var left   = document.documentElement.scrollLeft;
    var height = document.documentElement.clientHeight;
    var width  = document.documentElement.clientWidth;
    
    return {top:top,left:left,height:height,width:width};
}

function QuickPostion(objID)
{
    var obj = document.getElementById(objID);

    window.onscroll = function (){
        var Position   = getPosition();
            obj.style.top  = (Position.top) + 140  +"px";
            obj.style.right = "6px";
    };
}



// *** Cookies ***

function setCookie(name,value)
{
    var Days = 1;
    var exp  = new Date();    //new Date("December 31, 9998");
        exp.setTime(exp.getTime() + Days*24*60*60*1000);
        document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString() + "; path=/"; 
}
function getCookie(name)
{
    var arr,reg=new RegExp("(^| )"+name+"=([^;]*)(;|$)");
        if(arr=document.cookie.match(reg)) return unescape(arr[2]);
        else return null;
}
function delCookie(name)
{
    var exp = new Date();
        exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
        if(cval!=null) document.cookie= name + "="+cval+";expires="+exp.toGMTString();
}



// *** 地址重组 ***
function GetThisAllRequest()
{
	var url =window.location.search; //获取url中"?"符后的字串
	var thisquest="";
	if(url.indexOf("?") != -1)
	{ 
	    thisquest=url.slice(1);
	}
	return thisquest;
}


function GetUserID()
{
	var url =window.location.search; //获取url中"?"符后的字串
	var thisquest="";
	if(url.indexOf("/?") && url.indexOf("=") == -1)
	{ 
	    thisquest=url.slice(1);
	}
	return thisquest;
}


function GetThisRequest(rename)
{
	var url =window.location.search; //获取url中"?"符后的字串
	var thisquest="";
	if(url.indexOf("?") != -1)
	{ 
	  var str = url.slice(1);
	  strs = str.split("&");
	  for(var i = 0; i < strs.length; i ++){
			if (rename==strs[i].split("=")[0]){
			    thisquest=unescape(strs[i].split("=")[1]);
			}
	  }
	}
	return thisquest;
}



//document.write(GetUserID());

Promotion()

function Promotion()
{
    var SiteUrl=window.location.hostname;
    
    if(GetUserID().length>0){
        var UserID=GetUserID();
    }else{
        var UserID=GetThisRequest('UserID');
    }
    

    var PID=GetThisRequest('id');
    var UID=GetThisRequest('UserID');
    
    if( PID && UID ){
        var testme=getCookie('Promotion_PID');
        if(testme!==null){
           if(testme.indexOf(","+PID+",")==-1){
                setCookie('Promotion_PID',testme+PID+"," );
           }
        }else{
             setCookie('Promotion_PID',","+PID+",");
        }
    }

//    if(PID){
//        setCookie('Promotion_PID',PID);
//    }
    
    if(UserID){
        setCookie('Promotion_UserID',UserID);
    }else{
        setCookie('Promotion_UserID',"");
    }
    
    if(SiteUrl){
        setCookie('Promotion_SiteUrl',SiteUrl);
    }else{
        setCookie('Promotion_SiteUrl',"");
    }
}



function setCopy(_sTxt){try{clipboardData.setData('Text',_sTxt)}catch(e){}}