﻿var ajaxReq;

function $(id) { return document.getElementById(id); }

function hide(obj) { $(obj).style.display='none'; }
function show(obj) { $(obj).style.display=''; }
function hideshow(obj) { $(obj).style.display = ($(obj).style.display == 'none' ? '' : 'none'); };

function ajaxSend(url, params, onReceive) {
    ajaxReq = null;
	if(window.XMLHttpRequest) ajaxReq = new XMLHttpRequest();
	else if(window.ActiveXObject) ajaxReq = new ActiveXObject("Microsoft.XMLHTTP");
	else return false;
	
	ajaxReq.open("POST", url, true);
	ajaxReq.onreadystatechange = onReceive;
	ajaxReq.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	ajaxReq.send(params);
}

function ajaxCancel() {
    if(ajaxReq) {
        ajaxReq.onreadystatechange = function () {}
        ajaxReq.abort();
    }
}

function refreshSiteMenu() {
     var addr = window.location.pathname;
     var page = addr.substring(addr.lastIndexOf('/') + 1);
     switch(page) {
        case "nasil.aspx" : hideshow('menusub_nasil'); break;
        case "rehber.aspx" : hideshow('menusub_rehber'); break;
        case "icerik.aspx" : hideshow('menusub_icerik'); break;
        case "destek.aspx" : hideshow('menusub_destek'); break;
        default: break;
     }
}

/*
function ajaxReceive() {
    if (ajaxReq.readyState == 4 && ajaxReq.status == 200) {
		var ajaxRes = ajaxReq.responseText;
		$('res').innerHTML = ajaxRes;
	}
}
*/