function YoudayQueryString(qs){ 
    var s = location.href; 
    s = s.replace("?","?&").split("&"); 
    var re = null; 
    for(i=1;i<s.length;i++) 
       if(s[i].indexOf(qs+"=")==0) 
           re = s[i].replace(qs+"=",""); 
    return re; 
}

function GetLocationParam(qs){ 
    var s = location.href; 
    s = s.replace("?","?&").split("&"); 
    var re = null; 
    for(i=1;i<s.length;i++) 
       if(s[i].indexOf(qs+"=")==0) 
           re = s[i].replace(qs+"=",""); 
    return re; 
}

var webownerId= YoudayQueryString("webownerId");
if(webownerId == "") webownerId = 10001;
var childid = YoudayQueryString("childid");
if(childid == "") childid = 10000;
var id = YoudayQueryString("id");
var siteurl = GetSiteurl();
var gourl = YoudayQueryString("gourl");

function GetSiteurl(){ 
	var url = YoudayQueryString("siteurl");
	if(url == null) {
	    if(document.referrer){ 
	         url = document.referrer; 
	    } else if(window.opener && window.opener.location){ 
	         try{ 
	              url = window.opener.location.href 
	         }catch(e){ 
	              url = ""; 
	         } 
	    } 
	    if(url=="") 
	         url = "http://"+location.host+location.pathname; 
	    try{ 
	        var re = /http[^\?]+/i; url = url.match(re) 
	    }catch(e){ 
	    } 
	}
    return url; 
} 

function getForwardIndexPage(serviceid) {
	var indexPage = "http://www.520ring.cn?";
	if(serviceid == "100001")
            indexPage = "http://www.520ring.cn?";
    if(serviceid == "100005")
            indexPage = "http://c.3bu.cn/click.jsp?";
        if(serviceid == "100006")
            indexPage = "http://c.3bu.cn/click.jsp?";
        if(serviceid == "100008")
            indexPage = "http://www.iqmofa.cn?";
        if(serviceid == "100010")
            indexPage = "http://www.feichang71.com?";
        if(serviceid == "100011")
            indexPage = "http://c.3bu.cn/click.jsp?";            
        if(serviceid == "100013")
            indexPage = "http://c.3bu.cn/click.jsp?";
        if(serviceid == "100015")
           	indexPage = "http://www.youdayxingzuo.com.cn?";
        if(serviceid == "100016")
           	indexPage = "http://www.u-ker.cn?";	
        if(serviceid == "100018")
           	indexPage = "http://c.3bu.cn/click.jsp?";
        if(serviceid == "100019")
           	indexPage = "http://www.xinqm.com?";        	
        if(serviceid == "100021")
           	indexPage = "http://www.xingmingyun.com?";
        if(serviceid == "100024")
           	indexPage = "http://www.cpmadao.com/?";        
     return indexPage;
}

function ToIndexWindow(serviceid, tj, gopage) {
	var indexPage = "http://c.3bu.cn/click.jsp?";
	if(tj)
		indexPage="http://c.3bu.cn/click.jsp?";
	else {
		indexPage = getForwardIndexPage(serviceid);
	}
	var paras = ['serviceId='+serviceid, 'id='+id, 'webownerId='+webownerId, 'childid='+childid, 'siteurl='+siteurl, 'gopage='+gopage,'gourl='+gourl];
	var args = paras.join('&');
	var urlStr= indexPage + args;
	var t=window.open(urlStr);
	t.focus();
}

function ToYoudayIndexWindow(evt){
	var t=window.open("http://www.youday.cn");
	t.focus();
	var e=(evt)?evt:window.event; 
	if (window.event) {
		e.cancelBubble=true;
	} else {
	e.stopPropagation();
	}
}

//通栏文字链
function getForwardUrl(serviceid) {
	var indexPage = getForwardIndexPage(serviceid);
    var paras = ['serviceId='+serviceid, 'id='+id, 'webownerId='+webownerId, 'childid='+childid, 'siteurl='+siteurl,'gourl='+gourl];
	var args = paras.join('&');
	if(serviceid == "100008")
		args += "&gopage=17";
	return indexPage + args;
}

var codetypes = [
				{"serviceid":"100001","href":getForwardUrl('100001'), "title":"MP3手机铃声下载！", "color":"#f1038f;", "show":1},
				{"serviceid":"100005","href":getForwardUrl('100005'), "title":"设计签名赢取苹果MP3!", "color":"#05AE05;", "show":1},
				{"serviceid":"100006","href":getForwardUrl('100006'), "title":"2010年运气好吗,为您揭秘!", "color":"#0066ff;", "show":0},
				{"serviceid":"100018","href":getForwardUrl('100018'), "title":"2010年运气好吗,为您揭秘!", "color":"#0066ff;", "show":1},
				{"serviceid":"100008","href":getForwardUrl('100008'), "title":"考考你答题有大奖!", "color":"#ff6600;", "show":0},
				{"serviceid":"100010","href":getForwardUrl('100010'), "title":"测试非常7+1!", "color":"#f1038f;", "show":0},
				{"serviceid":"100013","href":getForwardUrl('100013'), "title":"最准的爱情测试!缘分解密", "color":"#05AE05;", "show":1}
				];