function popUp(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0, scrollbars=1, location=0, statusbar=0, menubar=0,resizable=1, width=450, height=300, left = 400, top = 15 0');");
}

function popPencere(URL, myWidth, myHeight, myLeft, myTop)
{
    day = new Date();
    id = day.getTime();

    if (myWidth == 0) myWidth = 450;
    if (myHeight == 0) myHeight = 300;

    var winLeft = (screen.width-myWidth)/2;
    var winTop = (screen.height-myHeight)/2;
    if (myLeft == 0) myLeft = winLeft;
    if (myTop == 0) myTop = winTop;
    
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0, scrollbars=1, location=0, statusbar=0, menubar=0,resizable=1, width=" + myWidth + ", height=" + myHeight + ", left = " + myLeft + ", top = " + myTop + "');");
}

function GetXmlHttpObject()
{
    var xmlHttp=null;
    try { return new XMLHttpRequest(); } catch(e) {}
    try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) {}
    try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
    alert("XMLHttpRequest not supported");
    return null;
    return xmlHttp;
}

function getCheckedRadio(FieldName)
{    
	var kutular = document.getElementsByName(FieldName);
	var uzunluk = kutular.length;
	
	for(var i = 0; i < uzunluk; i++)
	{
        if(kutular[i].checked) return kutular[i].value;
	}
}

function increaseFontSize()
{
    var min=9;
    var max=15;
    var p = document.getElementsByTagName('p');
    for(i=0;i<p.length;i++)
    {
      if(p[i].style.fontSize)
      {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 11;
      }
      if(s!=max)
      {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
    }
}

function increaseFontSizeAll()
{
    var min=9;
    var max=15;
    var b = document.getElementsByTagName('body');
	if(b[0].style.fontSize)
	{
		var s = parseInt(b[0].style.fontSize.replace("px",""));
	} else {
		var s = 11;
	}
	if(s!=max) s += 1;
	b[0].style.fontSize = s+"px"
}

function decreaseFontSize()
{
    var min=9;
    var max=15;
    var p = document.getElementsByTagName('p');
    for(i=0;i<p.length;i++)
    {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 11;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
    }   
}

function secilmisBox(FieldName)
{
	var kutular = document.getElementsByName(FieldName);
	var uzunluk = kutular.length;
	
	for(var i = 0; i < uzunluk; i++)
	{
		if(kutular[i].checked == true)
		{
			return kutular[i].value;
		}
	}
}

function secilmisBoxes(FieldName)
{
	var kutular = document.getElementsByName(FieldName);
	var uzunluk = kutular.length;
	var veriler = "";
	
	for(var i = 0; i < uzunluk; i++)
	{
		if(kutular[i].checked == true)
		{
			if (veriler != "")
			{
				veriler = veriler +  ":";
			} 
			veriler = veriler + kutular[i].value;
		}
	}
	return veriler;
}

function DunyadanHaberler(id)
{
	xmlHttpDunyadanHaberler = GetXmlHttpObject();

	var url="index.php?name=anasayfa&op=dunyadan_haberler";
	url=url+"&id="+id;
	url=url+"&sid="+Math.random();
	
	xmlHttpDunyadanHaberler.onreadystatechange=function()
	{
		if(xmlHttpDunyadanHaberler.readyState == 4)
		{
			//if(xmlHttpDunyadanHaberler.responseText != "") window.location = xmlHttpDunyadanHaberler.responseText;
		}
	}
 
	xmlHttpDunyadanHaberler.open("GET", url, true);
	xmlHttpDunyadanHaberler.send(null);
}

function YerelBasin(id)
{
	xmlHttpYerelBasin = GetXmlHttpObject();

	var url="index.php?name=anasayfa&op=yerel_basin";
	url=url+"&id="+id;
	url=url+"&sid="+Math.random();
	
	xmlHttpYerelBasin.onreadystatechange=function()
	{
		if(xmlHttpYerelBasin.readyState == 4)
		{
			//if(xmlHttpYerelBasin.responseText != "") window.location = xmlHttpYerelBasin.responseText;
		}
	}
 
	xmlHttpYerelBasin.open("GET", url, true);
	xmlHttpYerelBasin.send(null);
}

function MailListEkle()
{
	var email = document.getElementById("maillist-mail").value;
	xmlHttpMaillistEkle = GetXmlHttpObject();

	var url="index.php?name=anasayfa&op=maillist";
	url=url+"&email="+email;
	url=url+"&sid="+Math.random();
	
	xmlHttpMaillistEkle.onreadystatechange=function()
	{
		if(xmlHttpMaillistEkle.readyState == 4)
		{
			document.getElementById("maillist-submit").disabled = false;
			if(xmlHttpMaillistEkle.responseText.indexOf("Hata") != -1)
			{
				alert(xmlHttpMaillistEkle.responseText);
				return false;
			}
			else
			{
				alert(xmlHttpMaillistEkle.responseText);
				document.getElementById("maillist-mail").value = "";
			}
		}
		else
		{
			document.getElementById("maillist-submit").disabled = true;
		}
	}
 
	xmlHttpMaillistEkle.open("GET", url, true);
	xmlHttpMaillistEkle.send(null);
}

function anasayfaAnketiOyla(pollID, voteID)
{
	if(pollID == null || pollID == 0 || voteID == null || voteID == 0)
	{
		alert("Lütfen anketi oylayınız...");
	}
	else
	{
		xmlHttpAnketOyla=GetXmlHttpObject();
		var url="index.php?name=anketler&op=anket_oy_ver";
		url=url+"&pollID="+pollID+"&voteID="+voteID;
		url=url+"&sid="+Math.random();

		xmlHttpAnketOyla.onreadystatechange=function()
		{
			if(xmlHttpAnketOyla.readyState==4)
			{
				if(xmlHttpAnketOyla.responseText.indexOf("Hata") != -1)
				{
					document.getElementById('anket-submit-button').disabled = false;
					alert(xmlHttpAnketOyla.responseText);
				}
				else
				{
					document.getElementById('anket-icerik').innerHTML = xmlHttpAnketOyla.responseText;
				}
			}
			else
			{
				document.getElementById('anket-submit-button').disabled = true;
			}
		}
		
		xmlHttpAnketOyla.open("GET", url, true);
		xmlHttpAnketOyla.send(null);
	}
}

function aramaSonuclariniGoster(query)
{
	if(query.length < 3) return false;

    var up_element = document.getElementById('content');
	
    var alan_top = parseInt(up_element.offsetTop);
    var alan_left = parseInt(up_element.offsetLeft + up_element.offsetWidth - 200);

	xmlHttpASG=GetXmlHttpObject();

	var url = "index.php?name=arama&op=arama_onerilerini_goster";
	url = url+"&query="+query;
	url = url+"&sid="+Math.random();

	xmlHttpASG.onreadystatechange=function()
	{
		if(xmlHttpASG.readyState==4)
		{
			if(xmlHttpASG.responseText.indexOf("NoKeyWord") == -1)
			{
				document.getElementById('searchresultsarea').style.top = alan_top + "px";
				document.getElementById('searchresultsarea').style.left = alan_left + "px";
				document.getElementById('searchresultsarea').style.display = "block";
				document.getElementById('searchresultsarea').innerHTML = xmlHttpASG.responseText;
			}
		}
		else
		{
			//document.getElementById("searchresultsarea").innerHTML = xmlHttpASG.responseText;
		}
	}

	xmlHttpASG.open("GET", url, true);
	xmlHttpASG.send(null);
}

