var sid="";
//主菜单
jQuery(function(){
	jQuery('ul.sf-menu').superfish();
	
	$.ajaxSetup({
		  cache: false,
		  type: "post"
	 });
	 /*
	 $(document.body).append("<div id=\"gg1\" style='z-index:10000;'><a href='http://click.tinselbird.com.cn/edm_tracking/edm_click_tracking.aspx?edm_id=t222_edm_20110420_1&edm_flag=chinapolling&target_id=t222&email=$$_toemail$$&urlto=http://polling2.chinapolling.com/googlePoll.aspx$$eTopicId=2088**topicId=222**url=default.html' target='_blank'><img src='/front/images/floatbtn.jpg' width='122'/></a></div>");
	 var ad1=new AdMove("gg1");
	 ad1.Run(); */
	 var burl = location.href ;
	 _ajax('/login-loginurl.action','backurl='+burl,function(){});
	 
	 _ajax('/cmsAjax!sid.action','',function(data){
			sid = getCookie("sid");
			if(document.getElementById("topsid")){
				document.getElementById("topsid").value = sid;
			}
			if(document.getElementById("leftsid")){
				document.getElementById("leftsid").value = sid;
			}
	 });
});

function _ajax(url,para,fun){
	
	$.ajax({url:url,
			data:para,
			success:fun,
			error:function(data){
				//alert(data);
			},cache: false
	});
}
// cookie
function getCookieVal (offset) {
    var endstr = document.cookie.indexOf (";", offset);
    if (endstr == -1) endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset, endstr));
}

function getCookie (name) {
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen) {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg) return getCookieVal (j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}
function setCookie (name, value) {
    var exp = new Date();
    exp.setTime (exp.getTime()+3600000000);
    document.cookie = name + "=" + value + "; expires=" + exp.toGMTString();
}
// end

//share start
var shareurl = "http://www.nestlebaby.com.cn/index.htm";
var sharepic = "http://www.nestlebaby.com.cn/front/images/logo.jpg";
function getshareurl(url){
	if(!url){
		return shareurl;
	}
	return url;
}
function getsharepic(pic){
	if(!pic){
		return sharepic;
	}
	return pic;
}
//豆瓣
function sharedouban(title,content,pic,url){
	url = getshareurl(url);
	window.open('http://www.douban.com/recommend/?url='+encodeURIComponent(url)+'&title='+encodeURIComponent(title),'_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes');
	void(0);
}
//开心 
function sharekaixin001(title,content,pic,url){
	url = getshareurl(url);
	pic = getsharepic(pic);
	window.open('http://www.kaixin001.com/repaste/share.php?rtitle='+encodeURIComponent(title)+'&rurl='+encodeURIComponent(url)+'&rcontent=' + encodeURIComponent(content)+'&pic='+pic,'_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes');
	void(0);
}
//人人 
function sharerenren(title, content,pic,url){
	url = getshareurl(url);
	pic = getsharepic(pic);
	window.open('http://share.renren.com/share/buttonshare.do?link='+encodeURIComponent(url)+'&title='+encodeURIComponent(title)+'&content=' + encodeURIComponent(content)+'&pic='+pic,'_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes');
	void(0);
}
//QQ 
function shareqq(title,content,pic,url){
	url = getshareurl(url);
	pic = getsharepic(pic);	
	window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+ encodeURIComponent(url)+ '&title='+encodeURIComponent(title)+'&content='+encodeURIComponent(content),'_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes');
	void(0);
}
//搜狐 
function shareshou(title,content,pic,url){
	url = getshareurl(url);
	pic = getsharepic(pic);
	if(content==null||content==""){
		content = title;
	}
	window.open('http://t.sohu.com/third/post.jsp?title='+encodeURIComponent(content)+'&url='+encodeURIComponent(url)+'&pic='+pic+"&content=utf-8",'_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes');
	void(0);
}
//新浪微博 
function sharesina(content,pic,url){
	url = getshareurl(url);
	pic = getsharepic(pic);
	var appkey = "3476937728";
	window.open('http://v.t.sina.com.cn/share/share.php?title='+encodeURIComponent(content)+'&url='+encodeURIComponent(url)+'&pic='+pic+"&appkey="+appkey,'_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes');
	void(0);
}
//share end
/** 过敏测试flash赋值 */
function setAllergicValue(value){
	if(document.getElementById("users_allergic")){
		document.getElementById("users_allergic").value = value;
	}
}
/** popus tests */
function openTests(){
	window.open('/allergy-tests.html','_blank','scrollbars=no,width=484,height=340,left=75,top=20,status=no,resizable=yes');
}

