﻿var requiredMajorVersion = 9;
var requiredMinorVersion = 0;
var requiredRevision = 115;
var windowname='fullScreenWindow';
var contentUrl='';

function getDocHeight(doc)
{
  var docHt = 0, sh, oh;
  if (doc.height)
  {
    docHt = doc.height;
  }
  else if (doc.body)
  {
    if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
    if (sh && oh) docHt = Math.max(sh, oh);
  }
  return docHt;
}

function getReSize()
{
  var docHt = null;
  var iframeWin = window.frames['_iframe'];
  var iframeEl = window.document.getElementById? window.document.getElementById('_iframe'): document.all? document.all['ifrm']: null;
  if ( iframeEl && iframeWin )
  {
    docHt = getDocHeight(iframeWin.document);
    if (docHt != iframeEl.style.height) iframeEl.style.height = docHt + 'px';
  }
  else
  { // firefox
    docHt = window.document.getElementById('_iframe').contentDocument.height;
    window.document.getElementById('_iframe').style.height = docHt + 'px';
  }
}

function SetIFrame(url,hidePanel)
{    
    document.getElementById('Div_Konular').style.display=(hidePanel?'':'none');
    document.getElementById('_iframe').src=url;
}

function ResizeIFrame()
{
    getReSize();
    setTimeout('ResizeIFrame()',500);
}

function RefreshIFrameWithParameter(queryString)
{
    document.getElementById('_iframe').src=document.getElementById('_iframe').src + queryString;
}

var previousElementId;
var previousElementBGColor;

function BaslikSec(objectId,headerId)
{
    if (document.getElementById('_iframe')==null)
    {
        alert('Konu anlatımı, alıştırma veya uygulama seçmelisiniz.');
    }
    else
    {
        if (previousElementId!=null)
        {
            document.getElementById(previousElementId + 'T').style.backgroundColor=previousElementBGColor;
            document.getElementById(previousElementId + 'I').style.backgroundColor=previousElementBGColor;            
        }
                
        previousElementBGColor=document.getElementById(objectId + 'T').style.backgroundColor;
        
        document.getElementById(objectId + 'T').style.backgroundColor='#CCCCCC';
        document.getElementById(objectId + 'I').style.backgroundColor='#CCCCCC';
        previousElementId=objectId;

        document.getElementById('_iframe').contentWindow.BaslikSec(headerId);
    }
}

function ShowSubject(headerText, url, subjectId, subjectLinkId)
{
    window.scrollTo(0,0);
    var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);        
    document.getElementById('Span_Header').innerText=headerText;
    //if (!hasReqestedVersion)
    //    ASPxPopupControl_Flash.SetContentUrl('http://data.hiperokul.com/' +  url + '/u/');         
    //else        
        ASPxPopupControl_Flash.SetContentUrl('http://data.hiperokul.com/' +  url + '/');        
    ASPxPopupControl_Flash.Show(); 
    LogYaz(subjectId, subjectLinkId);    
}


function DetectFlash()
{

    var hasReqestedVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);        
    if (!hasReqestedVersion) {  
        ASPxPopupControl_Flash.SetContentUrl('RequireNewFlashVersion.aspx');
        ASPxPopupControl_Flash.Show();	    
    }
}

function SetFullScreen(popupWindow,url)
{
    contentUrl=popupWindow.GetContentUrl();
    var _window=window.open(url, windowname, ',type=fullWindow,fullscreen,scrollbars=yes');
    if(!_window.opener){ _window.opener = this.window; }    
    popupWindow.Hide();
}