﻿function getInternetExplorerVersion()
// Returns the version of Internet Explorer or a -1
// (indicating the use of another browser).
{
  var rv = -1; // Return value assumes failure.
  if (navigator.appName == 'Microsoft Internet Explorer')
  {
    var ua = navigator.userAgent;
    var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null)
      rv = parseFloat( RegExp.$1 );
  }
  return rv;
}



//************************************************
//THIS CHECKS WHAT SCREEN SIZE THE USER IS
//VIWING THE SITE AT
//1024 : 1280 : > 1280
//************************************************
function check_screen_res()
{

    var myWidth = 0;
    if( typeof( window.innerWidth ) == 'number' ) 
    {
        myWidth = window.innerWidth;//Non-IE
    } 
    else if( document.documentElement && (document.documentElement.clientWidth) ) 
    {
        myWidth = document.documentElement.clientWidth;//IE 6+ in 'standards compliant mode'
    } 
    else if( document.body && ( document.body.clientWidth) ) 
    {
        myWidth = document.body.clientWidth;//IE 4 compatible
     }
 
    
    //************************************************
    //checking if the screen width
    //to display the background meduim or lareg image
    //************************************************
    
    /*if(myWidth <= 1024)
    {
     document.body.style.backgroundImage = 'url(../GraduateSiteImages/pageBackgrounds/1024.jpg)';
    }
    else if(myWidth <= 1152)
    {
     document.body.style.backgroundImage = 'url(../GraduateSiteImages/pageBackgrounds/1152.jpg)';
    }
    else if(myWidth <= 1280)
    {
     document.body.style.backgroundImage = 'url(../GraduateSiteImages/pageBackgrounds/1280.jpg)';
    }*/
    //************************************************
}


//************************************************
//THIS ID THE SMOOTH SCROLLING OF THE PAGE
//************************************************
function pageScroll(Position) {
    window.scrollBy(0,50); 
    scrolldelay = setTimeout('newScroll('+Position+')',50); // scrolls every 1000 milliseconds
}
function stopScroll() {
    clearTimeout(scrolldelay);
}

function newScroll(Position) 
{

    //this will be exectuted iof IE is found
    var ver = getInternetExplorerVersion();
    
    if ( ver > -1 )
    {
        if(document.documentElement.scrollTop > Position)
        {
            stopScroll();
            return;
        }
        else
        {
            pageScroll(Position);
        }
    }
    else
    {
        if(window.pageYOffset > Position)
        {
            stopScroll();
            return;
        }
        else
        {
            pageScroll(Position);
        }
    
    }
    
}

function jumpScroll() {
    window.scroll(0,150); // horizontal and vertical scroll targets
}
