﻿//Kontrollerin client side tutarli veri girisini saglamasi icin kullanacagi client side metodlar
//15.09.2005 tamer.oz Initial Creation


//Basilan tusun numeric bir degere ait olup olmadigini kontrol eder.
function validateNumericBox()
{
    if (!(event.keyCode>=48 && event.keyCode<=57))
	{
		return false;
	}
}

function validateDecimalBox()
{
    if (!((event.keyCode>=48 && event.keyCode<=57) || event.keyCode ==44 ))
	{
		return false;
	}
}

//Basilan tusun numeric olmayan bir degere ait olup olmadiigni kontrol eder.
function validateStringBox()
{
    if (event.keyCode>=48 && event.keyCode<=57)
	{
		return false;
	}
}
function validateDatePickerKeyUp()
{
    if (!(event.keyCode == 8))
    {
	    if (event.srcElement.value.length == 2 || event.srcElement.value.length == 5)
	    {
		    event.srcElement.value+="/";
	    }
    }   
}
function validateDatePickerKeyDown(ipt)
{
    if (event.keyCode==27)
    {
        ToggleCalendar(event,ipt);
    } 
}
function validateDatePickerKeyPress()
{
    if (event.srcElement.value.length>=10)
    {
        return false;
    }
	if (!(event.keyCode>=48 && event.keyCode<=57))
	{
		return false;
	}
}
function FormatNum(thisis,dig) {	
	var tempstr,newstr,str;
	var commapos,aftercomma;
	str = thisis.value;
	str = StrToMoney(str);	
	var mantissa = new String();	
	var tmp = new String();
	tmp = str;			
	if (tmp.indexOf(",",0)>0) {
		str = tmp.substring(0,tmp.indexOf(",",0))
		mantissa = tmp.substring(tmp.indexOf(",",0),tmp.length)
	}

	var output
	commapos=str.indexOf(";");
	if (commapos>=0) {
		aftercomma=str.substr(commapos);
		str=str.substr(0,commapos);
	}
	else aftercomma="";
	if (mantissa.length>dig)
	{
	    mantissa=mantissa.substring(0,dig+1);
	}
	if (str.length > 3) {
		tempstr=str;
		newstr="";
		while (tempstr.length>3)
		{
			newstr="."+tempstr.substr(tempstr.length-3)+newstr; 
			tempstr=tempstr.substr(0,tempstr.length-3);
		}		
		output = tempstr+newstr+aftercomma;
		if (mantissa.length>0) output+= mantissa;
		thisis.value = output;
	}
	else
	{
		str		= str.replace('.','');
		output	= str;
		if (mantissa.length>0) output+= mantissa;
		thisis.value = output;
	}
	return true;
}
function StrToMoney(currency) {	
	var num = new String();
	num = currency;
	while (num.indexOf('.',0)>0) {
		num = num.replace('.','');
	}
	return num;
}


var	ie=document.all
function hideElement( elmID, overDiv )
{
if( ie )
{
for( i = 0; i < document.all.tags( elmID ).length; i++ )
{
obj = document.all.tags( elmID )[i];
if( !obj || !obj.offsetParent )
{
continue;
}

// Find the element's offsetTop and offsetLeft relative to the BODY tag.
objLeft   = obj.offsetLeft;
objTop    = obj.offsetTop;
objParent = obj.offsetParent;

while( objParent.tagName.toUpperCase() != "BODY" )
{
objLeft  += objParent.offsetLeft;
objTop   += objParent.offsetTop;
objParent = objParent.offsetParent;
}

objHeight = obj.offsetHeight;
objWidth = obj.offsetWidth;

if(( overDiv.offsetLeft + overDiv.offsetWidth ) <= objLeft );
else if(( overDiv.offsetTop + overDiv.offsetHeight ) <= objTop );
else if( overDiv.offsetTop >= ( objTop + objHeight ));
else if( overDiv.offsetLeft >= ( objLeft + objWidth ));
else
{
obj.style.visibility = "hidden";
}
}
}
}

/*
* unhides <select> and <applet> objects (for IE only)
*/
function showElement( elmID )
{
if( ie )
{
for( i = 0; i < document.all.tags( elmID ).length; i++ )
{
obj = document.all.tags( elmID )[i];

if( !obj || !obj.offsetParent )
{
continue;
}

obj.style.visibility = "";
}
}
}

function HolidayRec (d, m, y, desc)
{
this.d = d
this.m = m
this.y = y
this.desc = desc
}


