function getObj(name)
{
    if (document.getElementById)
    {
        this.obj = document.getElementById(name);
        //  this.style = document.getElementById(name).style;
    }
    else if (document.all)
    {
        this.obj = document.all[name];
        this.style = document.all[name].style;
    }
    else if (document.layers)
    {
        this.obj = document.layers[name];
        this.style = document.layers[name];
    }
}
function close(e)
{
    var keycode;
    if(document.getElementById('dvResult').style.display == 'block')
    {
        if(window.event)
        {
           keycode = window.event.keyCode;
        }
        else if(e)
        {
            keycode = e.which;
        }
        if(keycode == 27)
        {
            document.getElementById('dvResult').style.display = 'none';
        }
   }  
}
function MessageBoxConfirm(msg)
{
    var conf = confirm(msg);
    if(conf)
        return true;
    else
        return false;
}
function AddMessageBoxConfirm(msg,path)
{
    var conf = confirm(msg);
    if(conf)
        location.href=path;
    else
        location.href='default.aspx';
        return false;
}
function IsNumeric(objId)
{
    var txt = document.getElementById(objId);
    if(txt.value > 0)
    {
        
    }
    else
    {
        txt.value = txt.value.substring(0,txt.value.length-1);
    }
}
function showLargeImage(path)
{
    window.open('large.htm?'+path,null,"width=800,height=600,toolbar=0,scrollbars=0");
}
function showNewsGallery(id)
{
    window.open('newsGallery.aspx?newsId='+id,null,"width=800,height=600,toolbar=0,scrollbars=0");
}

function loadDealers(dvId,url)
{
    var xmlHttp = new ajax();
    var ddlCity = document.getElementById('ddlCity');
    url += '?'+Math.random(100);
    if(ddlCity.selectedIndex > 0)
    {
       
        url +='&city='+ddlCity.options[ddlCity.selectedIndex].value;
        if(xmlHttp)
        {
            var mainDiv = document.getElementById(dvId);
           
            xmlHttp.onreadystatechange = function()
            {
                if(xmlHttp.readyState == 3)
                {
                    mainDiv.innerHTML = '';
                    mainDiv.innerHTML = '<table cellpadding="0" cellspacing="0" border="0px" width="100%"><tr><td style="width:100%; height:300px; text-align:center; vertical-align=middle"><img id="imgLoading" src="Images/loading.gif" /></td></tr></table>';
                }
                else if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
                {
                    try
                    {
                        mainDiv.innerHTML = '';
                        mainDiv.innerHTML = xmlHttp.responseText;
                    }
                    catch(e)
                    {
                        mainDiv.innerHTML = '';
                        var childDiv = document.createElement('Div');
                        childDiv.innerHTML = xmlHttp.responseText;
                        mainDiv.appendChild(childDiv);
	      
                    }
                }
                
            }
            
            xmlHttp.open('get',url,true);
            xmlHttp.send(null);
           mainDiv.style.height="";
        }
    }
}
function loadSupport(dvId,url)
{
    var ddlType = document.getElementById('ddlType');
    var ddlCity = document.getElementById('ddlCity');
    var mainDiv = document.getElementById(dvId);
    
    url += '?'+Math.random(100)+'&type='+ddlType.options[ddlType.selectedIndex].value;    
    url += '&city='+ddlCity.options[ddlCity.selectedIndex].value
    
    xmlHttp = new ajax();
    if(xmlHttp)
    {
        xmlHttp.onreadystatechange=function()
        {
            if(xmlHttp.readyState == 2)
            {
                mainDiv.innerHTML = '<table cellpadding="0" cellspacing="0" border="0px" width="100%"><tr><td style="width:100%; height:300px; text-align:center; vertical-align=middle"><img id="imgLoading" src="Images/loading.gif" /></td></tr></table>';
            }
            else if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
            {
                try
                {
                    mainDiv.innerHTML = '';
                    mainDiv.innerHTML = xmlHttp.responseText;
                }
                catch(e)
                {
                    mainDiv.innerHTML = '';
                    var childDiv = document.createElement('Div');
                    childDiv.innerHTML = xmlHttp.responseText;
                    mainDiv.appendChild(childDiv);
                }                
            }
            
        }
        
        xmlHttp.open('get',url,true);
        xmlHttp.send(null);
       mainDiv.style.height='';
    }
}
function loadDealersForm(dvId,url)
{
    var xmlHttp = new ajax();
    url += '?'+Math.random(100);
    if(xmlHttp)
    {
        var mainDiv = document.getElementById(dvId);
         

        xmlHttp.onreadystatechange = function()
        {
            if(xmlHttp.readyState == 3)
            {
                mainDiv.innerHTML = '';
                mainDiv.innerHTML = '<img id="imgLoading" src="Images/loading.gif" />';
            }
            else if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
            {
                try
                {
                    mainDiv.innerHTML = '';
                    mainDiv.innerHTML = xmlHttp.responseText;
                }
                catch(e)
                {
                    mainDiv.innerHTML = '';
                    var childDiv = document.createElement('Div');
                    childDiv.innerHTML = xmlHttp.responseText;
                    mainDiv.appendChild(childDiv);
                }
            }
            
        }
        xmlHttp.open('get',url,true);
        xmlHttp.send(null);
        mainDiv.style.height='';
    }
}
function sendDealersForm(dvId,url)
{
    
    var xmlHttp = new ajax();
    url += '?'+Math.random(100);
    if(xmlHttp)
    {
        var mainDiv = document.getElementById(dvId);
        var txtName = document.getElementById('txtName');
        var txtMail = document.getElementById('txtMail');
        var txtCompany = document.getElementById('txtCompany');
        var txtPhone = document.getElementById('txtPhone');
        var txtAddress = document.getElementById('txtAddress');
        var ddlCity = document.getElementById('ddlCity');
        var msg,cntrl = true;  
        msg = '';
        
        
        if(txtName.value == '')
        {
          msg = '- Adınızı ve soyadınızı girin...'+'\n';
          cntrl = false;
        }
        if(txtMail.value == '')
        {
          msg += '- E-mail adresinizi girin...'+'\n';
          cntrl = false;
        }
        else
        {
            if(txtMail.value.indexOf('@') == -1 || txtMail.value.indexOf('.') == -1)
            {
              msg += '- E-mail adresinizi geçersizdir...'+'\n';
              cntrl = false;
            }
        }
        if(txtCompany.value == '')
        {
          msg += '- Şirket adını girin...'+'\n';
          cntrl = false;
        }
        if(txtPhone.value == '')
        {
          msg += '- İrtibat için telefon numaranızı girin...'+'\n';
          cntrl = false;
        }
        if(txtAddress.value == '')
        {
          msg += '- Adresinizi girin...';
          cntrl = false;
        }
        if(cntrl != false)
        {    
            var data = 'txtName='+txtName.value+'&txtCompany='+txtCompany.value+'&txtPhone='+txtPhone.value+'&txtMail='+txtMail.value+'&txtAddress='+txtAddress.value+'&ddlCity='+ddlCity.options[ddlCity.selectedIndex].value;
            xmlHttp.onreadystatechange = function()
            {
                if(xmlHttp.readyState == 3)
                {
                    mainDiv.innerHTML = '';
                    mainDiv.innerHTML = '<img id="imgLoading" src="Images/loading.gif" />';
                }
                else if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
                {
                    try
                    {
                        mainDiv.innerHTML = '';
                        mainDiv.innerHTML = xmlHttp.responseText;
                    }
                    catch(e)
                    {
                        mainDiv.innerHTML = '';
                        var childDiv = document.createElement('Div');
                        childDiv.innerHTML = xmlHttp.responseText;
                        mainDiv.appendChild(childDiv);
                    }
                }
                
            }
            xmlHttp.open('Post',url,true);
            xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
            xmlHttp.setRequestHeader("Content-length", data.length);
            xmlHttp.setRequestHeader("Connection", "close");
            xmlHttp.send(data);
            return true;
        }
        else
        {
            alert(msg);
            return false;
        }
    }
}
function loadQuestion(dvId,url)
{
    xmlHttp = new ajax();
    if(url.indexOf('?') > -1)
    {
        url += '&'+Math.random(100);
    }
    else
    {
        url += '?'+Math.random(100);
    }
    if(xmlHttp)
    {
        var mainDiv = document.getElementById(dvId);
        xmlHttp.onreadystatechange = function()
        {
            if(xmlHttp.readyState == 3)
            {
                mainDiv.innerHTML = '';
                mainDiv.innerHTML = '<img id="imgLoading" src="Images/loading.gif" />';
            }
            else if(xmlHttp.readyState == 4 && xmlHttp.status == 200)
            {
                try
                {
                    mainDiv.innerHTML = '';
                    mainDiv.innerHTML = xmlHttp.responseText;
                }
                catch(e)
                {
                    mainDiv.innerHTML = '';
                    var childDiv = document.createElement('Div');
                    childDiv.innerHTML = xmlHttp.responseText;
                    mainDiv.appendChild(childDiv);
                }
            }
        }
        xmlHttp.open('get',url,true);
        xmlHttp.send(null);
    }
}