function MaxCharacter(ObjectId,MaxLength)
{
    if (document.getElementById(ObjectId).value.length>MaxLength)
    {
        document.getElementById(ObjectId).value = document.getElementById(ObjectId).value.substr(0,MaxLength);
    }
}

function GetYear(Years)
	{
		mySelect = Years;
		
		for (x=0;x<mySelect.options.length;x++)
		{
			document.getElementById("Year_" + mySelect.options[x].value).style.display="none";
			document.getElementById("Year_" + mySelect.options[x].title).style.display="none";
			document.getElementById("Year_" + mySelect.options[x].title).style.left="0px";
		}

		document.getElementById("Year_" + Years.options[Years.selectedIndex].value).style.display="inline";
		document.getElementById("Year_" + Years.options[Years.selectedIndex].value).style.left="0px";

		document.getElementById("Year_" + Years.options[Years.selectedIndex].title).style.display="inline";
		document.getElementById("Year_" + Years.options[Years.selectedIndex].title).style.left="95px";
	}
function OpenToWindow(pageUrl, windowName, width, height, top, left, resizable, scrollbars)
{
	window.open(pageUrl, windowName, 'width='+ width +', height='+ height +', resizable=' + resizable + ', scrollbars=' + scrollbars + ', location=no, toolbar=no, menubar=no, status=no, top=' + top + ', left=' + left );
}

function Reset()
{
    aspnetForm.reset();
}

function isNumeric(ch) 
{
	if (!(ch >= '0' && ch <= '9') && key != 8) 
	{
		return false;
	}
	return true;
}

function FormatNumeric(obj)
{	
    browserType=navigator.appName;
	if (browserType.indexOf('Netscape') >= 0)
    {
		return false;
	}
	
	key = window.event.keyCode;
	ch = String.fromCharCode(key);
	
	if (!isNumeric(ch) && ch !=',' )
	{
		event.returnValue = 0;
	}	
	
	return true;
} 
function showPanels(panelName, panelId)
{
    var elements=document.body.getElementsByTagName('*');
    for (var i=0;i<elements.length; i++ ) {      
        var currentElement = elements[i];
        if (currentElement != null && currentElement.id != null && currentElement.id.indexOf(panelName) > 0) {
            if (currentElement.id != panelId) {
	            currentElement.style.display = "none";
            }
        }
    }

	if (document.getElementById(panelId).style.display != "block")
		document.getElementById(panelId).style.display = "block";
	else
		document.getElementById(panelId).style.display = "none";
}
function showContactPanels(panelId)
{
	for(i=1; i<=4; i++) if (i!=panelId) document.getElementById("bolum" + i).style.display = "none";
	if (document.getElementById("bolum" + panelId).style.display != "block")
		document.getElementById("bolum" + panelId).style.display = "block";
	else
		document.getElementById("bolum" + panelId).style.display = "none";
}
function showContactPanels2(panelId)
{
	for(i=1; i<=4; i++) if (i!=panelId) document.getElementById("bolum" + i).style.display = "none";
		
	if (document.getElementById("bolum" + panelId).style.display != "block")
		document.getElementById("bolum" + panelId).style.display = "block";
	else
		document.getElementById("bolum" + panelId).style.display = "none";
}
function showContactPanels3(panelName, index)
{
    var panels = document.getElementsByName(panelName);
	for(var i=0; i<panels.length; i++) if (i!=index) panels[i].style.display = "none";
	if (panels[index].style.display != "block")
		panels[index].style.display = "block";
	else
		panels[index].style.display = "none";
}
function StringToFormatMoney(ObjectValue)
{
    Object_Value=ObjectValue.toString().replace(".","");
    while(Object_Value.indexOf(".")>-1) Object_Value = Object_Value.replace(".","");

    if (Object_Value.length>1 || Object_Value!="0")
    {
        formatted_money="";
        Kusurat="";
        Kusurat_Pozisyonu=Object_Value.indexOf(",");
        if (Kusurat_Pozisyonu > -1)
        {
	        i_len=Object_Value.length;
	        Kusurat=Object_Value.substring(Kusurat_Pozisyonu,i_len);
	        Object_Value=Object_Value.substring(0,Kusurat_Pozisyonu);
        }

        i_len=Object_Value.length;
        loop_value_a=parseFloat(i_len / 3);
        loop_value_b=parseFloat(Math.floor(i_len / 3));
        if (loop_value_a != loop_value_b)
	        loop_value=loop_value_b+1;
        else
	        loop_value=loop_value_b;

        if (i_len > 3)
        {
	        for (i=0;i<loop_value;i++)
	        {
		        if (i_len > 3)
		        {
			        formatted_money = "." + Object_Value.substring( (i_len-3),i_len ) + formatted_money;
			        i_len = i_len - 3;
			    }
		        else
		        {
			        formatted_money=Object_Value.substring(0,i_len) + formatted_money;
		        }
	        }
	    }
        else
	        formatted_money=Object_Value;

	    ObjectValue = formatted_money + Kusurat;
    }
    
    return ObjectValue;
}

function GetCursorPosition() 
{
    var obj = document.activeElement;
    var cur = document.selection.createRange();
    var pos = 0;
    if (obj && cur) {
    var tr = obj.createTextRange();
    if (tr) 
    {
        while (cur.compareEndPoints("StartToStart", tr) > 0) 
        {
        tr.moveStart("character", 1);
        pos++;
        }
        return pos;
        }
    }
    return -1;
}

function SetCursorPosition(pos) 
{
    var obj = document.activeElement;
    if (obj) 
    {
        var tr = obj.createTextRange();
        if (obj && tr) 
        {
            tr.moveStart("character", pos);
            tr.collapse();
            tr.select();
            return true;
        }
    }
    return false;
}
        
//Start IsDate Functions
function isDate(DateToCheck)
{
    if(DateToCheck==""){return true;}
    var m_strDate = FormatDate(DateToCheck);
    if(m_strDate=="")
    {
        return false;
    }

    var m_arrDate = m_strDate.split("/");
    var m_DAY = m_arrDate[0];
    var m_MONTH = m_arrDate[1];
    var m_YEAR = m_arrDate[2];

    if(m_YEAR.length > 4){return false;}

    m_strDate = m_MONTH + "/" + m_DAY + "/" + m_YEAR;
    var testDate=new Date(m_strDate);

    if(testDate.getMonth()+1==m_MONTH)
    {
        return true;
    } 
    else
    {
        return false;
    }
}

function FormatDate(DateToFormat,FormatAs)
{
    if(DateToFormat==""){return"";}
    if(!FormatAs){FormatAs="dd/mm/yyyy";}

    var strReturnDate;
    FormatAs = FormatAs.toLowerCase();
    DateToFormat = DateToFormat.toLowerCase();
    var arrDate
    var arrMonths = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
    var strMONTH;
    var Separator;

    while(DateToFormat.indexOf("st")>-1){
    DateToFormat = DateToFormat.replace("st","");
    }

    while(DateToFormat.indexOf("nd")>-1){
    DateToFormat = DateToFormat.replace("nd","");
    }

    while(DateToFormat.indexOf("rd")>-1){
    DateToFormat = DateToFormat.replace("rd","");
    }

    while(DateToFormat.indexOf("th")>-1){
    DateToFormat = DateToFormat.replace("th","");
    }

    if(DateToFormat.indexOf(".")>-1){
    Separator = ".";
    }

    if(DateToFormat.indexOf("-")>-1){
    Separator = "-";
    }

    if(DateToFormat.indexOf("/")>-1){
    Separator = "/";
    }

    if(DateToFormat.indexOf(" ")>-1){
    Separator = " ";
    }

    arrDate = DateToFormat.split(Separator);
    DateToFormat = "";
	for(var iSD = 0;iSD < arrDate.length;iSD++)
	{
		if(arrDate[iSD]!="")
		{
		    DateToFormat += arrDate[iSD] + Separator;
		}
	}
    DateToFormat = DateToFormat.substring(0,DateToFormat.length-1);
    arrDate = DateToFormat.split(Separator);

    if(arrDate.length < 3){return "";}

    var DAY = arrDate[0];
    var MONTH = arrDate[1];
    var YEAR = arrDate[2];

    if(parseFloat(arrDate[1]) > 12)
    {
        DAY = arrDate[1];
        MONTH = arrDate[0];
    }

    if(parseFloat(DAY) && DAY.toString().length==4)
    {
        YEAR = arrDate[0];
        DAY = arrDate[2];
        MONTH = arrDate[1];
    }

for(var iSD = 0;iSD < arrMonths.length;iSD++)
{
    var ShortMonth = arrMonths[iSD].substring(0,3).toLowerCase();
    var MonthPosition = DateToFormat.indexOf(ShortMonth);
	
	if(MonthPosition > -1)
	{
    	MONTH = iSD + 1;
		if(MonthPosition == 0)
		{
		    DAY = arrDate[1];
		    YEAR = arrDate[2];
		}
    	break;
	}
}

    var strTemp = YEAR.toString();
    if(strTemp.length==2)
    {
	    if(parseFloat(YEAR)>40)
	    {
	        YEAR = "19" + YEAR;
	    }
	    else
	    {
	        YEAR = "20" + YEAR;
	    }
    }

	if(parseInt(MONTH)< 10 && MONTH.toString().length < 2)
	{
	    MONTH = "0" + MONTH;
	}
	
	if(parseInt(DAY)< 10 && DAY.toString().length < 2)
	{
	    DAY = "0" + DAY;
	}
	
	switch (FormatAs)
	{
	    case "dd/mm/yyyy":
	    return DAY + "/" + MONTH + "/" + YEAR;
	    case "mm/dd/yyyy":
	    return MONTH + "/" + DAY + "/" + YEAR;
	    case "dd/mmm/yyyy":
	    return DAY + " " + arrMonths[MONTH -1].substring(0,3) + " " + YEAR;
	    case "mmm/dd/yyyy":
	    return arrMonths[MONTH -1].substring(0,3) + " " + DAY + " " + YEAR;
	    case "dd/mmmm/yyyy":
	    return DAY + " " + arrMonths[MONTH -1] + " " + YEAR;	
	    case "mmmm/dd/yyyy":
	    return arrMonths[MONTH -1] + " " + DAY + " " + YEAR;
	}

    return DAY + "/" + strMONTH + "/" + YEAR;;
} 
//End IsDate Functions
