﻿function Set_Cookie( name, value, expires, path, domain, secure )
{
    // set time, it's in milliseconds
    var today = new Date();
    today.setTime( today.getTime() );

    if ( expires )
    {
        expires = expires * 1000 * 60 * 60 * 24;
    }
    var expires_date = new Date( today.getTime() + (expires) );

    document.cookie = name + "=" +escape( value ) +
    ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
    ( ( path ) ? ";path=" + path : "" ) + 
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ( ( secure ) ? ";secure" : "" );
}

// this function gets the cookie, if it exists
function Get_Cookie( name ) {
	
    var start = document.cookie.indexOf( name + "=" );
    var len = start + name.length + 1;
    if ( ( !start ) &&
    ( name != document.cookie.substring( 0, name.length ) ) )
    {
        return null;
    }
    if ( start == -1 ) return null;
        var end = document.cookie.indexOf( ";", len );
    if ( end == -1 ) end = document.cookie.length;
        return unescape( document.cookie.substring( len, end ) );
}

function Get_Zoom_Value()
{
    if(Get_Cookie('zoomValue')!=null)
    {
    var ZoomValue = parseInt(Get_Cookie('zoomValue'));
        return ZoomValue;
    }
    else
    {
    var ZoomValue = '100';
        return ZoomValue;
    }
}

// this deletes the cookie when called
function Delete_Cookie( name, path, domain ) {
    if ( Get_Cookie( name ) ) document.cookie = name + "=" +
        ( ( path ) ? ";path=" + path : "") +
        ( ( domain ) ? ";domain=" + domain : "" ) +
        ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}

function oZoom_Zoom_Value()
{
    if(Get_Cookie('zoomValue')!=null)
    {
    var ZoomValue = parseInt(Get_Cookie('zoomValue'))+'%';
        return 'Style: '+ZoomValue+'%';
    }
    else
    {
    var ZoomValue = '100%';        
        return 'Style: '+ZoomValue+'%';
    }
}

function SubMenuAc(Hedef){
if(navigator.appName!='Netscape')
{
var HedefSub = document.getElementById(Hedef);
    if(HedefSub.style.display != "block")
    {
        document.getElementById('anasayfa').style.display="none";
        document.getElementById('bizkimiz').style.display="none";
        document.getElementById('saglikliyasam').style.display="none";
        document.getElementById('yasliliktaaktifyasam').style.display="none";
        document.getElementById('yasliligadair').style.display="none";
        document.getElementById('arastirmalar').style.display="none";
        document.getElementById('bilgibankasi').style.display="none";
        document.getElementById('ilanpanosu').style.display="none";
    }
    Set_Cookie('menuName', Hedef, 1, '/', '', '');
    
	if(document.getElementById)
	{
	
		if(HedefSub.style.display != "block")
		{
			HedefSub.style.display = "block";
		}
		else
		{
			HedefSub.style.display = "none";
		}
	}
}
}


function zoomInOZoom() {
  newZoom= parseInt(Get_Cookie('zoomValue'))+20+'%'
      oZoom.style.zoom =newZoom;
  Set_Cookie('zoomValue', parseInt(Get_Cookie('zoomValue'))+20, '', '/','', '');
} 
  
function zoomOutOZoom() {
  if(Get_Cookie('zoomValue')>100)
  {
     newZoom= parseInt(Get_Cookie('zoomValue'))-20+'%'
     oZoom.style.zoom =newZoom;
     Set_Cookie('zoomValue', parseInt(Get_Cookie('zoomValue'))-20, '', '/','', '');
  }
} 

function fixOZoom() {
  newZoom= '100%'
      oZoom.style.zoom =newZoom;
  Set_Cookie('zoomValue', 1, '', '/','', '');
} 

function Get_Cursor_Name()
{
    if(Get_Cookie('cursorName')!=null)
    {
        var cursorName = Get_Cookie('cursorName');
        return cursorName;
    }
    else 
    {
        cursorName = 'images/arrow_m.cur';
        return cursorName;
    }
}

function Get_Menu_Name()
{
    if(Get_Cookie('menuName')!=null)
    {
        var cursorName = Get_Cookie('menuName');
        return cursorName;
    }
    else 
    {
        cursorName = "anasayfa"
        return cursorName;
    }
}

function Get_Menu_Bg()
{
    if(Get_Cookie('menuBg')!=null)
    {
        var menuId = Get_Cookie('menuBg');
        return menuId;
    }
    else
    {
        menuId = "";
        return menuId;
    }
}

function Get_Css_File()
{
    if(Get_Cookie('cssFile')!=null)
        return Get_Cookie('cssFile');
    else
        return 'style.css';
}

function setStyleSheet(styleId, fileName)
{
    document.getElementById(styleId).href=fileName;
    Set_Cookie('cssFile',fileName,1,'/','','');
}

function Set_Menu_Bg(menuId)
{
    Set_Cookie('menuBg',menuId,1,'/','','');
}

function setAllCookiesOfPage()
{   
        Set_Cookie('zoomValue', Get_Zoom_Value(), 1, '/', '', '');
        Set_Cookie('cursorName', Get_Cursor_Name(), 1, '/', '', '');
        Set_Cookie('menuName', Get_Menu_Name(), 1, '/', '', '');
        Set_Cookie('menuBg', Get_Menu_Bg(), 1, '/', '', '');
        Set_Cookie('cssFile', Get_Css_File(), 1, '/', '', '');
        
        document.getElementById('cssSheet').href=Get_Css_File();
        
        if(document.getElementById(Get_Menu_Bg()))
        {
            if(document.getElementById('cssSheet').href=='style.css')
                document.getElementById(Get_Menu_Bg()).style.backgroundColor = "#C6E2F4";
            else
                document.getElementById(Get_Menu_Bg()).style.backgroundColor = "#ffa779";;
        }
        
        
    document.body.style.cursor = Get_Cursor_Name();
    SubMenuAc(Get_Menu_Name());
}

function cursorBuyut()
{
    document.body.style.cursor = "images/arrow_il.cur";
    Set_Cookie('cursorName', 'images/arrow_il.cur', 1, '/', '', '');
}

function cursorKucult()
{
    document.body.style.cursor = "images/arrow_i.cur";
    Set_Cookie('cursorName', 'images/arrow_i.cur', '', '/', '', '');
}

function normalCursor()
{
    document.body.style.cursor = "images/arrow_m.cur";
    Set_Cookie('cursorName', '', '', '/', '', '');
}

function KeyDownHandler(btn)
    {
        if(navigator.appName!='Netscape')
        {
            if (event.keyCode == 13)
            {
               var button;
               button=document.getElementById(btn);
               event.returnValue=false;
               event.cancel = true;
               button.click();
            }
        }
}

function addSWF(fullFilePath, width, height)
{
    var str;
    str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0"';
    str += 'height="'+height+'" width="'+width+'"><param name="movie" value="'+fullFilePath+'" /><param name="quality" value="high" /><param name="wmode" value="transparent" />';
    str += '<embed src="'+fullFilePath+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer"';
    str += 'type="application/x-shockwave-flash" width="'+width+'" height="'+height+'"></embed></object>';
    document.write(str);
}

function someThing(control)
{
    if(document.getElementById(control))
    {
        if(document.getElementById(control).value=='')
        document.getElementById(control).value='';
        return true;
    }
    else
        return false;
}

function unCheckRadio(radioButtonId)
{
    var i, radio;
    for(i=0; i<12; i++)
    {
        radio = document.getElementById(radioButtonId+i);
        radio.checked = false;
    }
    
}

function openPopup()
{
    window.open('Popup.aspx','startuppopup','height=300, width=364, toolbar=no, menubar=no, resizable=no');
}

function closePopup()
{
    document.getElementById('katman').style.display = 'none';
}

//firefox için eklenen menüye ait script

if(navigator.appName=='Netscape')
{
    // JavaScript Document
/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Travis Beckham :: http://www.squidfingers.com | http://www.podlob.com
version date: 06/02/03 :: If want to use this code, feel free to do so,
but please leave this message intact. (Travis Beckham) */

// Node Functions

if(!window.Node){
  var Node = {ELEMENT_NODE : 1, TEXT_NODE : 3};
}

function checkNode(node, filter){
  return (filter == null || node.nodeType == Node[filter] || node.nodeName.toUpperCase() == filter.toUpperCase());
}

function getChildren(node, filter){
  var result = new Array();
  var children = node.childNodes;
  for(var i = 0; i < children.length; i++){
    if(checkNode(children[i], filter)) result[result.length] = children[i];
  }
  return result;
}

function getChildrenByElement(node){
  return getChildren(node, "ELEMENT_NODE");
}

function getFirstChild(node, filter){
  var child;
  var children = node.childNodes;
  for(var i = 0; i < children.length; i++){
    child = children[i];
    if(checkNode(child, filter)) return child;
  }
  return null;
}

function getFirstChildByText(node){
  return getFirstChild(node, "TEXT_NODE");
}

function getNextSibling(node, filter){
  for(var sibling = node.nextSibling; sibling != null; sibling = sibling.nextSibling){
    if(checkNode(sibling, filter)) return sibling;
  }
  return null;
}
function getNextSiblingByElement(node){
        return getNextSibling(node, "ELEMENT_NODE");
}

// Menu Functions & Properties

var activeMenu = null;

function showMenu() {
  if(activeMenu){
    activeMenu.className = "";
    getNextSiblingByElement(activeMenu).style.display = "none";
  }
  if(this == activeMenu){
    activeMenu = null;
  } else {
    this.className = "active";
    getNextSiblingByElement(this).style.display = "block";
    activeMenu = this;
    Set_Cookie('menuName', getNextSiblingByElement(this).parentNode.id, 1, '/', '', '');
  }
  return false;
}

function assignHref(id)
{
	switch(id)
	{
		case 'anasayfa': return "Default.aspx";
		break;
		case 'bizeulasin': return "BizeUlasin.aspx";
		break;
		case 'duyurular': return "IlanPanosu.aspx?Bolum=Ilan";
		break;
		case 'bilgibankasi': return "BilgiBankasi.aspx";
		break;
		case 'arastirmalar': return "ArastirmaDetay.aspx";
		break;
		default: return "#";
	}
}

function initMenu(){
  var menus, menu, text, a, i;
  menus = getChildrenByElement(document.getElementById("menu"));
  for(i = 0; i < menus.length; i++){
    menu = menus[i];
    text = getFirstChildByText(menu);
    a = document.createElement("a");
    menu.replaceChild(a, text);
    a.appendChild(text);
    a.href = assignHref(menus[i].id);
    a.onclick = showMenu;
    a.onfocus = function(){this.blur()};
	
  }
}

if(document.createElement) window.onload = initMenu;
}