﻿var dom = (document.getElementById) ? true : false;
var ns5 = ((navigator.userAgent.indexOf("Gecko")>-1) && dom) ? true: false;
var ie5 = ((navigator.userAgent.indexOf("MSIE")>-1) && dom) ? true : false;
var ns4 = (document.layers && !dom) ? true : false;
var ie4 = (document.all && !dom) ? true : false;
var nodyn = (!ns5 && !ns4 && !ie4 && !ie5) ? true : false;

   
 /*---- use width=..px to give an exact dimension-------*/  
 /*---- use width=100% for no scaling-------*/  
 
    //Will generate a <div> with internal <object> and <embed> flash objects
    function InsertFlash(path,width,height)
    {
       id="FlashViewer"; 
       document.write("<div id='"+id+"' style='text-align: left; width: "+width+"px; height: "+height+"px; margin-top: 20px; margin-bottom:20px; background-color:#000000;'>");
       document.write(GenerateFlashObjectsString(path,width,height));
       document.write("</div>");
    }
    
    function GenerateFlashObjectsString(path, width, height)
    {
    var a = new Array();
    if (!width) width="100%";
    if (!height) height="100%";
    a.push("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='"+width+"' height='"+height+"' codebase='http://active.macromedia.com/flash5/cabs/swflash.cab#version=7,0,0,0'>");
    a.push("<param name='MOVIE' value='"+path+"' />");
    a.push("<param name='PLAY' value='true' />");
    a.push("<param name='LOOP' value='true' />");
    a.push("<param name='QUALITY' value='high' />");
    a.push("<param name='bgcolor' value='#000000' />");
    a.push("<embed src='"+path+"' quality='high' width='"+width+"' height='"+height+"' bgcolor='#000000' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
    a.push("</object>");
    return a.join("");
    }
    
    //Will find the <div> containing the flash objects and re-write the inner html
    function ActivateFlashMovie(text)
    {
        var flashContainer = document.getElementById('FlashViewer');
        var height = flashContainer.style.height;
        var width = flashContainer.style.width;
   
        flashContainer.innerHTML=GenerateFlashObjectsString(text,width,height);
    }
    
    /*---- Search section ----Start-------*/
//    var theForm = document.forms['aspnetForm'];
//    if (!theForm) {  theForm = document.aspnetForm; }
//    function OnSearchPressed(e) 
//    {
//        var theKey;
//        if(e.keyCode)
//            theKey = e.keyCode;
//        else 
//            theKey = e.which;
//        
//        if (theKey == 13)
//        {
//            var word=document.aspnetForm.TextBoxSearch.value;
//            if (word)
//                window.open("http://www.google.com/search?hl=en&q=" + word + "+site%3ahttp%3a%2f%2fwww.novabrain.com", "_blank","left=0,top=0,screenX=0,screenY=0,toolbar=1,status=1,scrollbars=1,resizable=yes,width=765,height=500");
//            return false;
//        }
//    }
/*---- Search section ----End-------*/

 
/*---- Expend and Collapse Element ----Start-------*/
    function CollapseExpand(elemName, imgName)
    {
        var elem;
        var img;

        if(document.getElementById)
        {
            elem = document.getElementById(elemName);
            img = document.getElementById(imgName);
        }
        else if(document.all)
        {
            elem = document.all[elemName];
            img = document.all[imgName];
        }
                
        if(elem.style.display == "none")
        {
            elem.style.display = "block";
            img.src = "../Images/Bullets/expanded.png";
        }
        else
        {
            elem.style.display = "none";
            img.src = "../Images/Bullets/collapsed.png";
        }
    }
    
    function NoOp()
    {
    }
/*---- Expend and Collapse Element ----End-------*/
    
    
/*  To be removed and replaced with the PopBox javascript  */
    function OpenScreenShot(url)    
    {
        window.open(url,"_blank","left=0,top=0,screenX=0,screenY=0,toolbar=0,status=0,scrollbars=1,resizable=yes,width=1074,height=818");    
    }
    
    function LaunchFlashViewer(clip,width,heigth)    
    {
    if (!width) width=900;
    if (!heigth) heigth=720;
     var array=location.href.split("novabrain.com");
     var url=array[0]+"novabrain.com/Media/Viewers/FlashViewer.aspx?file="+clip; 

     window.open(url,"_blank","toolbar=0,left=100,top=100,status=0,scrollbars=0,resizable=yes,width="+width+",height="+heigth);    

return false;
    }
    
    function LaunchPlayListViewer(playlist,movieTitle)    
    {
    
     var array=location.href.split("novabrain.com");
     var url=array[0]+"novabrain.com/Media/Viewers/PlayListViewer.aspx?File=" + playlist;
     if(movieTitle) url = url + "&movie="+ movieTitle;
     window.open(url,"_blank","toolbar=0,left=100,top=100,status=0,scrollbars=1,resizable=yes,width=1074,height=720");    
  return false;
    }
