
/*
    SPK Web Site r.3
    file name     : spkmethods.js
    description   : Generic js methods for pages
    file version  : 0.9
    written by    : Ahmetcan Öztürk
    last modified : 03.02.2006
*/

/* method for opening mevzuat application */
  function openMevzuat() {
    var url = "/mevzuat/mevzuat_index.html";
    var windowMevzuat = null;
    var wwidth = screen.availWidth-40;
    var wheight = screen.availHeight-60;
    windowMevzuat = window.open('/mevzuat/mevzuat_empty.html','windowMevzuat','width='+wwidth+',height='+wheight+',status=no,toolbar=no,menubar=no,directories=no,location=no,scrollbars=yes,resizable=no,alwaysRaised=yes,titlebar=no,left=20,top=20');
    if (windowMevzuat != null) {
      if (windowMevzuat.opener == null) {
        windowMevzuat.opener = self;
      }
      windowMevzuat.location.href = url;
      windowMevzuat.focus();
    }
  }
  
  function openMevzuat(url) {
     var windowMevzuat = null;
     var wwidth = screen.availWidth-40;
     var wheight = screen.availHeight-60;
     windowMevzuat = window.open('/mevzuat/mevzuat_empty.html','windowMevzuat','width='+wwidth+',height='+wheight+',status=no,toolbar=no,menubar=no,directories=no,location=no,scrollbars=yes,resizable=no,alwaysRaised=yes,titlebar=no,left=20,top=20');
     if (windowMevzuat != null) {
        if (windowMevzuat.opener == null){
           windowMevzuat.opener = self;
        }
        windowMevzuat.location.href = url;
        windowMevzuat.focus();
     }
   }

/* method for displaying real spk logo */
  function displayLogo() {
    var sImg = "<img src='/images/spklogo.jpg' alt='Sermaye Piyasasi Kurulu' width='112' height='92' border='0' align='center'>";
    var windowImg = null;
    var wwidth = 130;
    var wheight = 120;
    var wleft = screen.availWidth / 2 - 130;
    var wtop = screen.availHeight / 2 - 120;
    windowImg = window.open('','windowImg','width='+wwidth+',height='+wheight+',status=no,toolbar=no,menubar=no,directories=no,location=no,scrollbars=no,resizable=no,alwaysRaised=yes,titlebar=no,left='+wleft+',top='+wtop+'');
    if (windowImg != null) {
       windowImg.document.write(sImg);
       windowImg.focus();
    }
  }
  
/* method for detecting the browser */
  function detectBrowser() {
    var ua = window.navigator.userAgent;
    if (ua.indexOf ("MSIE") > 1)
       return "ie";
    else if (ua.indexOf ("Firefox") > 1)
       return "firefox";
    else if (ua.indexOf ("Netscape") > 1)
       return "netscape";
    else
       return "none";
  }

/* method for calculating the top location of main frame for submenu of main menu */
  var y1 = 0;
  function getMyTop() {
    (document.getElementById) ? dom = true : dom = false;
    if (dom && !document.all) {
       document.getElementById("divTop").style.top = window.pageYOffset + (window.innerHeight - (window.innerHeight-y1))
    }
    if (document.layers) {
       document.layers["divTop"].top = window.pageYOffset + (window.innerHeight - (window.innerHeight-y1))
    }
    if (document.all) {
       document.all["divTop"].style.top = document.body.scrollTop + (document.body.clientHeight - (document.body.clientHeight-y1));
    }
    window.setTimeout("getMyTop()", 10);
  }

/* */
function resizeOutTable() {
  document.getElementById("tableTop").style.width = (document.body.offsetWidth * 0.98).toString() + "px";
  document.getElementById("tableCenter").style.width = (document.body.offsetWidth * 0.98).toString() + "px";
  document.getElementById("tableBottom").style.width = (document.body.offsetWidth * 0.98).toString() + "px";
  document.getElementById("tableBottomTdBg").style.width = (document.body.offsetWidth * 0.98 - 14).toString() + "px";
  document.getElementById("tableBottomTdBt").style.width = (document.body.offsetWidth * 0.98 - 14).toString() + "px";
}

/* fot HTML compliant doctype */
function resizeContainerHeight(myDiv) {
  var iHeight = 500;
  var brwsr = detectBrowser();
  if (brwsr == "ie") {
    document.getElementById("divContainer").style.height = "100%";
    iHeight = document.body.offsetHeight - 90;
  }
  else if (brwsr == "firefox") {
    document.getElementById("divContainer").style.height = "97%";
    //iHeight = document.getElementById("divContainer").offsetHeight - 70;
    iHeight = document.body.offsetHeight - 70;
  }
  document.getElementById(myDiv).style.height = iHeight.toString() + "px";
}

/* fot XHTML compliant doctype xhtml-transitional */
function resizeContainerHeightInner(myDiv) {
  var iHeight = 500;
  var brwsr = detectBrowser();
  if (brwsr == "ie") {
    document.getElementById("divContainer").style.height = "100%";
    iHeight = document.body.offsetHeight - 10;
  }
  else if (brwsr == "firefox") {
    document.getElementById("divContainer").style.height = "100%";
    iHeight = document.getElementById("divContainer").offsetHeight + 55;
  }
  document.getElementById(myDiv).style.height = iHeight.toString() + "px";
}

/* method for getting query variable from querystring */
/* usage : var sTid = getQueryVariable("tid"); */
  function getQueryVariable(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i=0;i<vars.length;i++) {
      var pair = vars[i].split("=");
  	  if (pair[0] == variable) {
  	    return pair[1];
  	  }
    }
  }

/* method for email links */
  function emaillink(subdomain,user,domain){
    location.href = "mailto:" + user + "@" + subdomain + "." + domain;
  }
  
  function menucolor (obj, overout)
  {
    if (overout == 1)
       obj.style.backgroundColor = "#8A8CCC";
    else
       obj.style.backgroundColor = "#E9E9FA";
  }
  
  function menucolorOtherMenus (obj, myevent, myclass)
  {      
    if (myevent == 1)
    {
        obj.style.backgroundColor = "#FFD2A8";
    }
    else if (myevent == 2)
    {
        if (myclass == "tdodd")
            obj.style.backgroundColor = "#F6F9FC";
        else
            obj.style.backgroundColor = "#CCD4FF"; //
    }
  }
        
  function doSearch()
  {
      //document.getElementById("txtSearch2.ClientID").value = document.getElementById("txtSearchbox").value;
      
      //document.getElementById("txtSearch.ClientID").Text = document.getElementById("txtSearchbox").value;
      //alert("a");
      //document.getElementById("btnX.ClientID).click();
      //document.getElementById("<%=form1.ClientID%>").action = "search.aspx";
      //document.getElementById("<%=form1.ClientID%>").submit();
  }
 
  function setTopBgImg() {
     var topimg = "top3g1.jpg";
     if (getQueryVariable("topimg") != null) {
         topimg = getQueryVariable("topimg");
         document.getElementById("tableTop").style.backgroundImage = "url('/images/"+topimg+"')";
     }
     var toplinkbarclass = "toplinkbar";
     if (getQueryVariable("toplinkbarclass") != null) {
         toplinkbarclass = getQueryVariable("toplinkbarclass");
         document.getElementById("divtopLinkBar").className = toplinkbarclass;
     }
  }
   
function toggle( targetId ){ 
  if (document.getElementById){ 
        target = document.getElementById( targetId ); 
           if (target.style.display == "none"){ 
              target.style.display = ""; 
           } else { 
              target.style.display = "none"; 
           } 
     } 
} 

function urlencode( str ) {                                    
    var histogram = {}, histogram_r = {}, code = 0, tmp_arr = [];
    var ret = str.toString();
    
    var replacer = function(search, replace, str) {
        var tmp_arr = [];
        tmp_arr = str.split(search);
        return tmp_arr.join(replace);
    };
    // identical to the one in urldecode.
    histogram['!']   = '%21';
    histogram['%20'] = '+';
    ret = encodeURIComponent(ret);
    
    for (search in histogram) {
        replace = histogram[search];
        ret = replacer(search, replace, ret) // Custom replace. No regexing
    }    
    // uppercase
    return ret.replace(/(\%([a-z0-9]{2}))/g, function(full, m1, m2) {
        return "%"+m2.toUpperCase();
    });
    
    return ret;
}

function changeFontSize(size)
{
  var sMasterId = "ctl00_ContentPlaceHolder1_";
  var mycontrols = new Array(4);
  mycontrols[0] = sMasterId + "divContent";
  mycontrols[1] = sMasterId + "divTitle";
  mycontrols[2] = sMasterId + "divMessage";
  mycontrols[3] = sMasterId + "divMenuContainer";
  for (i = 0; i < mycontrols.length; i++)
  {
      var mydiv = document.getElementById(mycontrols[i]);
      if (mydiv != null)
      {
        mydiv.style.fontSize = size + 'px';
        var tds = mydiv.getElementsByTagName('td');
        for (j=0; j<tds.length; j++)
            tds[j].style.fontSize = size + 'px';
      }
  }
  
/*
  var p = document.getElementsByTagName('p');
  for(i=0; i<p.length; i++) {
    p[i].style.fontSize = size + 'px';
  }
  
  var uls = document.getElementsByTagName('ul');
  for(i=0; i<uls.length; i++) {
    uls[i].style.fontSize = size + 'px';
  }
*/
}

//Video sayfasını açmak için yeni html sayfası çağırır
function MM_openBrWindowNews(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=(features!='')?',':'';
    features+=',left='+myLeft+',top='+myTop;
  }
  window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight);
}

//Fotoğraflar için
function borderit(which,color){
		if (document.all||document.getElementById){
		which.style.borderColor=color
				}
}

//Fotoğraflar için
function op(imageName) {
			newWindow = window.open("","newWindow","width=250,height=250");
			newWindow.document.open();
			newWindow.document.write('<html><head><title>Nuri Uslu</title><scr'+'ipt language="javascr'+'ipt">function boyutlandir(scud){genislik=eval(scud.offsetWidth)+8;yukseklik=eval(scud.offsetHeight)+27;window.resizeTo(genislik,yukseklik);yenix=(screen.availWidth-genislik)/2;yeniy=(screen.availHeight-yukseklik)/2;');
			newWindow.document.write('window.moveTo(yenix,yeniy);}</scr'+'ipt></head><body bgcolor=#FFFFFF background=images/yukleniyor.gif leftmargin=0 topmargin=0 marginheight=0 marginwidth=0 onload="window.setTimeout(\'self.close\',20000)" onresize="boyutlandir(resim)" onload="boyutlandir(resim)">');
			newWindow.document.write('<a href="#"><img border=0 onclick="self.close()" src='+imageName+' id=resim onload="boyutlandir(resim)"></a><scr'+'ipt language="javascr'+'ipt">boyutlandir(resim);</scr'+'ipt>');
			newWindow.document.write('</body></html>');
			newWindow.document.close();
			newWindow.focus();
}



         