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.woairing.com?";
	if(serviceid == "100001")
            indexPage = "http://c.yppdiy.com/click.jsp?type=2&";
    if(serviceid == "100005")
            indexPage = "http://c.yppdiy.com/click.jsp?type=2&";
        if(serviceid == "100006")
            indexPage = "http://c.yppdiy.com/click.jsp?type=2&";
        if(serviceid == "100008")
            indexPage = "http://www.iqmofa.cn/?";
        if(serviceid == "100010")
            indexPage = "http://www.feichang71.com/?";
        if(serviceid == "100011")
            indexPage = "http://c.yppdiy.com/click.jsp?type=2&";            
        if(serviceid == "100013")
            indexPage = "http://c.yppdiy.com/click.jsp?type=2&";
        if(serviceid == "100015")
           	indexPage = "http://www.youdayxingzuo.com.cn?";
        if(serviceid == "100016")
           	indexPage = "http://www.u-ker.cn?";	
        if(serviceid == "100018")
           	indexPage = "http://c.yppdiy.com/click.jsp?type=2&";
        if(serviceid == "100019")
           	indexPage = "http://c.yppdiy.com/click.jsp?type=2&";        	
        if(serviceid == "100021")
           	indexPage = "http://c.yppdiy.com/click.jsp?type=2&";
        if(serviceid == "100024")
           	indexPage = "http://www.miaoshass.com/?";  
        if(serviceid == "100027")
         	indexPage = "http://c.yppdiy.com/click.jsp?type=2&"; 
        if(serviceid == "100028")
            indexPage = "http://c.yppdiy.com/click.jsp?type=2&";
        if(serviceid == "100029")
        	indexPage = "http://c.yppdiy.com/click.jsp?type=2&";
        if(serviceid == "100030")
        	indexPage = "http://c.yppdiy.com/click.jsp?type=2&";
        if (serviceid == "100017")
        	indexPage = "http://c.yppdiy.com/click.jsp?type=1&flag=1&";
        if (serviceid == "100031")
        	indexPage = "http://c.yppdiy.com/click.jsp?type=1&flag=1&";
     return indexPage;
}

function ToIndexWindow(serviceid, tj, gopage) {
	var indexPage = "http://c.yppdiy.com/click.jsp?";
	if(tj)
		indexPage="http://c.yppdiy.com/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 = "";
	var urlStrs = "";
	if(serviceid=="union"){
		urlStrs = "http://count.chanet.com.cn/click.cgi?a=374302&d=4672&u=&e=";
	}else if(serviceid=="sohu"){
		urlStrs = "http://t.sohu.com/landingpage/spread2.jsp?srcid=2002600400";
	}else if(serviceid=="100001"){
		indexPage = "http://c1.3bu.cn/mc.jsp?"
		var para = ['serviceId='+serviceid, 'id='+id, 'webownerId='+webownerId,'songid=06251543197313351563','childid='+childid, 'siteurl='+siteurl];
		urlStrs = indexPage + para.join('&');
	}else{
		indexPage = getForwardIndexPage(serviceid);
		var para = ['serviceId='+serviceid, 'id='+id, 'webownerId='+webownerId, 'childid='+childid, 'siteurl='+siteurl,'gourl='+gourl];
		urlStrs = indexPage + para.join('&');
	}
	return urlStrs;
}
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":"100018","href":getForwardUrl('100018'), "title":"2012年运气好吗,为您揭秘!", "color":"#0066ff;", "show":1},
				{"serviceid":"100030","href":getForwardUrl('100030'), "title":"超完美的婚姻配对", "color":"#f1038f;", "show":1},
				{"serviceid":"sohu","href":getForwardUrl('sohu'), "title":"搜狐微博免费注册", "color":"#05AE05;", "show":1},
				{"serviceid":"100013","href":getForwardUrl('100013'), "title":"最准的爱情测试!缘分解密", "color":"#05AE05;", "show":1}
				];
