/*document.onkeydown = function(){
if(event.keyCode == 13){    
event.keyCode =9;
}}
*/
var timer_count = 0;
function GetCookie(cookiename)
{
    var thebigcookie = document.cookie;
    var firstchar = thebigcookie.indexOf(cookiename);
    if (firstchar != -1) {
        firstchar += cookiename.length + 1;
        lastchar = thebigcookie.indexOf(";",firstchar);
        if(lastchar == -1) lastchar = thebigcookie.length;
        return unescape(thebigcookie.substring(firstchar, lastchar));
    }
    return "";
}
function SetCookie(cookiename,cookievalue,cookieexpdate,domainname)
{
    document.cookie = cookiename + "=" + escape(cookievalue)
    + "; domain=" + domainname
    + "; path=" + "/"
    + "; expires=" + cookieexpdate.toGMTString();
}

Date.prototype.format = function(format)
{ 
var o = { 
"M+" : this.getMonth()+1,
"d+" : this.getDate(),
"h+" : this.getHours(),
"m+" : this.getMinutes(),
"s+" : this.getSeconds(),
"q+" : Math.floor((this.getMonth()+3)/3),
"S" : this.getMilliseconds()
} 
if(/(y+)/.test(format)) format=format.replace(RegExp.$1, 
(this.getFullYear()+"").substr(4 - RegExp.$1.length)); 
for(var k in o)if(new RegExp("("+ k +")").test(format)) 
format = format.replace(RegExp.$1, 
RegExp.$1.length==1 ? o[k] : 
("00"+ o[k]).substr((""+ o[k]).length)); 
return format; 
}

function CheckImg(o,img, txt,img1)
{
	if (!/\.((jpg)|(bmp)|(gif)|(png))$/ig.test(o.value))
	{
		alert('只能上传jpg,bmp,gif,png格式图片!');
		o.outerHTML = o.outerHTML;
	}
	else
	{
	    $(img).hide();
		$(img1).filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src=o.value;
		$(img1).show();
		$(txt).value = o.value;
	}
}
function CheckPrice(o)
{
    var v=parseFloat(o.value);
    v=isNaN(v)?'0.0':v.toFixed(2);    
    if (o.value!=v)
    {
        o.value=v;
        //alert('金额只能保留到两位小数，例如：123.45');
    }    
}
function CheckImgCss(o,img)
{
	if (!/\.((jpg)|(bmp)|(gif)|(png))$/ig.test(o.value))
	{
		alert('只能上传jpg,bmp,gif,png格式图片!');
		o.outerHTML = o.outerHTML;
	}
	else
	{
		$(img).filters.item("DXImageTransform.Microsoft.AlphaImageLoader").src=o.value;
	}
}

function GetProduct()
{
    var str = GetCookie('history');
    var obj = [];
    if (str != null && str != '') obj = str.evalJSON();
    return obj;
}
function AddProduct(id,pic,name)
{
    var obj = GetProduct();
    for (var i=0;i<obj.length;i++)
        if (id==obj[i][0])break;
    if (i==obj.length)
        obj.push([id,pic,name]);
    while(obj.length>6)
        obj.shift();
    var d = new Date();
    d.setYear(d.getYear()+1);
    SetCookie('history', obj.toJSON(), d, 'ylaner.com');
}

function GetXY(score)
{
	if (score<4)return [0,0];
	var arr=[[10,40,90,150,250],[500,1000,2000,5000,10000],[20000,50000,100000,200000,500000]];
	for(var i=0;i<arr.length;i++)
	for(var j=0;j<arr[i].length;j++)
	{
		if (score<=arr[i][j])return [i,j+1];
	}
	
}
var timer_count = 30;
var comment_timer;


function DrawImage(ImgD,imgwidth,imgheight){  
     if(ImgD.src.indexOf('none.gif')<0){       
        var f = ImgD.width/ImgD.height;
		if (ImgD.width>imgwidth){ImgD.width=imgwidth;ImgD.height=imgwidth/f;}
		if (ImgD.height>imgheight){ImgD.height=imgheight;ImgD.width=imgheight*f;}
        //addHref(ImgD);
     }
}   
function addHref(element)//参数就是img的实例
{
     var link1 = document.createElement("a");
     link1.href = element.src;
     link1.target='_blank';
     element.parentNode.insertBefore(link1,element);
     link1.appendChild(element);
}
function DrawImage1(ImgD,imgwidth,imgheight){   
     if(ImgD.src.indexOf('none.gif')<0){
        var f = ImgD.width/ImgD.height;
		if (ImgD.width>imgwidth){ImgD.width=imgwidth;ImgD.height=imgwidth/f;}
		if (ImgD.height>imgheight){ImgD.height=imgheight;ImgD.width=imgheight*f;}
     }
} 

function toit(obj,tag)
{    
    closeall();
    obj.className = "cur";
    Element.toggle("ddd"+tag);
}
function CheckNum(o)
{
    var v=parseFloat(o.value);
    v=isNaN(v)?'1':v; 
    o.value = v;   
   //alert(1);
}
function CheckNumint(o)
{
    var v=parseInt(o.value);
    v=isNaN(v)?'0':v; 
    o.value = v;   
   //alert(1);
}
function CheckPrice(o)
{
    var v=parseFloat(o.value);
    v=isNaN(v)?'0':v.toFixed(2);    
    if (o.value!=v)
    {
        o.value=v;
        //alert('金额只能保留到两位小数，例如：123.45');
    }    
}

function redaili()
{
    var uname = GetCookie("username");
    if(uname=="")
    {
       window.location.href='/help/h_34.shtml';
    }
    else
    {
        window.location.href='/user/wangdaisq.aspx';
    }
}

function showcg(obj)
{
	    document.getElementById("picdiv").innerHTML = "<img src='"+obj.src+"'/>";
    	
	    document.getElementById("picdiv").style.left = cumulativeOffset(obj)[0];
	    document.getElementById("picdiv").style.top =cumulativeOffset(obj)[1];
}
function closeshow()
{
	document.getElementById("picdiv").innerHTML = "";
	document.getElementById("picdiv").style.left = "0";
	document.getElementById("picdiv").style.top = "0";
}
function   cumulativeOffset(element)   {   
var   valueT   =   0,   valueL   =   0;   
do   {   
  valueT   +=   element.offsetTop     ||   0;   
  valueL   +=   element.offsetLeft   ||   0;   
  element   =   element.offsetParent;   
}   while   (element);   
return   [valueL,   valueT];   
} 
function rand1(number) {
return Math.floor(Math.random() * number);
}

function kd()
{
if(event.keyCode==13){seac();}
}
function seac()
{
    document.location='/search.aspx?key='+escape(document.getElementById("key").value);
}
String.prototype.trim = function() 
{ 
return this.replace(/(^[\s]*)|([\s]*$)/g, ""); 
} 
function keyUpdo()
{
    
    if(event.keyCode==13)
	{
	    //research();
	    document.getElementById("btnSearch").click();
	    event.keyCode=9;
	}
}
function doSearch()
{
    window.location = "/search.aspx?key="+escape(document.getElementById("SeachKeyWord").value);
}

function setgou19(strgstr)
{
    if(document.getElementById("gouwuc1")!=null)
    {
        document.getElementById("gouwuc1").innerHTML = strgstr;
    }
}
