
/**
 * 过滤html
 * @param str
 * @return
 */
function delhtml(str)
{
	str = str.replace(/<\/?[^>]+>/g,''); //去除HTML tag
	str = str.replace(/[ | ]*\n/g,'\n'); //去除行尾空白
	str= str.replace(/\n[\s| | ]*\r/g,'\n'); //去除多余空行
	return str;
}
function ReplaceAll(str, sptr, sptr1)
{
	while (str.indexOf(sptr) >= 0)
	{
	   str = str.replace(sptr, sptr1);
	}
   return str;
}
function RemoveHTML(strText,start,end)
{
 var regEx =/<[^>]*>/g;
 var content=strText.replace(regEx, "");
 return content.substring(start,end);
}
/*usercenter 弹出框*/
function modAlipay()
{
	$("#paydiv").css("display","block");
}

function showMenu (baseID, divID) {

	var bw = $("#"+baseID).width();
	var dw = $("#"+divID).width();
    baseID =  document.getElementById(baseID);
    divID  =  document.getElementById(divID);

    var l = GetOffsetLeft(baseID);
    var t = GetOffsetTop(baseID);

    
    divID.style.left = l+ bw/2-(dw/2+20 ) + 'px';
	divID.style.top = t + baseID.offsetHeight +12 + 'px';
    if (showMenu.timer) clearTimeout(showMenu.timer);
	hideCur();
    divID.style.display = 'block';
	showMenu.cur = divID;

    if (! divID.isCreate) {
        divID.isCreate = true;
        //divID.timer = 0;
        divID.onmouseover = function () {
            if (showMenu.timer) clearTimeout(showMenu.timer);
			hideCur();
            divID.style.display = 'block';
        };

        function hide () {
            showMenu.timer = setTimeout(function () {divID.style.display = 'none';}, 1000);
        }

        divID.onmouseout = hide;
        baseID.onmouseout = hide;
    }
	function hideCur () {
		showMenu.cur && (showMenu.cur.style.display = 'none');
	}
}

function GetOffsetLeft (el, p) {
    var _l = el.offsetLeft;
    var _p = el.offsetParent;

    while (_p) {
        if (_p == p) break;
        _l += _p.offsetLeft;
        _p = _p.offsetParent;
    }

    return _l;
};

function GetOffsetTop (el, p) {
    var _t = el.offsetTop;
    var _p = el.offsetParent;

    while (_p) {
        if (_p == p) break;
        _t += _p.offsetTop;
        _p = _p.offsetParent;
    }

    return _t;
};
//将内容复制到剪贴板


function copyToClipboard(text2copy,msg) 
{    
	if (window.clipboardData) 
	{
		window.clipboardData.setData("Text",text2copy);
	} 
	else 
	{
		var flashcopier = 'flashcopier';
		if(!document.getElementById(flashcopier)) 
		{
			var divholder = document.createElement('div');
			divholder.id = flashcopier;
			document.body.appendChild(divholder);
		}
		document.getElementById(flashcopier).innerHTML = '';
		var divinfo = '<embed src="templates/Default/script/_clipboard.swf" FlashVars="clipboard='+text2copy+'" width="0" height="0" type="application/x-shockwave-flash"></embed>';//这里是关键		
		document.getElementById(flashcopier).innerHTML = divinfo;
	}
	//alert(msg);
	//getTip(msg,450,135);
	alert(msg);
	return true;
	 
}

//将商品加入收藏，依赖于Jquery
function AddFavorite(pid)
{ 	
	 c_ajax_sumbit(pid);
}
//弹出框关闭
function cancel()
{
	$(".blockUI").hide();
}

$(function()
{
    $('.nav_con>li>a').hover(function(){$(this).next('div').show();
    $(this).next('div').css('left',$(this).position().left);},function(){$(this).next('div').hide();});
    $('.nav_con>li>a').next('div').hover(function()
    {
        $(this).show();
        $(this).prev('a').addClass('cur');
    },function()
    {
        $(this).hide();
        $(this).prev('a').removeClass('cur');
    });		   
});

