﻿// JScript 文件


function getObject(idname)
{
    if (document.getElementById)
    {
        return document.getElementById(idname);
    }
    else if (document.all)
    {
        return document.all[idname];
    }
    else if (document.layers)
    {
        return document.layers[idname];
    }
    else
    {
        return null;
    }
}


function getTags(parentobj, tag)
{
    if (parentobj == null)
    {
        return new Array();
    }
    else if (typeof parentobj.getElementsByTagName != 'undefined')
    {
        return parentobj.getElementsByTagName(tag);
    }
    else if (parentobj.all && parentobj.all.tags)
    {
        return parentobj.all.tags(tag);
    }
    else
    {
        return new Array();
    }
}

function normerImg(id,uwidth)
{
    var tuwidth=0;
    var url = "";
    var urli=0;
    var object2;
    var oldwidth=0;
    var oldheight=0;
    var object = getTags(getObject(id),"img");
    tuwidth=uwidth==""?680:uwidth;
    objectlength=object.length;

    for(var i=0;i<objectlength;i++)
    {
        object2 = object[i];
        oldwidth=object2.width;
        oldheight=object2.height;
        if(oldwidth>tuwidth)
        {
            object2.width=tuwidth;
            object2.height=(tuwidth/oldwidth)*oldheight;
        }

        if(window.addEventListener)
        { // Mozilla, Netscape, Firefox
            object2.addEventListener('click', function(){window.open(object2.src)}, false);
        }
        else
        { // IE
            object2.attachEvent('onclick',  function(){window.open(object2.src);});
        }
        //object2.onclick=new Function(window.open(object2.src));
        object2.style.cursor="pointer";
    }
}

function addtofavorite(SortID,RecordID)
{
    
    $.ajax({
    type:"POST",
    url:"ajax/AjaxUsermag.aspx",
    data:"action=atfavorite&sid="+SortID+"&rid="+RecordID,
    dataType:'json',
    error:function(ErrorHttp,Errormsg,Errors){
        alert("Error:please contact site manager!");
    },
    success:function(data,text){
        if(typeof(data.status) != 'undefined')
	    {
			if(data.status != 'Yes')
			{
				alert(data.status);
			}
			else
			{
			    alert("adding finish!");
			}
		}
    },
    complete:function(hp,text){ }
    });    

}













