﻿function getRootPath()
{
    return 'http://www.astuteconsulting.com/';
}


// For Home page Slide Show

// The list of images to display in the slideshow
//creating a array of the image object

//var image=new Array("Images/DIDYOUKNOW/DIDYOUKNOW1.jpg",
//                    "Images/DIDYOUKNOW/DIDYOUKNOW2.jpg"
//                    )

var image=new Array(getRootPath() + "Images/DrSurana.jpg",
                    getRootPath() + "Images/DrSurana2.jpg"
                    )
//variable that will increment through the images
var num=0

// set the delay between images
var timeDelay
 
//preload the images in the cache so that the images load faster
//create new instance of images in memory 

var imagePreload=new Array()
for (i=0;i<image.length;i++)
{
   imagePreload[i]=new Image()
// set the src attribute
imagePreload[i].src=image[i]
}


function image_effects()
{
//     var selobj = document.getElementById('slidehow_transition');
//     alert(document.getElementById('slidehow_transition'));
//     var selIndex = selobj.selectedIndex;
//     //set the transition to the number selected in the list
//            slideShow.filters.revealTrans.Transition='Random dissolve'
     //slideShow.filters.revealTrans.apply()
     //slideShow.filters.revealTrans.play()
}

//function to get the previous image in the array
function previous_image()
{  
  //code to execute only when the automatic slideshow is disabled 
   //var chk = document.getElementById('chkslideshow');
   //if (chk.checked==false)
   //{
    if (num>0)
    {
       num--
       image_effects()
       //set the SRC attribute to let the browser load the preloaded images 
       document.images.slideShow.src=image[num] 
     }
    if (num==0)
    {  //if first image is displayed
       num=image.length
       num--
       image_effects()
       document.images.slideShow.src=image[num] 
       //timeDelay=setTimeout("slideshow_automatic()",4000)
    } 
  //}  
}

//function to get the next image in the array
function next_image()
{ 
  //code to execute only when the automatic slideshow is disabled 
  var chk = document.getElementById('chkslideshow');
  //if (chk.checked==false)
  //{
    if (num<image.length)
    {
       num++
       //if last image is reached,display the first image
       if (num==image.length) 
       num=0
       image_effects()
        //set the SRC attribute to let the browser load the preloaded images 
       document.images.slideShow.src=image[num]   
       //timeDelay=setTimeout("slideshow_automatic()",4000)
    }
  //} 
}

//for automatic Slideshow of the Images
function slideshow_automatic()
{ 
    var chk = document.getElementById('chkslideshow');
    //if (chk.checked)
   //{
    if (num<image.length)
     {
       num++
       //if last image is reached,display the first image
       if (num==image.length) 
       num=0
       image_effects()
       //sets the timer value to 4 seconds,we can create a timing loop by using the setTimeout method
       timeDelay=setTimeout("slideshow_automatic()",60000) 
       if (document.images.slideShow != null)
        document.images.slideShow.src=image[num]   
     }
   //}  
   //if (chk.checked==false)
   //{ 
     //Cancels the time-out that was set with the setTimeout method. 
      //clearTimeout(timeDelay)
   //}
}

//end of Home Page Slide Show

// For changing css of control dynamic
//Start

function changeStyle(ctrlId)
{
    document.getElementById(ctrlId).className="rightMenuPageSelected";
}

//End

//not in use
function SetQueryString(strCtrlid, strQueryValue)
{
    alert(strCtrlid);    
    document.getElementById(ctrlId).innerHTML = strQueryValue;
}

//---------------------------------------------------------------
//for World Map
function MM_swapImgRestore() 
{ //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) 
{ //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//-----------------------------------------------------------------

//For Closing Window
function CloseWindow()
{
    window.close();
}

function OpenPopUp(p_url)
{
    //var p_path = getRootPath() + p_url;
    window.open(p_url,'popup','titalbar=no,menubar=no,width=550,height=550,status=no,scrollbars=yes,maximum=yes');
    
//    var OLECMDID = 7;
//    var PROMPT = 1;
//    var WebBrowser='<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
//    document.body.insertAdjacentHTML('beforeEnd',WebBrowser);
//    WebBrowser1.ExecWB(OLECMDID,PROMPT);
//    WebBrowser1.outerHTML="";
}



// "Page Name","path","Page Title","Many,Key,Words","Descriptive Comments"
page="<html><head><title>Search Results</title></head><body bgcolor='white'><center><table border=0 cellspacing=10 width=80%>";
var item = new Array();
c=0; item[c]=new Array("Home.aspx","/","Home","RSM Astute","Demonstration search engine data about an imagined but probable internet site.");
c++; item[c]=new Array("SiteMap.aspx","/","Sitemap","RSM Astute","Contact details and general information about the creator of the site and what the site is about.");

function search(frm) 
{
    win = window.open("","","scrollbars");
    win.document.write(page);
    txt = frm.value.split(" ");

    fnd = new Array(); 
    total=0; //for number of pages
    for (i = 0; i < item.length; i++) 
    {
        fnd[i] = 0; 
        order = new Array(0, 4, 2, 3);
        for (j = 0; j < order.length; j++)
        {
            for (k = 0; k < txt.length; k++)
            {
                if (item[i][order[j]].toLowerCase().indexOf(txt[k]) > -1 && txt[k] != "")
                    fnd[i] += (j+1);
            }
        }
    }
    for (i = 0; i < fnd.length; i++) 
    {
        n = 0; 
        w = -1;
        for (j = 0;j < fnd.length; j++)
            if (fnd[j] > n) 
            { 
                n = fnd[j]; 
                w = j; 
            };
        if (w > -1) total += show(w, win, n);
        fnd[w] = 0;
    }
    win.document.write("</table><br>Total found: "+total+"<br></body></html>");
    win.document.close();
}

function show(which,wind,num) 
{
    link = item[which][1] + item[which][0]; 
    line = "<tr><td><a href='"+link+"'>"+item[which][2]+"</a> Score: "+num+"<br>";
    line += item[which][4] + "<br>"+link+"</td></tr>";
    wind.document.write(line);
    return 1;
}
function Find()
{
    var frm = document.getElementById('ctl00_txtSearch');
    return search(frm);
}

function checkInt(e)
{  
    if(!checkSpecialKeys(e))
    {
        if ((!(e.keyCode >= 48 && e.keyCode <= 57)) && (!(e.keyCode >= 96 && e.keyCode <= 105)) )
        {    
            if(window.event)
            {
                e.returnValue = false;
            }
            else
            {//For firefox
                e.preventDefault();
            }
        }
    }
}

function checkSpecialKeys(e)
{
    if(e.keyCode != 8 && e.keyCode != 9 && e.keyCode != 17 && e.keyCode != 35 && e.keyCode != 36 && e.keyCode != 37 && e.keyCode != 38 && e.keyCode != 39 && e.keyCode != 40 && e.keyCode != 46)
    {
        return false;
    }
    else
    {
        return true;
    }
}

function handleEvent(e)
{  
    if(!checkSpecialKeys(e))
    {
        if(window.event)
        {
            e.returnValue = false;
        }
        else
        {//For firefox
            e.preventDefault();
        }
    }
}

function CheckMaxLength(obj, Len)
{
    var TextLength  = obj.value.length;

    if(TextLength > Len)
    { 
        alert("Please enter character up to " + Len);
        obj.focus();
    }
}

function SetMaxLength( e, obj, Len )
{   
    if(!checkSpecialKeys(e))
    {
        var TextLength  = obj.value.length;
        
        TextLength  = TextLength + 1 ;
        
        if(TextLength > Len)
        { 
            if(window.event)
            {
                e.returnValue = false;
            }
            else
            {
                e.preventDefault();
            }
        }
    }
}

function movetolocation(obj)
{

//    var path = window.location.pathname;
//    var page = path.substring(path.lastIndexOf('/') + 1);
//    if(obj.options != null)
//    {
//        if(page.toLowerCase() == "locations.aspx")
//        {
//            //window.location.href = '#' + obj.options[obj.selectedIndex].value;
//            __doPostBack(obj.id, '');
//        }
//        else
//        {
//            var redirect = getRootPath() + 'Contact/Locations.aspx#' + obj.options[obj.selectedIndex].value;
//            window.location.href = redirect;
//        }
//        for(i = 0; i < obj.length; i++)
//        {
//            var div = document.getElementById(obj.options[i].value);
//            if(div != null)
//            {
//                div.className = '';
//            }
//        }
//        var d = document.getElementById(obj.options[obj.selectedIndex].value);
//        if(d != null)
//        {
//            d.className = 'border';
//        }
//    }
}

function KeyDownHandler(e, btn) 
{
    var eventInstance = window.event ? event : e;

    if (window.event) // IE
    {
        if (eventInstance.keyCode == 13) 
        {
            eventInstance.returnValue = false;
            eventInstance.cancel = true;
            var obj = document.getElementById(btn);
            obj.click();
            return false;
        }
    }
    else if (eventInstance.which) // Netscape/Firefox/Opera
    {
        if (eventInstance.which == 13) 
        {
            eventInstance.returnValue = false;
            eventInstance.preventDefault();
            eventInstance.cancelBubble = true;
            var obj = document.getElementById(btn);
            obj.click();
            return false;
        }
    }
}

//function nopaste(e)
//{
//    var code = (document.all) ? event.keyCode : e.which;
//    var ctrl = (document.all) ? event.ctrlKey : e.modifiers & Event.CONTROL_MASK;
//    var msg = "Sorry, this functionality is disabled.";
//    if(document.all)
//    {
//        if(ctrl && code == 86) // CTRL + V = 86
//        {
//            alert(msg);
//            window.event.returnValue = false;
//        }
//        else if(ctrl && code == 67) // CTRL + C = 67
//        {
//            alert(msg);
//            window.event.returnValue = false;
//        }
//    }
//    else
//    {
//        if(ctrl == 2) // CTRL = 2
//        {
//            alert(msg);
//            return false;
//        }
//    }
//}

function clearinputs()
{
   var o = document.getElementsByTagName("object");
   for(i=0;i<o.length;i++)
   {
       var e = o[i];
       //alert("object " + e);
       e.style.visibility = "hidden";
   }
   var chks = document.getElementsByTagName("input");
   for(i=0;i<chks.length;i++)
   {
       var e = chks[i];
       //alert("input " + e);
       e.disabled = true;
   }
   var combo = document.getElementsByTagName("select");
   for(i=0;i<combo.length;i++)
   {
       var e = combo[i];
       //alert("select " + e);
       e.disabled = true;
   }
   var textarea = document.getElementsByTagName("textarea");
   for(i=0;i<textarea.length;i++)
   {
       var e = textarea[i];
       //alert("textarea " + e);
       e.disabled = true;
   }
   var a = document.getElementsByTagName("a");
   for(i=0;i<a.length;i++)
   {
       var e = a[i];
       //alert("anchor " + e);
       e.href = "javascript:return false;";
       e.target = "_self";
       e.disabled = true;
       e.style.cursor = "default";                    
   }
   var img1 = document.getElementsByTagName("img");
   for(i=0;i<img1.length;i++)
   {
       var e = img1[i];
       //alert("img " + e);
//       if(e.id != "PrintNow")
//       {
           e.target = "_self";
           e.disabled = true;
           e.style.cursor = "default";   
       //}                 
   }
  
}   

// Created By Jigna Gandhi
// Used on Location.aspx page

function ChangePosition(p_x,p_y)
{
    var x = document.getElementById(p_x).value;
    var y = document.getElementById(p_y).value;
    //alert(y);
    window.scrollBy(x,y);
}

// Created By Jigna Gandhi
// Used on Current-Opening.aspx page
function ScrollPage(p_x,p_y,p_z)
{
    var y;
    //alert (p_y + " " + p_z);
    if (p_y != null)
        y = findPosition(p_y);
    else if (p_z != null)
        y = findPosition(p_z);
    else
        y = 0;
    //alert('Y = ' + y);
    window.scroll(0,y);
}

function findPosition(oElement)
{
    //alert(oElement);
    //alert(document.getElementById(oElement));
    var pY;
    if (typeof(oElement.offsetParent) != 'undefined')
    {  
        for (var posX=0,posY=0;oElement;oElement = oElement.offsetParent)
        {
            posX += oElement.offsetLeft;
            posY += oElement.offsetTop;
        }
        pY = posY;
    }
    else
    {
        pY = oElement.Y;
    }
    //alert("py = " + pY);
    return pY;
}

function Clear(p_pos,p_con)
{
    document.getElementById(p_pos).value = '';
    document.getElementById(p_con).value = '';
}