var Obody=document;
Obody.onkeydown = disableCtrlKeyCombination;
var IsPegasusPage=1;
function stringBuilder()
	{
		var strArray=new Array();
		this.append=function(str)
			{
			  strArray.push(str);
			  return this;
			}
		this.toString=function(seprator)
			{
			  if(!seprator) seprator="";
			  return strArray.join(seprator);
			}
		this.length=function()
			{
			 return strArray.join("").length;
			}
	}
/*Sample
var obj=new stringBuilder();
obj.append("String1").append("String2").append("String3").append("String4").append("String5");
alert(obj.toString());
*/

function ele(obj) // ele Function to get document.getElementById
	{
		return document.getElementById(obj);
	}

function checkWindow()
{
    var strcurrentUrl=location.href;
    if(strcurrentUrl.indexOf("frmTeachingPlan.aspx")!=-1)
    {
        try
        {
            if(window.frames[0].objPopWin && window.frames[0].objPopWin!='undefined' )
            {
                window.frames[0].objPopWin.focus();
                return true;           
             }
            else if(window.frames[1].objPopWin && window.frames[1].objPopWin!='undefined')
            {
                window.frames[1].objPopWin.focus();
                return true;           
            }
            else
            return false;
        }
        catch(e){return false;}
    }
    else if(strcurrentUrl.indexOf("frmAssignContent.aspx")!=-1)
      { try
            { if(window.frames[0].objPopWin)
                {    
                 window.frames[0].objPopWin.focus();
                 return true;
                 }        
          else if(window.frames[2].objPopWin)
            {
                 window.frames[2].objPopWin.focus();
                 return true;                  
            }
            else
            return false;
           }
            catch(e){return false;}        
      }
    else if(strcurrentUrl.indexOf("frmCoursePreview.aspx")!=-1)
       {
       try
            { if(window.frames[1].objPopWin && window.frames[1].objPopWin!='undefined' )
                {    
                 window.frames[1].objPopWin.focus();
                 return true;
                 }        
               else if(window.parent.objWindow && window.parent.objWindow!='undefined')
               {
               try{
                    window.parent.objWindow.close();
                    return false;
                   }
                catch(e)
                {return false;}
               }
               else                         
                return false; 
            }
            catch(e){return false;}
       }   
     else
      {
         return false;   
      }
}	

function SetfontImg(obj)
{ 
 
   if(checkWindow() == false)
    {
    var fontsize;
    switch (obj.id)
     {
      case 'imgfontsmall':
                fontsize = 1;
                break;
            
      case 'imgfontmedium':
                fontsize = 2;
                break;
                        
      case 'imgfontlarge':
                fontsize = 3;
                break;
     }  
     
     var parentID = null ;
     var objWin = null;
     // Vijay: Earlier code will result script error if we are not using any iframes in main window.
     if(window.frames[0])
     {
         parentId= window.frames[0].CurentAssetId;
         objWin = window.frames[0];
     }
     else
     {
         parentId= window.CurentAssetId;
         objWin = window;
      }
        var strUrl = location.href; 
        
        if(objWin.ADVANCED_MODE_FLAG)
        {
            if(objWin.ADVANCED_MODE_FLAG=="1")
            {
            if(strUrl.indexOf("AdMode")!=-1)
            {
            PegasusMenuCollection.SetSessionvalue(strUrl);
            }
            else
            {
            //strUrl=strUrl.substring(0,strUrl.length-38);
            PegasusMenuCollection.SetSessionvalue(strUrl+"&AdMode=1");
            }
            }
         }
         else if(strUrl.indexOf("AdMode")!=-1)
         {
            strUrl=strUrl.substring(0,strUrl.length-9);
            PegasusMenuCollection.SetSessionvalue(strUrl);
         }
         else if(strUrl.indexOf("From=AC") != -1)
            PegasusMenuCollection.SetSessionvalue(strUrl.substring(0,strUrl.indexOf("?")+1)+"&From=AC&SelectedDate="+window.frames[2].SelectedDateTime +"&FilterOpt="+window.frames[0].ContentSeleted+"&intLinkParentID="+window.frames[0].rtAssetID)
         else if(strUrl.indexOf("From=SCC") != -1)
            PegasusMenuCollection.SetSessionvalue(strUrl.substring(0,strUrl.indexOf("?")+1)+"&from=SCC&SelectedDay="+window.frames[1].document.getElementById('hdnSelectedDay').value)
         else
            PegasusMenuCollection.SetSessionvalue(strUrl);
        //PegasusMenuCollection.SetSessionvalue(strUrl);d
        if(strUrl.indexOf("From=AC") != -1)
            location.href="../../../Common/frmSetFontSettings.aspx?fontsize="+fontsize;
        else
            location.href="../../Common/frmSetFontSettings.aspx?fontsize="+fontsize;
       }
}
function disableCtrlKeyCombination(e)
{

        //list all CTRL + key combinations you want to disable
        
        var forbiddenKeys = new Array('n');
        var key;
        var isCtrl;
        if(window.event)
        {
			
                key = window.event.keyCode;     //IE
                if(window.event.ctrlKey)
				{
                        isCtrl = true;
				}
                else
				{
                        isCtrl = false;
				}
        }
        else
        {
                key = e.which;     //firefox
                if(e.ctrlKey)
                        isCtrl = true;
                else
                        isCtrl = false;
        }

        //if ctrl is pressed check if other key is in forbidenKeys array
        if(isCtrl)
        {
			
                for(i=0; i<forbiddenKeys.length; i++)
                {
                        //case-insensitive comparation
                        if(forbiddenKeys[i].toLowerCase() == String.fromCharCode(key).toLowerCase())
                        {
							
                              return false;
                        }
                }
        }
        return true;
}
getBrowserDetails();
function getBrowserDetails()
{
	this.ver = navigator.appVersion; this.agent=navigator.userAgent
	this.dom = document.getElementById?1:0
	this.ie4 = (document.all && !this.dom)?1:0;
	this.ie = this.ie4 || (this.ver.indexOf("MSIE")>-1 && this.dom)?1:0;
	this.mac = this.agent.indexOf("Mac")>-1;
	this.opera5 = this.agent.indexOf("Opera 5")>-1
	this.ns6 = (this.dom && (parseInt(this.ver) >= 5) && (this.agent.indexOf("Netscape") > -1) ) ?1:0;
	this.ns4 = (document.layers && !this.dom && (this.agent.indexOf("Netscape") > -1) )?1:0;
	this.ff = (this.dom && (parseInt(this.ver) >= 5) && (this.agent.indexOf("Firefox") > -1) ) ?1:0;
	this.bw = (this.ie || this.ns4 || this.ns6 || this.opera5 || this.ff || this.dom);
	return this;
}
