function SetTableBackgroundColor( e, col ) 
{
	for( var i = 0; i < e.cells.length; i++ )
	{
		e.cells(i).bgColor = col ;	
	}		
}
/*
 * NumberFormat v1.01
 */

/*
 * NumberFormat -The constructor
 * num - The number to be formatted
 */
function NumberFormat(num)
{
	// member variables
	this.num;
	this.isCommas;
	this.isCurrency;
	this.currencyPrefix;
	this.places;

	// external methods
	this.setNumber = setNumberNF;
	this.toUnformatted = toUnformattedNF;
	this.setCommas = setCommasNF;
	this.setCurrency = setCurrencyNF;
	this.setCurrencyPrefix = setCurrencyPrefixNF;
	this.setPlaces = setPlacesNF;
	this.toFormatted = toFormattedNF;

	// internal methods
	this.getRounded = getRoundedNF;
	this.preserveZeros = preserveZerosNF;

	// setup defaults
	this.setNumber((num==null) ? 0 : num);
	this.setCommas(true);
	this.setCurrency(true);
	this.setCurrencyPrefix('$');
	this.setPlaces(2);
}

/*
 * setNumber - Sets the number
 * num - The number to be formatted
 */
function setNumberNF(num)
{
	this.num = num;
}

/*
 * toUnformatted - Returns the number as is (a number)
 */
function toUnformattedNF()
{
	return (this.num);
}

/*
 * setCommas - Sets a switch that indicates if there should be commas
 * isC - true, if should be commas; false, if no commas
 */
function setCommasNF(isC)
{
	this.isCommas = isC;
}

/*
 * setCurrency - Sets a switch that indicates if should be displayed as currency
 * isC - true, if should be currency; false, if not currency
 */
function setCurrencyNF(isC)
{
	this.isCurrency = isC;
}

/*
 * setCurrencyPrefix - Sets the symbol that precedes currency.
 * cp - The symbol
 */
function setCurrencyPrefixNF(cp)
{
	this.currencyPrefix = cp;
}

/*
 * setPlaces - Sets the precision of decimal places
 * p - The number of places. Any number of places less than or equal to zero is considered zero.
 */
function setPlacesNF(p)
{
	this.places = p;
}

/*
 * toFormatted - Returns the number formatted according to the settings (a string)
 */
function toFormattedNF()
{
	var pos;
	var nNum = this.num; // v1.0.1 - number as a number
	var nStr;            // v1.0.1 - number as a string

	// round decimal places
	nNum = this.getRounded(nNum);
	nStr = this.preserveZeros(Math.abs(nNum)); // this step makes nNum into a string. v1.0.1 Math.abs

	if (this.isCommas)
	{
		pos = nStr.indexOf('.');
		if (pos == -1)
		{
			pos = nStr.length;
		}
		while (pos > 0)
		{
			pos -= 3;
			if (pos <= 0) break;
			nStr = nStr.substring(0,pos) + ',' + nStr.substring(pos, nStr.length);
		}
	}
	
	nStr = (nNum < 0) ? '-' + nStr : nStr; // v1.0.1

	if (this.isCurrency)
	{
		// add dollar sign in front
		nStr =  nStr + this.currencyPrefix;
	}

	return (nStr);
}

/*
 * getRounded - Used internally to round a value
 * val - The number to be rounded
 */
function getRoundedNF(val)
{
	var factor;
	var i;

	// round to a certain precision
	factor = 1;
	for (i=0; i<this.places; i++)
	{	factor *= 10; }
	val *= factor;
	val = Math.round(val);
	val /= factor;

	return (val);
}

/*
 * preserveZeros - Used internally to make the number a string
 * 	that preserves zeros at the end of the number
 * val - The number
 */
function preserveZerosNF(val)
{
	var i;

	// make a string - to preserve the zeros at the end
	val = val + '';
	if (this.places <= 0) return val; // leave now. no zeros are necessary - v1.0.1 less than or equal
	
	var decimalPos = val.indexOf('.');
	if (decimalPos == -1)
	{
		val += '.';
		for (i=0; i<this.places; i++)
		{
			val += '0';
		}
	}
	else
	{
		var actualDecimals = (val.length - 1) - decimalPos;
		var difference = this.places - actualDecimals;
		for (i=0; i<difference; i++)
		{
			val += '0';
		}
	}
	
	return val;
}

function Git(Yer)
{
 window.navigate(Yer);
}
function over() {
    window.event.srcElement.style.filter = "alpha(opacity=50)";
}
function out() {
    window.event.srcElement.style.filter = "alpha(opacity=100)";
}

function tanitimpencere(x,xx,y,z,s) {
var tanitimpopup; 
if (tanitimpopup) {tanitimpopup.close();}
tanitimpopup = window.open(x,xx,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars="+s+",resizeable=0,width="+y+",height="+z+",screenX=5,screenY=5,top=5,left=5")
tanitimpopup.focus();

}

function checkString(f,fieldname,l){
  var value=f.value;
  var result=!isEmpty(rtrim(value));
  if(!result)alert("Lütfen "+fieldname+" Bölümünü doldurunuz.");
  if(result){
    result=(value.length>=l)
    if(!result)alert("Lütfen en az " + l + " karakter giriniz.");}
  if(!result)f.focus();
  return(result);
}

function checkNumeric(f,fieldname,l){
  var result=checkString(f,fieldname,l);
  if(result){
    for(i=0;(i<l)&&result;i++){
      c=parseInt(f.value.substring(i,i+1),10);
      result=result&&(c==c);}
    if(!result)alert("Lütfen "+fieldname+" olarak sayısal bir değer giriniz.");}
  return(result);
}

function checkEmail(f){
var x=f.value;
var result=(x.search(new RegExp("^\\S+@\\S+\\.\\S+$")));
if(result!=0){
    alert("Lütfen e-mail adresinizi mail@domain.com formatında giriniz.");
    f.focus();
    return false}
else
    return true;
}

function strKarsilastir(f,f2,fieldname){
  var value=f.value;
  var value2=f2.value;
  if (value!=value2)
     result=false;
   else
     result=true;
  if(!result)alert(fieldname+" alanları aynı olmalıdır.");
  return(result);
}

function isEmpty(s){
  return ((s == null)||(s.length == 0))
}

function rtrim(text){
  var lastChar=text.substring(text.length-1, text.length);
  while(lastChar==" "){
    text=text.substring(0, text.length-1);
    lastChar=text.substring(text.length-1, text.length);}
  return text;	
}
