﻿// JScript File
/**** written By Sunil Jha
      dated : sept 11th 20078*/
/****Global varible decleartion Area*****/
    var SlideReady=true;
    var CurrentSlide;
    var WinOpen;
    var current = 0;
    var delay=9000;
    var Count=0;
 
 /***This Script is used to view popup image based on screen resolution***/
    function Show(myevent)
   {
      try
      {
      
            x = myevent.clientX + document.body.scrollLeft+10;
            if((document.body.scrollTop )>screen.height/2.45)
            {
                y= myevent.clientY + document.body.scrollTop + 25; 
                
            }
            else
            {
                y= (myevent.clientY + document.body.scrollTop )-300;  
            }
            // display the pop-up 
            Popup.style.display="block";
            Popup.style.left = x;
            /* set the pop-up's top */
            Popup.style.top = y;
      }
      catch(error)
      {
      }
    }


/********** this function hides the pop-up when user moves the mouse out of the link */
    function Hide()
    {
        Popup.style.display="none";
    }
    
    
    
/********This Script is used for open window***************/

    function functionopenWin(pageName,parameter)
     {
         try
         
         {           
              if(!WinOpen||WinOpen.closed)
              {
                WinOpen = window.open(pageName+'?value='+parameter,'ImageViewer','status=1,width=800,height=640,left=100 ,top=0,scrollbars=no');
              }
              else
              {
                 WinOpen.focus();
                 return; 
              }
              
              if(WinOpen)
              {
                    var popUpsBlocked = false
              }
              else
              {
                    var popUpsBlocked = true
                    self.defaultStatus="Your popup is blocked.";
              }
                      
          }
          catch(Error)
          {
           
          }

}
/********To fix IE 7  Bug *********************************************/
function winopen_img(imgname)
{
  try
  {
          closeChildWindow();
          WinOpen = window.open('ImageView.htm?value='+imgname,'ImageViewer','status=1,width=800,height=640,left=100 ,top=0,scrollbars=no');
   }
   catch(Error)
   {
   }
}
/*********Close child window******************/
function OpenNewsWindow()
{
  try
  {
   closeChildWindow();
    WinOpen = window.open('NewsPage.htm','News','status=1,width=800,height=640,left=100 ,top=0,scrollbars=no');
  }
  catch(error)
  {
  }
}
/***********************************************/
function closeChildWindow()
{ try
    {
        if(WinOpen)
        {
            WinOpen.close();
         }
    }
    catch(Error)
    {
    }
   
}
/**********Changes Image on dropdown value change*******************/
function funChageImg()
{
    try
    {
        current = document.forms[0].slide.selectedIndex;
        document.images.show.src = document.forms[0].slide[current].value;
    }
    catch(Error)
    {
       
    }
}

//This method is used to view first image on first button click
function first() 
{
  try
  {
    current = 0;
    document.images.show.src = document.forms[0].slide[0].value;
    document.forms[0].slide.selectedIndex = 0;
  }
  catch(Error)
  {
  
  }
}

//This is method used to view last image on last Button Click
function last() 
{
    try
    {
    //Length of dropdown
        current = document.forms[0].slide.length-1;
        document.images.show.src = document.forms[0].slide[current].value;
        document.forms[0].slide.selectedIndex = current;
    }
    catch(Error)
    {
    }
}

// Function Used to see previous image
 function previous()
 {
    try
    {
     if (current-1 >= 0) 
      {
        document.images.show.src = document.forms[0].slide[current-1].value;
        document.forms[0].slide.selectedIndex = --current;
      }
      else
      last();
   }
   catch(Error)
   {
   }
 }
 //function Next is used to view next image on button click
 function next()
  {
    if (document.forms[0].slide[current+1])
     {
        document.images.show.src = document.forms[0].slide[current+1].value;
        document.forms[0].slide.selectedIndex = ++current;
     }
    else 
    first();
 }
 // Automaticaly rotates image after 2 sec on click start button
 function rotate() 
 {
   try
   {
    if (document.forms[0].slidebutton.value == "Stop")
        {
            current = (current == document.forms[0].slide.length-1) ? 0 : current+1;
            document.images.show.src = document.forms[0].slide[current].value;
            document.forms[0].slide.selectedIndex = current;
            window.setTimeout("rotate()", delay);
            document.images.process.style.visibility='visible';
        }
        else
        {
            document.images.process.style.visibility='hidden';
        }
   }
   catch(Error)
   {
    
   }
 }
 //Rotate image after Some interval and chages text
  function ap(text) 
  {
     try
     {
        document.forms[0].slidebutton.value = (text == "Stop") ? "Start" : "Stop";
        rotate();
     }
     catch(Error)
     {
     }
  }
  //Making visibilty false for gif file on body load of image viewer
function funprocess()
{
    try
    {
    
     document.images.process.style.visibility='hidden';
    }
    catch(Error)
    {
    }
}
function fun_imgviewerOnunload()
{
    WinOpen=0;
}
// This method is for Marquee
function stop(marq_id)
{
  document.getElementById(marq_id).scrollamount=0
}
function start()
{
document.getElementById(marq_id).scrollamount=2
}
/*Reverse Marquee direction************/
function funReverse(ctlid,ctld_marq)
{
    try
    {
        if(document.getElementById(ctld_marq).direction=="down")
        {
            document.getElementById(ctld_marq).direction="up";
            document.getElementById(ctlid).src="images//Images_Icon//Led.GIF";
        }
        else
        {
            document.getElementById(ctld_marq).direction="down";
            document.getElementById(ctlid).src="images//Images_Icon//up.GIF";
        }
    }
    catch(error)
    {
    }
}
/*****************************************************/
