﻿function Popup(url, w, h)
{
    wleft = (screen.width - w) / 2;
    wtop = (screen.height - h) / 2;
    window.open(url, "popPrint", "dependent,modal,center=yes;resizable=yes,toolbar=no,scrollbars=yes,menubar=no,status=yes,directories=no,width=" + w + ",height=" + h + ",top=" + wtop + ",left=" + wleft);
}

function CurrToNumber(sCurrency) 
{
    var Temp = new String();
	Temp=sCurrency;
    return Temp.replace(/[/.]/ig,'');
}


function NumToCurrency(sNumber,nDec) {  
  if (sNumber!=null && sNumber!='')
  {

  var Temp = new String();
  var Top, Bottom, Num; 
	Temp = sNumber;
	Temp = Temp.replace(/[.]/ig,'');
	Temp = Temp.replace(/[,]/ig,'.');
	Num = parseFloat(Temp.replace(/[^\d\.]/ig,''));	
	if (isNaN(Num)) return '';
	else {
	    if (nDec == -1)
	        return Num;
	        
  	  Top = Math.floor(Num);
	  Bottom = Math.round((Num - Math.floor(Num)) * Math.pow(10,nDec));	  
	  Bottom = Bottom.toString();
	  if (Bottom==100) {Bottom='00'; Top=Top+1}
	  Top = Top.toString();
	  Temp='';
	  while (Bottom.length<nDec) {
 	    Bottom = '0' + Bottom;
	  }
	  while (Top.length>3) {
	    Temp = '.' + Top.slice(Top.length-3) + Temp;
	    Top = Top.substr(0,Top.length-3);
	  }	
	  if (nDec>0) 
		{Temp= Top + Temp + "," + Bottom;
		}
	  else
	    {Temp= Top + Temp}
	  if (sNumber.substring(0,1) == '-')
	  {
	  Temp='-'+Temp
	  }
	  return Temp;
	}
	
	}
	else
	{
	return ''
	}
}

var tags = new Array( 'span', 'div','td','tr','p','b','table','strong','emphasis','a','h1','h2','h3','pre','sub','sup','i','th','cp','ul','ol','li','dt','dd');
var pixelArray =  new Array('9','11','13','15','24','30','40');
var emArray =  new Array('0.6','0.9','1.0','1.5','2.0','2.5','3');
var initSize = 1;
var incSize = 1;

function fontSizer(inc,unit) {
	
	if (!document.getElementById) 
		return;
			
    incSize += inc;    
    if (incSize <0)
        incSize=0;    
    
    inc = incSize;    
	var sizeTitle = 20;
	var size = initSize;
		size = inc;
		
		if (inc > 1)
			sizeTitle +=inc;
		
	if (size < 0 ) {
		size = 0;
        }
	        if (size > 6 ) {
		        size = 6;
        }
        initSize = size;
        getBody = document.getElementById('ResizeBody');				
	for (i = 0 ; i < tags.length ; i++ ) {
		getallTags = getBody.getElementsByTagName(tags[i]);
	for (k = 0 ; k < getallTags.length ; k++) 		
		{
		//if (getallTags[k].style.fontSize != undefined) alert(getallTags[k].style.fontSize)		
		
		if (getallTags[k].className == "tabTitle")		
			{
			getallTags[k].style.fontSize = sizeTitle+'px';						
			}
		else if (getallTags[k].tagName == "H1")		
			{
			getallTags[k].style.fontSize = sizeTitle+'px';						
			}			
		else
			getallTags[k].style.fontSize = (unit=='px') ? pixelArray[size]+unit: emArray[size]+unit;			
		}
	}
}

var lineH=1;
function LineHeightInc()
{
    lineH +=0.5;
    $('div#ResizeBody').css("lineHeight",lineH);
}

/*Rating*/
function Rate(callback, r, id)
{    
    callback.SendCallback(r+";"+id);
}

function ShowSelection(s, holderID) 
{    
    $("#" + holderID + " li").removeClass().addClass("rateStarNone");
    var sIndex = $("#" + holderID + " li").index(s);

    $("#" + holderID + " li").each(
        function(i) {
            if (i > sIndex)
                return;                
            $(this).removeClass().addClass("rateStarFull");
    });
}
function SetRate(r, holderID)
{    
    var rate = r;
    
    $("#" + holderID + " li").removeClass().addClass("rateStarNone");
    $("#" + holderID + " li").each(
        function(i) {
            if (Math.floor(rate) <= i)
                return;                
            $(this).removeClass().addClass("rateStarFull");
        });

    if (Math.abs(rate - Math.floor(rate)) >0.4) {
        var li = $("#" + holderID + " li").get(Math.floor(rate));
        $(li).removeClass().addClass("rateStarHalf");
    }
}

function AddBookmark() 
{     
    if (window.sidebar)
        window.sidebar.addPanel(document.title, location.href, "");	
    else if( window.external )        
        window.external.AddFavorite(location.href, document.title);        
    else if(window.opera && window.print) 
        return true;
}
function CheckForAnchor() 
{
    var charIndex = window.location.href.indexOf("#");
    if (charIndex > 0)
        window.location.href = window.location.href.substring(charIndex);    
}