﻿function CreateArticleRate(num)
{
    var strRate = "";
    
    if(!isNaN(num))
   {
        if(num>0)
        {
            for(var i=0;i<num;i++)
            {           
                    strRate = strRate + "<IMG alt='' src='http://images.unigo.com/Media/graphics/star.gif' wight='13px' height='11px' />";
            }
            for(var t=num;t<5;t++)
            {
                     strRate = strRate + "<IMG alt='' src='http://images.unigo.com/Media/graphics/greystar.gif' wight='13px' height='11px'  />";
            }
        }
        else
        {
             for(var j=0;j<5;j++)
            {           
                strRate = strRate + "<IMG alt='' src='http://images.unigo.com/Media/graphics/greystar.gif' wight='13px' height='11px'  />";
            }      
        }
        
   } 
   document.write(strRate);
}


function CreateArticleRateDom(num,objId)
{
    var strRate = "";
    
    if(!isNaN(num))
   {
        for(var i=0;i<num;i++)
        {
            strRate = strRate + "<IMG alt='' src='http://images.unigo.com/Media/graphics/star.gif' wight='13px' height='11px'  />";
        }
   } 
   jQuery("#"+objId).html(strRate);
}

function InputTextIsNull(inputstring)
    {
        var isNull = false;
        var inputText = document.getElementById(inputstring);
        if((inputText.value.replace(/(^\s*)|(\s*$)/g,"").length==0)) 
        {
            alert("Please input your comment!");
            isNull = true;
        }
        
        return isNull;
    }
   
function TransPage(obj)
{
    var isValidate = true;
    if(obj!=null && obj!="") 
   {
        if(!isNaN(obj))
        {
            isValidate = false;
        }
   } 
   
   return isValidate;        
} 
function SetPosition(obj)
{
    var divId = obj.replace("_img_","_div_");
    var divJObj = jQuery("#"+divId);
    var imgJObj = jQuery("#"+obj);
    var imgoffSet = imgJObj.offset();
    var left,height,width,top,divheight,divwidth = 0;
    divheight = divJObj.height();
    divwidth = divJObj.width()/2;
    height = imgJObj.height();
    width = imgJObj.width();
    
//    left = imgoffSet.left - divwidth + width/4;
//    if(left<0)
//    {
//    	left = 2;
//    }
    
    top = imgoffSet.top - (divheight + 220);
    if(top<0)
    {
    	top = imgoffSet.top + height + 10;
    }
    /*
    top = imgoffSet.top + height + 10;*/ 
    divJObj.css({left:left,top:top});

}


function CreateArticleStarRating(num)
{
    var strRate = "";
    
    if(!isNaN(num))
   {
        if(num>0)
        {
            for(var i=0;i<num;i++)
            {           
                    strRate = strRate + "<IMG alt='' src='http://images.unigo.com/Media/graphics/star_on.gif' onmouseout='getRating();' onmousemove='showRating();' />";
            }
            for(var t=num;t<5;t++)
            {
                     strRate = strRate + "<IMG alt='' src='http://images.unigo.com/Media/graphics/star_off.gif' onmouseout='getRating();' onmousemove='showRating();' />";
            }
        }
        else
        {
             for(var j=0;j<5;j++)
            {           
                strRate = strRate + "<IMG alt='' src='http://images.unigo.com/Media/graphics/star_off.gif' onmouseout='getRating();' onmousemove='showRating();' />";
            }      
        }
        
   } 
   document.write(strRate);
}

