//--------------- Constants -------------------//				
var TSKB_DataTypeSTRING = "VARCHAR";
var TSKB_DataTypeNUMBER = "NUMERIC"; 
var TSKB_DataTypeCURRENCY = "CURRENCY"; 
var TSKB_DataTypeSMALLDATE = "SMALLDATE";
var TSKB_DataTypeLONGDATE = "LONGDATE";
var TSKB_DataTypeDATETIME = "DATETIME";
var TSKB_DataTypeEXCHANGERATE = "EXCHANGERATE";
var TSKB_DataTypeSURVEY = "SURVEY";

var TSKB_RequiredYES="YES";
var TSKB_RequiredNO="NO";
var TSKB_ReadOnlyYES="YES";
var TSKB_ReadOnlyNO="NO";
var TSKB_UpperCaseYES="YES";
var TSKB_UpperCaseNO="NO";

var sTSKB_SelectionTypeNONE="NONE";
var sTSKB_SelectionTypeTEXT="TEXT";
var sTSKB_SelectionTypeCONTROL="CONTROL";
var collAllByTabIndex;

var Tskb_CurrentControlId="";
var Tskb_CurrentHiddenControlId="";

var VirtualPath="/GayrimenkulDegerleme";

var oPopup=null;

var nMenuHeight=18;

var TSKB_shiftKey=false;
var TSKB_ctrlKey=false;
var bCancelBubble=false;
var bContextMenu=false;

var bFormCanBeSubmitted=true;

var bFramesLoaded=true;

var TSKB_fromElement=null;
var TSKB_srcElement=null;
var TSKB_SelectedObject=null;
var TSKB_CopiedText="";
var TSKB_SelectedText=""

var nBodyWidth;
var nBodyHeight;
var nScreenWidth;
var nScreenHeight;
var nVResolution;
var nHResolution;
var oContextMenu=null;
var bContextMenuStatus=false;

var oActiveObj;
var oFirstObjByTabIndex=null;
var collAll;
var sEvent="";

var DigitalGroupingSymbol=",";
var DecimalSymbol=".";

var TSKB_DateDelimiter = "/";
var TSKB_CurrencyPrecisionDelimiter = DigitalGroupingSymbol;
var TSKB_CurrencyScaleDelimiter = DecimalSymbol;
var TSKB_CurrencyScale=2;
var TSKB_ExchangeRateScaleLength=2;
var TSKB_SurveyScaleLength=2;
var TSKB_ExchangeRatePrescisionLength=2;
var KeyCode_F2=113;
var collForbiddenKeys=new Array(122,116);
//--------------- /Constants -------------------//

function cancelKeyDownEvent()
{
	event.keyCode=0;
	event.returnValue=false;
}

function checkForbiddenKeys()
{
	var bReturnValue=true;
	for(var i=0;i<collForbiddenKeys.length;i++)
	{
		if(event.keyCode == collForbiddenKeys[i])
		{
			bReturnValue=false
		}
	}
	
	if(event.shiftKey)
		TSKB_shiftKey=true;
	if(event.ctrlKey)
		TSKB_ctrlKey=true;
	
	if(TSKB_ctrlKey && event.keyCode==78)
	{
		bReturnValue=false;
		TSKB_ctrlKey=false;
	}	
	
	if(!bReturnValue)
	{
		cancelKeyDownEvent();
	}		
	return bReturnValue;
}
function doActivate(){		
	var oSourceObj=window.event.srcElement;			
	if(oSourceObj.nodeName=="BODY")
	{				
		if(oFirstObjByTabIndex==null)
		{						
			oFirstObjByTabIndex="InUse";
		}
	}
	else
	{				
		doFocus();
	}		
}


function doBeforePaste()
{

}

function doBlur(oSource)
{			
	TSKB_fromElement=oSource;	
}


function doBodySelect()
{
}

function doClick()
{	
	var oSource=event.srcElement;
	var oParent=oSource.parentNode;
	var sAttrValue;	
		
	if(oParent.nodeName=="TR")
	{
		
		sAttrValue=getAttributeValue(oParent,"TSKB_HasChild");
		if (sAttrValue != null && sAttrValue=="1")
		{
		}
		else
		{
			
		}
	}
	else
	{
		
	}
	showContextMenu();	
	if(document.all("tblTakvim"))
	{
		if (document.all("tblTakvim").style.visibility == "visible")
		{
			takvimKapa();
		}
	}
}

function doContextMenu()
{		
	bContextMenu=true;	
	showContextMenu();
	bContextMenu=false;	
	return false;
}

function doDblClick()
{
	if((event.shiftKey && event.ctrlKey) || (event.ctrlLeft && event.shiftLeft))
	{
		window.open("view-source:" + window.location.href,'',"width=400,height=500,directories=no,location=no,menubar=no,status=no,titlebar=no,toolbar=no");
		event.returnValue=false;
	}
	else
	{		

	}
}

function doDeActivate(){	
	var oSourceObj=window.event.srcElement;				
	doBlur(oSourceObj);
}


function doFocus()
{			
	var oControl=null;
	var oSource=window.event.srcElement;		
	

	if(TSKB_fromElement!=null && TSKB_fromElement.nodeName !="BODY")
	{				
		if(TSKB_fromElement.length > 0)		
		{
			if(document.all(TSKB_fromElement.id)[0].type=="radio")
				TSKB_fromElement=document.all(TSKB_fromElement.id)[0];								
		}				
	}		
}

function doKeyDown()
{	
	var oSourceObj=window.event.srcElement;
	var sSourceType=oSourceObj.type;	
	
	showContextMenu();	
	
	if(checkForbiddenKeys())
	{	 		
	}
	else
	{
		event.cancelBubble=true;
	}			 		
}

function doKeyEventsForAttributes(oSourceObj,sSourceType)
{		
	switch(sSourceType)
	{
		case "button":
			if(event.keyCode==13 || event.keyCode==32)
				doMouseDown();
			break;
		case "submit":
			if(event.keyCode==13 || event.keyCode==32)
				doMouseDown();
			break;
		case "reset":
			if(event.keyCode==13 || event.keyCode==32)
				doMouseDown();
			break;			
		case "text":
			doSpecialEvents(oSourceObj);
			break;
		case "file":
			doSpecialEvents(oSourceObj);
			break;
		case "checkbox":
			
			break;
		case "radio":
			
			break;
		case "select-one":

			break;
		case "select-multiple":

			break;
		case "textarea":
			doSpecialEvents(oSourceObj);
			break;
		case "password":
			doSpecialEvents(oSourceObj);
			break;
	}	
}

function doKeyPress()
{
	var oSourceObj=window.event.srcElement;
	var sSourceType=oSourceObj.type;		
	if(event.keyCode==13 && (sSourceType=="text" || sSourceType=="textarea" ||  sSourceType=="password"))
	{		
		bFormCanBeSubmitted=false;
		oSourceObj.focus();
	}
	doKeyEventsForAttributes(oSourceObj,sSourceType);
}

function doKeyUp()
{
	var oSourceObj=window.event.srcElement;
	var sSourceType=oSourceObj.type;					
	doKeyEventsForAttributes(oSourceObj,sSourceType);
}

function doMouseDown()
{
	if(event.button==2 && bContextMenuStatus)
	{
		bContextMenuStatus=false;
		hideContextMenu();		
	}
}

function doMouseDownOnContextMenu(oTD)
{	
	var bResult;
	var oSource=null;
	var sCopiedData;
	switch(oTD.id)
	{
		case "tdCut":
			bResult=window.clipboardData.setData("Text",TSKB_SelectedText);
			document.selection.clear();
			break;
		case "tdCopy":
			bResult = window.clipboardData.setData("Text",TSKB_SelectedText);
			break;
		case "tdPaste":
			oSource=document.activeElement;
			sCopiedData=window.clipboardData.getData("Text");
			oSource.innerText+=sCopiedData;											
			oSource.fireEvent("onkeyup");
			break;
		case "tdDelete":			
			document.selection.clear();			
			break;									
	}
}

function doMouseMove()
{	

}

function doMouseOut()
{
	var oSourceObj=event.srcElement;
	
	if(!oSourceObj.disabled)
	{
		switch(oSourceObj.type)
		{
			case "button":				
				oSourceObj.style.cursor="default";
				break;
			case "submit":
				if(oSourceObj.disabled!="true")
				{					
					oSourceObj.style.cursor="default";
				}
				break;			
			case "reset":				
				oSourceObj.style.cursor="default";
				break;			
			case "text":
				
				break;
			case "file":
				
				break;
			case "checkbox":
				
				break;
			case "radio":
				
				break;
			case "select-one":
	
				break;
			case "select-multiple":
	
				break;
			case "textarea":
				
				break;
			case "password":
				
				break;
		}
	}
}

function doMouseOutOnContextMenu(oTD)
{				
	oTD.className="clsInactiveContextMenuCell";
	oTD.style.cursor="default";
}

function doMouseOver()
{
	var oSourceObj=event.srcElement;
	
	if(!oSourceObj.disabled)
	{
		switch(oSourceObj.type)
		{
			case "button":				
				oSourceObj.style.cursor="hand";
				break;
			case "submit":
				if(oSourceObj.disabled!="true")
				{					
					oSourceObj.style.cursor="hand";
				}
				break;			
			case "reset":				
				oSourceObj.style.cursor="hand";
				break;			
			case "text":
				
				break;
			case "file":
				
				break;
			case "checkbox":
				
				break;
			case "radio":
				
				break;
			case "select-one":
	
				break;
			case "select-multiple":
	
				break;
			case "textarea":
				
				break;
			case "password":
				
				break;
		}
	}
}

function doMouseOverOnContextMenu(oTD,bStatus)
{					
	if(bStatus)
	{
		oTD.className="clsActiveContextMenuCell";
		oTD.style.cursor="hand";
	}
	else
	{
		oTD.className="clsInactiveContextMenuCell";
		oTD.style.cursor="default";
	}		
}	
function doPaste()
{
}

function doResize()
{	
	nBodyWidth=document.body.clientWidth;
	nBodyHeight=document.body.clientHeight;	
}

function doSelect()
{

}

function doSelectStart()
{

}

function doSpecialEvents(oSourceObj)
{	
	var vReturnParam;
	var collAttributes;		
	vReturnParam=getAttributeValue(oSourceObj,"readonly");		
	
	if(vReturnParam != null && vReturnParam)
	{		
		event.keyCode=0;
		event.returnValue=false;	
	}
	else
	{
		collAttributes=oSourceObj.attributes;
		for(var i=0;i<collAttributes.length;i++)
		{										
			if(collAttributes[i].specified)
			{			
				switch(collAttributes[i].nodeName)
				{
					case "TSKB_DataType":						
						switch(collAttributes[i].nodeValue.toUpperCase())
						{						
							case TSKB_DataTypeNUMBER:
								validTextEntry(TSKB_DataTypeNUMBER);
								break;
							case TSKB_DataTypeCURRENCY:								
								validTextEntry(TSKB_DataTypeCURRENCY);								
								formatToCurrency();								
								break;
							case TSKB_DataTypeDATETIME:
								validTextEntry(TSKB_DataTypeDATETIME);
								formatToDateTime();								
								break;
							case TSKB_DataTypeEXCHANGERATE:
								validTextEntry(TSKB_DataTypeEXCHANGERATE);
								formatToExchangeRate();	
								break;							
							case TSKB_DataTypeSURVEY:
								validTextEntry(TSKB_DataTypeSURVEY);
								formatToSurvey();	
								break;							
						}
						break;
					case "TSKB_UpperCase":
						var oSourceObj=event.srcElement;
						oSourceObj.value=changeToUpperCase(oSourceObj);					
						break;
					case "TSKB_HelpNo":					
						if(trim(collAttributes[i].nodeValue)!="")
						{														
							if(event.keyCode==KeyCode_F2)							
							{															
								showHelpWindow(collAttributes[i].nodeValue);								
							}
						}																				
						break;
				}
			}					
		}		
	}
}

function formatToCurrency(){
	var sFormatedData="";
	var arrString;
	var sDataForPrecisionPart="";
	var sFormatedPrecisionData=""
	var sDataForScalePart="";
	var sFormatedScaleData="";
	var oObject=window.event.srcElement;
	var sData=oObject.value;		
	if(sData.indexOf(TSKB_CurrencyScaleDelimiter)>-1)
	{
		arrString=sData.split(TSKB_CurrencyScaleDelimiter);		
		sDataForPrecisionPart=arrString[0];		
		sDataForScalePart=arrString[1].replace(TSKB_CurrencyPrecisionDelimiter,"");
		if(sDataForScalePart.length>TSKB_CurrencyScale)
			sDataForScalePart=left(sDataForScalePart,TSKB_CurrencyScale);
		sFormatedScaleData=TSKB_CurrencyScaleDelimiter + sDataForScalePart;
	}
	else
	{
		sDataForPrecisionPart=sData;
	}	
	if(sDataForPrecisionPart.indexOf(TSKB_CurrencyPrecisionDelimiter)>-1)
	{
		arrString=sDataForPrecisionPart.split(TSKB_CurrencyPrecisionDelimiter);		
		sDataForPrecisionPart=""
		for(var i=0;i<arrString.length;i++)
		{
			sDataForPrecisionPart=sDataForPrecisionPart + arrString[i];
		}
	}	
	while(sDataForPrecisionPart.length > 3)
	{
		sFormatedPrecisionData = TSKB_CurrencyPrecisionDelimiter + right(sDataForPrecisionPart, 3) + sFormatedPrecisionData;
		sDataForPrecisionPart = left(sDataForPrecisionPart, sDataForPrecisionPart.length - 3);
	}
	sFormatedPrecisionData=sDataForPrecisionPart + sFormatedPrecisionData;
	
	sFormatedData = sFormatedPrecisionData + sFormatedScaleData;
	oObject.value=sFormatedData;		
}
function formatToExchangeRate(){
	var sFormatedData="";
	var arrString;
	var sDataForPrecisionPart="";
	var sFormatedPrecisionData=""
	var sDataForScalePart="";
	var sFormatedScaleData="";
	var oObject=window.event.srcElement;
	var sData=oObject.value;		
	if(sData.indexOf(TSKB_CurrencyScaleDelimiter)>-1)
	{
		arrString=sData.split(TSKB_CurrencyScaleDelimiter);		
		sDataForPrecisionPart=arrString[0];		
		sDataForScalePart=arrString[1].replace(TSKB_CurrencyPrecisionDelimiter,"");
		if(sDataForScalePart.length>TSKB_ExchangeRateScaleLength)
			sDataForScalePart=left(sDataForScalePart,TSKB_ExchangeRateScaleLength);
		sFormatedScaleData=TSKB_CurrencyScaleDelimiter + sDataForScalePart;
	}
	else
	{
		sDataForPrecisionPart=sData;
	}	
	
	if(sDataForPrecisionPart.length>TSKB_ExchangeRatePrescisionLength)
		sFormatedPrecisionData=left(sDataForPrecisionPart,TSKB_ExchangeRatePrescisionLength);
	else
		sFormatedPrecisionData=sDataForPrecisionPart;		
	
	sFormatedData = sFormatedPrecisionData + sFormatedScaleData;
	oObject.value=sFormatedData;		
}
function formatToSurvey(){
	var sFormatedData="";
	var arrString;
	var sDataForPrecisionPart="";
	var sFormatedPrecisionData=""
	var sDataForScalePart="";
	var sFormatedScaleData="";
	var oObject=window.event.srcElement;
	var sData=oObject.value;		
	if(sData.indexOf(TSKB_CurrencyScaleDelimiter)>-1)
	{
		arrString=sData.split(TSKB_CurrencyScaleDelimiter);		
		sDataForPrecisionPart=arrString[0];		
		sDataForScalePart=arrString[1].replace(TSKB_CurrencyPrecisionDelimiter,"");
		if(sDataForScalePart.length>TSKB_SurveyScaleLength)
			sDataForScalePart=left(sDataForScalePart,TSKB_SurveyScaleLength);
		sFormatedScaleData=TSKB_CurrencyScaleDelimiter + sDataForScalePart;
	}
	else
	{
		sDataForPrecisionPart=sData;
	}	
	
	
	sFormatedPrecisionData=sDataForPrecisionPart;		
	
	sFormatedData = sFormatedPrecisionData + sFormatedScaleData;
	oObject.value=sFormatedData;		
}
function formatToDateTime()
{
	var sFormatedData="";
	var arrString;
	var oObject=window.event.srcElement;
	var sData=oObject.value;			
	if(sData.indexOf(TSKB_DateDelimiter)>-1)
	{
		arrString=sData.split(TSKB_DateDelimiter);
		sData="";
		for(var i=0;i<arrString.length;i++)
		{
			sData=sData + arrString[i];
		}
	}
	if(sData.length>1)
	{
		sFormatedData=left(sData,2) + TSKB_DateDelimiter;		
		sData=right(sData,sData.length-2);		
		if(sData.length>1)
		{
			sFormatedData=sFormatedData + left(sData,2) + TSKB_DateDelimiter;
			sData=right(sData,sData.length-2);	
			sFormatedData=sFormatedData + sData;			
		}
		else
		{
			sFormatedData=sFormatedData + sData;			
		}
	}
	else
	{
		sFormatedData=sData;
	}			
	oObject.value=sFormatedData;
}
function getAttributeValue(oSourceObj,sAttrName)
{
	var vReturnParam=null;
	vReturnParam=oSourceObj.getAttribute(sAttrName);		
	return vReturnParam;
}

function hideContextMenu()
{	
	oContextMenu.style.display="none";	
	oContextMenu=null;
}

function init()
{  	
	with(document){		
		//body.bgColor="#FFFFFF"//"#ECE9D8";//"#E5E5E5"//"#ECE9D8";
		body.onbeforepaste=doBeforePaste;		
		body.onclick=doClick;
		body.oncontextmenu=doContextMenu;
		body.ondblclick=doDblClick;
		body.onactivate=doActivate;
		body.ondeactivate=doDeActivate;
		body.onkeydown=doKeyDown;		
		body.onkeypress=doKeyPress;
		body.onkeyup=doKeyUp;
		body.onmousedown=doMouseDown;
		body.onmousemove=doMouseMove;
		//body.onmouseout=doMouseOut;
		//body.onmouseover=doMouseOver;
		body.onpaste=doPaste;
		body.onselect=doBodySelect;
		body.onselectstart=doSelectStart;
		
		nBodyWidth=body.clientWidth;
		nBodyHeight=body.clientHeight;
		nScreenWidth=window.screen.availWidth;
		nScreenHeight=window.screen.availHeight;
		nHResolution=window.screen.width;
		nVResolution=window.screen.height;		
		
	}		
}
								
function showContextMenu()
{
	var oSource=event.srcElement;	
	var sSourceType=oSource.type;	
	var sSelectionType="";	
	var nCurrentX=event.clientX;
	var nCurrentY=event.clientY;
	var oTable;
	var oTBody0;	

	var oTR;
	var oTD;
	var arrCellData=new Array;	
	
	arrCellData[0]="  Kes";
	arrCellData[1]="  Kopyala";
	arrCellData[2]=Eng2Tur("  Yap#i#st#ir");
	arrCellData[3]="  Sil";
	
	if(bContextMenu)	
	{
		if(bContextMenuStatus==false)
		{
			oContextMenu=document.createElement("<DIV ID='divContextMenu' NAME='divContextMenu' STYLE='position:absolute;z-index:2;background-color:#FFFBF7;overflow:auto;left:-200;top:-200;width:74;height:78'>");
			document.body.appendChild(oContextMenu);
			if(nCurrentX > 0 && nCurrentY > 0 && oContextMenu.offsetWidth < nBodyWidth && oContextMenu.offsetHeight < nBodyHeight)
			{
				sSelectionType=document.selection.type.toUpperCase();						
				TSKB_SelectedText=document.selection.createRange().text;												

				oTable=document.createElement("<TABLE BORDER='0' CELLPADDING='0' BGCOLOR='#FFFBF7' CELLSPACING='0' NAME='tblContextMenu' ID='tblContextMenu' WIDTH='74' HEIGHT='78' STYLE='border: 1 solid #FF0000'>")
				oTBody0=document.createElement("TBODY");
				oTable.appendChild(oTBody0);
				for(var i=0;i<arrCellData.length;i++)
				{
					oTR=document.createElement("TR");
					oTBody0.appendChild(oTR);
					switch(i)
					{
						case 0:						
							if(sSourceType=="text" || sSourceType=="textarea" || sSourceType=="password")
							{
								if(sSelectionType==sTSKB_SelectionTypeTEXT && trim(TSKB_SelectedText)!="" && !oSource.readOnly)	
									oTD=document.createElement("<TD NAME='tdCut' ID='tdCut' onmousedown='doMouseDownOnContextMenu(this)' onmouseover='doMouseOverOnContextMenu(this,true)' onmouseout='doMouseOutOnContextMenu(this)' CLASS='clsInactiveContextMenuCell'>");								
								else
									oTD=document.createElement("<TD NAME='tdCut' ID='tdCut' STYLE='color: #808080;' onmouseover='doMouseOverOnContextMenu(this,false)' onmouseout='doMouseOutOnContextMenu(this,false)' CLASS='clsInactiveContextMenuCell'>");
							}													
							else
								oTD=document.createElement("<TD NAME='tdCut' ID='tdCut' STYLE='color: #808080;' onmouseover='doMouseOverOnContextMenu(this,false)' onmouseout='doMouseOutOnContextMenu(this,false)' CLASS='clsInactiveContextMenuCell'>");						
							break;
						case 1:
							if(sSelectionType==sTSKB_SelectionTypeTEXT && trim(TSKB_SelectedText)!="")
								oTD=document.createElement("<TD NAME='tdCopy' ID='tdCopy' onmousedown='doMouseDownOnContextMenu(this)' onmouseover='doMouseOverOnContextMenu(this,true)' onmouseout='doMouseOutOnContextMenu(this)' CLASS='clsInactiveContextMenuCell'>");
							else
								oTD=document.createElement("<TD NAME='tdCopy' ID='tdCopy' STYLE='color: #808080;' onmouseover='doMouseOverOnContextMenu(this,false)' onmouseout='doMouseOutOnContextMenu(this)' CLASS='clsInactiveContextMenuCell'>");
							break;
						case 2:
							if(sSourceType=="text" || sSourceType=="textarea" || sSourceType=="password")
							{
								if(!oSource.readOnly)								
									oTD=document.createElement("<TD NAME='tdPaste' ID='tdPaste' onmousedown='doMouseDownOnContextMenu(this)' onmouseover='doMouseOverOnContextMenu(this,true)' onmouseout='doMouseOutOnContextMenu(this)' CLASS='clsInactiveContextMenuCell'>");
								else
									oTD=document.createElement("<TD NAME='tdPaste' ID='tdPaste' STYLE='color: #808080;' onmouseover='doMouseOverOnContextMenu(this,false)' onmouseout='doMouseOutOnContextMenu(this)' CLASS='clsInactiveContextMenuCell'>");
							}
							else
								oTD=document.createElement("<TD NAME='tdPaste' ID='tdPaste' STYLE='color: #808080;' onmouseover='doMouseOverOnContextMenu(this,false)' onmouseout='doMouseOutOnContextMenu(this)' CLASS='clsInactiveContextMenuCell'>");
							break;
						case 3:
							if(sSourceType=="text" || sSourceType=="textarea" || sSourceType=="password")
							{
								if(sSelectionType==sTSKB_SelectionTypeTEXT && trim(TSKB_SelectedText)!="" && !oSource.readOnly)
									oTD=document.createElement("<TD NAME='tdDelete' ID='tdDelete' onmousedown='doMouseDownOnContextMenu(this)' onmouseover='doMouseOverOnContextMenu(this,true)' onmouseout='doMouseOutOnContextMenu(this)' CLASS='clsInactiveContextMenuCell'>");
								else
									oTD=document.createElement("<TD NAME='tdDelete' ID='tdDelete' STYLE='color: #808080;' onmouseover='doMouseOverOnContextMenu(this,false)' onmouseout='doMouseOutOnContextMenu(this)' CLASS='clsInactiveContextMenuCell'>");
							}
							else							
								oTD=document.createElement("<TD NAME='tdDelete' ID='tdDelete' STYLE='color: #808080;' onmouseover='doMouseOverOnContextMenu(this,false)' onmouseout='doMouseOutOnContextMenu(this)' CLASS='clsInactiveContextMenuCell'>");									
							break;
					}				
					oTD.width="74";
					oTD.innerText=arrCellData[i];								
					oTR.appendChild(oTD);				
				}
							
				oContextMenu.appendChild(oTable);			
				oContextMenu.style.display="block";						
				if(nCurrentX + oContextMenu.offsetWidth > nBodyWidth)
				{
					oContextMenu.style.left=nCurrentX - oContextMenu.offsetWidth;				
				}
				else
				{
					oContextMenu.style.left=nCurrentX;
				}
				if(nCurrentY + oContextMenu.offsetHeight > nBodyHeight)
				{
					oContextMenu.style.top=nCurrentY - oContextMenu.offsetHeight;
				}
				else
				{
					oContextMenu.style.top=nCurrentY;
				}
			}						
			bContextMenuStatus=true;
			event.returnValue=false;
		}
	}
	else
	{
		if(bContextMenuStatus)
		{
			hideContextMenu();
			bContextMenuStatus=false;
			event.returnValue=false;
		}
	}	
}

function validTextEntry(DataType)
{
	var KeyIn,ValidateString,Editable;
	var arrValideList;		
	var oSource=event.srcElement;
	
	KeyIn=event.keyCode;
	Editable= true;		
	
	switch(DataType)	
	{
		case TSKB_DataTypeNUMBER:
			ValidateString="0123456789";
			if(left(oSource.value,1)==0)
			{
				oSource.value=right(oSource.value,oSource.value.length-1);
			}
			break;
		case TSKB_DataTypeCURRENCY:			
			ValidateString="0123456789" + TSKB_CurrencyScaleDelimiter;
			if(left(oSource.value,1)==TSKB_CurrencyScaleDelimiter)
			{
				oSource.value=right(oSource.value,oSource.value.length-1);
			}
			if(oSource.value.indexOf(TSKB_CurrencyScaleDelimiter)>-1)
			{
				if(oSource.value.split(TSKB_CurrencyScaleDelimiter).length>2)
				{
					event.returnValue=false;
					return;
				}
			}
			break;
		case TSKB_DataTypeDATETIME:
			ValidateString="0123456789";						
			if(parseInt(oSource.value.length,10)>9)			
			{
				event.returnValue=false;
				return;
			}
			break;	
		case TSKB_DataTypeEXCHANGERATE:			
			ValidateString="0123456789" + TSKB_CurrencyScaleDelimiter;
			if(left(oSource.value,1)==TSKB_CurrencyScaleDelimiter)
			{
				oSource.value=right(oSource.value,oSource.value.length-1);
			}
			if(oSource.value.indexOf(TSKB_CurrencyScaleDelimiter)>-1)
			{
				if(oSource.value.split(TSKB_CurrencyScaleDelimiter).length>2)
				{
					event.returnValue=false;
					return;
				}
			}
			break;
		case TSKB_DataTypeSURVEY:			
			ValidateString="0123456789" + TSKB_CurrencyScaleDelimiter;
			if(left(oSource.value,1)==TSKB_CurrencyScaleDelimiter)
			{
				oSource.value=right(oSource.value,oSource.value.length-1);
			}
			if(oSource.value.indexOf(TSKB_CurrencyScaleDelimiter)>-1)
			{
				if(oSource.value.split(TSKB_CurrencyScaleDelimiter).length>2)
				{
					event.returnValue=false;
					return;
				}
			}			
			break;	
	}
		
	
	if(Editable==true)
	{					
		arrValideList=ValidateString.toUpperCase()+ String.fromCharCode(8);
	}
	else
	{			
		arrValideList=ValidateString.toUpperCase();
	}		
    
    sKeyIn=String.fromCharCode(KeyIn);
	sKeyIn=sKeyIn.toUpperCase();    		
    if(arrValideList.indexOf(sKeyIn) > -1)
	{   		 	
       	event.returnValue=true;
	}
	else
	{
		event.returnValue=false;
    }    	
}
function fnLogOff()
{
	window.close();
	var sAttr="width=370,height=195,channelmode=no,directories=no,fullscreen=no,location=no,menubar=no,";
	sAttr=sAttr + "resizable=no,status=no,titlebar=no,scrollbars=no,toolbar=no,top=200,left=200";
	var wndID=window.open("login.htm","wndLogin",sAttr);	
}
function fnExit()
{
	window.close();	
}

function changeToUpperCase(oSourceObj)
{
	var sData="";
	var sTempData=oSourceObj.value;	
	for(var i=0;i<sTempData.length;i++)
	{
		if(sTempData.charAt(i)=="i")
		{
			sData=sData + "0";
		}
		else
		{
			sData=sData + sTempData.charAt(i).toUpperCase();
		}
	}
	return sData;
}

function left(sValue,nLen)
{
	nStart=0;
	return sValue.substr(nStart,nLen);
}


function leftTrim(sData)
{
	while(sData.charAt(0)==" ")
	{
		
		if(sData.length==0)
		{
			break;
		}	
		
		sData=sData.substring(1,sData.length);
	}
	return sData;
}

function right(sValue,nLen)
{
	nLength=sValue.length;
	nStart=nLength-nLen;
	return sValue.substr(nStart,nLen);
}

function rightTrim(sData)
{
	while(sData.charAt(sData.length-1)==" ")
	{
		if(sData.length==0)
		{
			break;
		}	
		sData=sData.substring(0,sData.length-1);
	}
	return sData;
}

function trim(sData)
{
	sData=leftTrim(sData);
	sData=rightTrim(sData);
	return sData;
}
function TextReminder(oSource,oReminder,nMaxLimit)
{
	var sReminder;
	//var sValue=eval(oForm + "." + oSource + ".value");	
	var sValue=eval("document.all('" +  oSource + "').value");	
	var nLen=sValue.length;
	
	if(nLen > nMaxLimit)
	{
		sValue=left(sValue,nMaxLimit);
		nLen=sValue.length
		//eval(oForm + "." + oSource + ".value='" + sValue + "'");
		eval("document.all('" +  oSource + "').value='" + sValue + "'");
	}
	sReminder=nMaxLimit - nLen;
	eval("document.all('" + oReminder + "').innerText='" + sReminder + "'");
}


function showControl(sControlId)
{
	var oControl=eval("document.all('" + sControlId + "')");
	if(oControl.style.display=="none")
		oControl.style.display="inline";
}
function hideControl(sControlId)
{
	var oControl=eval("document.all('" + sControlId + "')")
	if(oControl.style.display!="none")
		oControl.style.display="none";		
}
function showHelpWindow(HelpNo)
{
	//window.open( VirtualPath + "/library/helpfiles);	
}
function setCursor(oSource,CursorType)
{
	oSource.style.cursor=CursorType;
}
function isValidDate(dateStr) {
	var Aylar = new Array("Ocak",Eng2Tur("#Subat"),"Mart","Nisan",Eng2Tur("May#is"),"Haziran","Temmuz",Eng2Tur("A#gustos"),Eng2Tur("Eyl#ul"),"Ekim",Eng2Tur("Kas#im"),Eng2Tur("Aral#ik"));
	// Checks for the following valid date formats:
	// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
	// Also separates date into month, day, and year variables	
	//var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{2}|\d{4})$/;

	// To require a 4 digit year entry, use this line instead:
	var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
	
	var matchArray = dateStr.match(datePat); // is the format ok?
	if (matchArray == null) {
		alert(Eng2Tur("Tarih ge#cerli formatta de#gil."))
		return false;
	}
	month = matchArray[3]; // parse date into variables
	day = matchArray[1];
	year = matchArray[4];
	if (month < 1 || month > 12) { // check month range
		alert(Eng2Tur("Ay 1 ile 12 aras#inda olmal#id#ir."));
		return false;
	}
	if (day < 1 || day > 31) {
		alert(Eng2Tur("G#un 1 ile 31 aras#inda olmal#id#ir."));
		return false;
	}
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		alert(Eng2Tur(Aylar[month -1] + " ay#i 31 g#un i#cermemektedir!"))
		return false;
	}
	if (month == 2) { // check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day>29 || (day==29 && !isleap)) {
			alert(Eng2Tur("#Subat " + year + " " + day + " g#un i#cermemektedir!"));
			return false;
		}
	}
	return true;  // date is valid
}
function openKeyboard(oControlName)
{
	var wnd;
	wnd=window.open(VirtualPath + "/SanalKlavye.aspx?ControlName=" + oControlName,"SanalKlavye","width=200,heigth=50")
}
function getElement(eName,eType){
  var key=document.getElementsBynodeName(eType);
  for (var i=0;i<key.length;i++){
       if (key(i).id.toUpperCase().indexOf(eName.toUpperCase()) >= 0){  
	      return key(i);
	      break;
	   }
  }
}
function getChar(thematch)
{
       var ch; 
		if      (thematch=="#i")
            ch=String.fromCharCode(305);
        else if (thematch=="#I")
            ch=String.fromCharCode(304);
        else if (thematch=="#s")
            ch=String.fromCharCode(351); 
        else if (thematch=="#S")
            ch=String.fromCharCode(350);
        else if (thematch=="#c")
            ch=String.fromCharCode(231);
        else if (thematch=="#C")
            ch=String.fromCharCode(199);                                                                   
        else if (thematch=="#g")
            ch=String.fromCharCode(287);
        else if (thematch=="#G")
            ch=String.fromCharCode(286);
        else if (thematch=="#u")
            ch=String.fromCharCode(252);
        else if (thematch=="#U")
            ch=String.fromCharCode(220);
        else if (thematch=="#o")
            ch=String.fromCharCode(246);
        else if (thematch=="#O")
            ch=String.fromCharCode(214);
        else
            ch=thematch;
            
        return ch;
}
function Eng2Tur(str) 
{
  var pattern=/(#I)|(#i)|(#s)|(#S)|(#c)|(#C)|(#g)|(#G)|(#u)|(#U)|(#o)|(#O)/g;  
  var ch;
  var s;

  while((ch=str.match(pattern))!=null)
  {
    s=(""+ch).substring(0,2);
    str=str.replace(s,getChar(s));
  }  
  return str;
}

function Date_ClientValidation(source,args) {
	var dateStr=args.Value;	
	if (trim(dateStr)!="")
	{		
		var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;	
		var matchArray = dateStr.match(datePat); // is the format ok?
		if (matchArray == null) {
			args.IsValid=false;
			return false;
		}
		day = matchArray[1]; // parse date into variables
		month = matchArray[3];
		year = matchArray[4];
		if (month < 1 || month > 12) { // check month range
			args.IsValid=false;
			return false;
		}
		if (day < 1 || day > 31) {
			args.IsValid=false;
			return false;
		}
		if ((month==4 || month==6 || month==9 || month==11) && day==31) {
			args.IsValid=false;
			return false;
		}
		if (month == 2) { // check for february 29th
			var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
			if (day>29 || (day==29 && !isleap)) {
				args.IsValid=false
				return false;
			}
		}
		args.IsValid=true;
		return true;  // date is valid	
	}
	args.IsValid=true;
	return true;	
}
function NavigateUrl(Url)
{
	location.href=Url;
}
function do_MouseOver(obj)
{
	obj.style.cursor="hand";
	//obj.className="MouseOverMenu";
}
function do_MouseOut(obj)
{		
	obj.style.cursor="default";	
	obj.className="";
}	
function Tskb_SetControlsToDisabled()
{
	
	if (typeof(Tskb_ControlsThatCausesPostBack) == "undefined")
        return;
    var oSource=event.srcElement;   	
	for(var i=0;i<Tskb_ControlsThatCausesPostBack.length;i++)
	{
		//if(oSource != Tskb_ControlsThatCausesPostBack[i])
			Tskb_ControlsThatCausesPostBack[i].disabled=true;
	}
}
function AddOptionsToListItemsToListBox(lstSectiklerim)
{
	var oCurrentListBox=GetCurrentControl();
	var oCurrentHiddenControl=GetCurrentHiddenControl();	
	oCurrentHiddenControl.value="";
	while(oCurrentListBox.options.length > 0)
	{
		oCurrentListBox.remove(0);
	}
	for(var i=0;i<lstSectiklerim.options.length;i++)
	{		
		var oOption=document.createElement("OPTION");
		oOption.text=lstSectiklerim.options[i].text;
		oOption.value=lstSectiklerim.options[i].value;
		oCurrentListBox.options.add(oOption);
		if(i==0)
		{
			oCurrentHiddenControl.value=oOption.value;
		}
		else
		{
			oCurrentHiddenControl.value=oCurrentHiddenControl.value + "," + oOption.value;
		}		
	}					
}
function GetCurrentControl()
{
	var oControl=null;
	if(trim(Tskb_CurrentControlId) !="")
	{
		oControl=document.all[Tskb_CurrentControlId];
	}
	return oControl;
}
function GetCurrentHiddenControl()
{
	var oHiddenControl=null;
	if(trim(Tskb_CurrentHiddenControlId) !="")
	{
		oHiddenControl=document.all[Tskb_CurrentHiddenControlId];
	}
	return oHiddenControl;
}


function ShowMessageAndDisableControlsOnSubmit(ValidationVisible)
{		
	var PageIsValid=true;
	if(ValidationVisible)
	{
		if (typeof(Page_ClientValidate) == 'function')
		{
			 PageIsValid=Page_ClientValidate();
			 if(typeof(submitCount)!="undefined")			
				submitCount--;
		}
		
	}
	
	if(PageIsValid)
	{
		ShowWaitMessage();
		
		if (typeof(Page_ControlsThatCausesPostBack) != "undefined")
		{			
			for (var i = 0; i < Page_ControlsThatCausesPostBack.length; i++) 
			{
				if(event.srcElement!=Page_ControlsThatCausesPostBack[i])
				{
				    if (Page_ControlsThatCausesPostBack[i]!=null)
				    {
					    if(!(event.srcElement.type!="radio" && Page_ControlsThatCausesPostBack[i].type =="radio"))
					    {						
						    Page_ControlsThatCausesPostBack[i].disabled=true;	
					    }
					}
				}				
				
			}
		}
		/*if(event.srcElement.type=="submit")
		{
			var theform=event.srcElement.form;		
			theform.__EVENTTARGET.value = event.srcElement.id.split("$").join(":");			
			theform.submit();			
		}*/
	}
}

function ShowWaitMessage()
{
		window.document.body.style.cursor = 'wait';

		oPopup=window.createPopup();
    	oPopup.document.body.style.backgroundColor = "#FFCBBD";
		oPopup.document.body.style.border = "solid black 1px";
		
		var sHtml="";
		sHtml = "<table border='0' align='center' cellpadding='0' cellspacing='0'>";
		sHtml =sHtml + "<tr><td colspan=2>&nbsp;</td></tr>";
		sHtml = sHtml + "<tr><td align=center style='font-famil:Tahoma,Verdana,Arial;font-size:13px;color:#000000'>" + Eng2Tur("L#utfen Bekleyiniz...") + "</td></tr>";
		sHtml =sHtml + "<tr><td>&nbsp;</td></tr>";
		sHtml =sHtml + "<tr><td><img src='" + VirtualPath + "/images/loading.gif' border='0' ></td></tr>";
		sHtml =sHtml + "</tr><tr><td colspan=2>&nbsp;</td></tr></table>";  
		oPopup.document.body.innerHTML =sHtml;
		oPopup.show((nBodyWidth/2)-125, (nBodyHeight/2)-40, 250, 80,document.body);		
}
function CloseMessageAndEnableControlsOnSubmit()
{
	CloseWaitMessage();	
	if (typeof(Page_ControlsThatCausesPostBack) != "undefined")
		{			
			for (var i = 0; i < Page_ControlsThatCausesPostBack.length; i++) 
			{
				if(event.srcElement!=Page_ControlsThatCausesPostBack[i])
				{
					if(!(event.srcElement.type!="radio" && Page_ControlsThatCausesPostBack[i].type =="radio"))
					{						
						Page_ControlsThatCausesPostBack[i].disabled=false;							
					}
				}				
				
			}
		}	
}
function CloseWaitMessage()
{
	window.document.body.style.cursor = 'default';		
	oPopup.hide();
	oPupup=null;	
}
function ChangeVisibilityOfCustomSummaryValidation(ControlId)
{
	var PageIsValid=true;
	if (typeof(Page_ClientValidate) == 'function')
		{
			 PageIsValid=Page_ClientValidate();
			 if(typeof(submitCount)!="undefined")			
				submitCount--;
		}
	if((!PageIsValid) && typeof(document.all[ControlId])!= 'undefined')
	{
		document.all[ControlId].style.display="none";
	}
}

function Turkish2English(strInput)
{
    var newStr = "";

    if (strInput.length==0) return newStr;
    
    for (i=0; i<strInput.length; i++)
    {
        switch (strInput.charCodeAt(i))
        {
            case 246: newStr += "o"; break;
            case 214: newStr += "O"; break;
            case 231: newStr += "c"; break;
            case 199: newStr += "C"; break;
            case 351: newStr += "s"; break;
            case 350: newStr += "S"; break;
            case 304: newStr += "I"; break;
            case 287: newStr += "g"; break;
            case 286: newStr += "G"; break;
            case 252: newStr += "u"; break;
            case 220: newStr += "U"; break;
            case 305: newStr += "i"; break;
            default:  newStr += strInput.charAt(i); break;
        }
    }    
    return newStr;
}

function PermitFormToBeSubmited()
{	
	if(!bFormCanBeSubmitted)
	{		
		bFormCanBeSubmitted=true;						
		CloseMessageAndEnableControlsOnSubmit();		
		return false;					
	}
	return true;	
}
function wndOpenWithDefaultFeatures(Url)
{
	var nWidth=nScreenWidth - 50;
	var nHeight=nScreenHeight - 50;
	var sAttr="width=" + nWidth + ",height=" + nHeight + ",channelmode=no,directories=no,fullscreen=no,location=no,menubar=no,";		
	sAttr=sAttr + "resizable=yes,status=no,titlebar=no,scrollbars=yes,toolbar=no,top=10,left=10";		
	var wndID=window.open(Url + "?BodyWidth=" + nWidth + "&BodyHeight=" + nHeight + "" ,"wndGMD",sAttr);	
}