﻿// Genel eklenen js fonksiyonarı içindir

function numbersonly( e )
{
        var unicode = e.charCode ? e.charCode : e.keyCode;
        if( unicode != 8 )
        {
            if( unicode < 48 || unicode > 57 )
            {
                return false;
            }
            else
            {            
                return true;
            }
        }
        else
        {
           return true;
        }
}

function SwapMenuBg(item,actionType)
{
    if(actionType=="Over")
    {
        //item.style.background = "url(images/subMenuULbg.gif)";
        item.style.background = "url(images/arrowbullet.png) no-repeat center left";
        item.style.backgroundColor = "#009900";
        item.style.color = "white";
        //item.style.backgroundColor = "#EDEDED";
    }
    else
    {
        //item.style.background = "url(images/subMenubg.gif)";
        item.style.backgroundColor = "";
        item.style.background = "";
        item.style.color = "#004890";
    }
}

function phoneLengthControl(weCallYouPhoneAreaCodeMessage,weCallYouPhoneMessage,areaCodeRequired,areaCodeLengthInvalid,phoneRequired,phoneLengthInvalid )
{
    if(document.getElementById('phoneAreaCode').value==''||document.getElementById('phoneAreaCode').value==weCallYouPhoneAreaCodeMessage)
    {
        alert(areaCodeRequired);
        document.getElementById('phoneAreaCode').focus();        
        return false;
    }
    else if(document.getElementById('phoneAreaCode').value.length<3)
    {
        alert(areaCodeLengthInvalid);
        document.getElementById('phoneAreaCode').focus();        
        return false;
    }
    else if(document.getElementById('phone').value==''||document.getElementById('phone').value==weCallYouPhoneMessage)
    {
        alert(phoneRequired);
        document.getElementById('phone').focus();        
        return false;
    }
    else if(document.getElementById('phone').value.length<7)
    {
        alert(phoneLengthInvalid);
        document.getElementById('Phone').focus();        
        return false;
    }
    else{
        return true;}
}
function OpenPopup(firstNameRequiredMessage,lastNameRequiredMessage,weCallYouPhoneAreaCodeMessage,weCallYouPhoneMessage,areaCodeRequired,areaCodeLengthInvalid,phoneRequired,phoneLengthInvalid)
{
    if(document.getElementById('name').value=='')
    {
        alert(firstNameRequiredMessage);
        document.getElementById('name').focus();  
    }
    else if(document.getElementById('lastname').value=='')
    {
        alert(lastNameRequiredMessage);
        document.getElementById('lastname').focus();  
    }
    else if(phoneLengthControl(weCallYouPhoneAreaCodeMessage,weCallYouPhoneMessage,areaCodeRequired,areaCodeLengthInvalid,phoneRequired,phoneLengthInvalid))
    {
        var name = document.getElementById('name').value;
        var lastname = document.getElementById('lastname').value;
        var phone = document.getElementById('phoneAreaCode').value+document.getElementById('phone').value;
        var url = 'AnswerQuestions.aspx?name=' + name + '&lastname=' + lastname + '&phone=' + phone;
        document.getElementById('name').value='';
        document.getElementById('lastname').value='';
        document.getElementById('phoneAreaCode').value='';
        document.getElementById('phone').value='';
        window.open(url,'','width=570,height=340,scrollbars=0,toolbar=0,status=0,resizable=0,menubar=0');
    }

}
function OpenPopupEBulten(inputmessage,alertmessage)
{
    if(checkbae(document.getElementById('elist'),inputmessage,alertmessage))
    {
        var email = document.getElementById('elist').value;
        var url = 'EBultenApplication.aspx?email=' + email;
        //document.getElementById('elist').value='';
        window.open(url,'','width=499,height=291,scrollbars=0,toolbar=0,status=0,resizable=0,menubar=0');
    }
}


function checkemail(input,inputmessage,alertmessage)
{
    var testresults;
    var str;
    if(input==null)
        str='';
    else
        str=input.value;
    var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
    if (filter.test(str))
        testresults=true
    else
    {   if(str!='')
            alert(alertmessage)
        testresults=false            
    }
    if(testresults==false)
    {
        input.value=inputmessage;
    }
    return (testresults)
}

function checkbae(input,inputmessage,alertmessage)
{
    if(input.value=='')
    {   
        input.value=inputmessage;
        return false;
    }
    return checkemail(input,inputmessage,alertmessage)
}

function checkXss() 
{
    var txt =  window.event;
    var charCode = (txt.which) ? txt.which : txt.keyCode;
    if (charCode == 37 || charCode == 39 ||  charCode == 40 ||  charCode == 41 ||  charCode == 60 ||  charCode == 62 || charCode == 58 ||  charCode == 59 ||  charCode == 34 ||  charCode == 96 ||  (charCode >= 145 &&  charCode <= 148) ||  charCode == 180) {
        return false;
    }
    return true
}
