// This is the javascript for the Troubleshooting wizards
var wiztrack,origin ='';

var browser = new Object()
function show(id)
{
  document.getElementById(id).className="show"
}

function hide(id)
{

  document.getElementById(id).className="hidden"
}

function nextQuestion(idtohide,idtoshow,back)
{   
    unsolved('hide') // hide the button
    if (idtohide!='')
    {
        hide(idtohide);
    }
    show(idtoshow);
    if (!back)
    {
      document.getElementById(idtoshow).previousQues=idtohide
    }
    else 
    {
        document.getElementById('supportform').className = 'hidden' // hide the support form
    }
    
    bb=document.getElementById('backButton')
    bb.preques = document.getElementById(idtoshow).previousQues
    bb.thisques = idtoshow 
    bb.style.visibility='visible'; // show the back button
    document.getElementById('answer').style.visibility='hidden'
    wiztrack=wiztrack+idtoshow+';';
    document.getElementById('allquestions').className = 'show';
    
 }

function checkTop()
{   
    bb=document.getElementById('backButton')
    if (bb.preques== null )
    {
       bb.style.visibility='hidden'; // hide the button
       document.getElementById('answer').style.visibility='visible'
     }   
}

function passwordForm()
{
    window.open("passwordrequest.html",'pwdreq','config=height=300,width=400')
}

function supportForm(from,fromID)
{ 
  
  if (document.getElementById('supportform_iframe')) // have to clear the form if the user goes back
  {
    sdiv = document.getElementById('supportform_iframe');
    sdiv.parentNode.removeChild(sdiv);    
  }
  addIframe('supportform','../issuetracker/supportform.php?fromts=y',800,600);
  origin=from 
  unsolved('hide')
  document.getElementById('supportform').className = 'show';
  document.getElementById('allquestions').className = 'hidden';
  if (fromID!='')
  {
    bb=document.getElementById('backButton')
    bb.preques = fromID
  }
  
} 

UA=navigator.userAgent.toUpperCase()+';'
browser.type = browser.version = browser.sp = browser.fullname = browser.make = ''; //initialize properties that we will use
if (UA.indexOf('OPERA') >=0)
{
    pos = UA.indexOf('OPERA')
    browser.type =UA.substr(pos,UA.indexOf(';',pos)-pos)
    browser.make='opera'
}
else
{
   if(UA.indexOf('FIREFOX') >=0)
  
   {
        pos = UA.indexOf('FIREFOX')
        browser.type =UA.substr(pos,UA.indexOf(';',pos)-pos)
        browser.make='firefox'
    }
   
    else
    {
        if(UA.indexOf('MSIE') >=0)
        { //  this is some type IE browser
            pos = UA.indexOf('MSIE')
            IEstring = UA.substr(pos,UA.indexOf(';',pos)-pos)
            browser.make='ie'
            browser.type='MSIE'
            browser.version= IEstring.substr(IEstring.lastIndexOf(' '))
            browser.sp = navigator.appMinorVersion.substr(navigator.appMinorVersion.indexOf('SP')+2)
            browser.fullname='Microsoft Internet Explorer version ' 
                                + browser.version + ' Service Pack ' + browser.sp
        }
        else
        {
            browser.type=browser.fullname=''
        }
    }
}

var oldIE=notIE=okIE=false

if (browser.type=='MSIE')
{ 
    if (browser.version < 6 || browser.sp <1)
    {
        oldIE=true
    }
    else
    {
        okIE=true
    }
} 
else
{
  notIE=true
}

function ieTest(id)
 {
    if (okIE)
    {
         nextQuestion(id,'conntest',false)
    }
    else
    {
        if(oldIE)
        { 
            nextQuestion(id,'noIE',false)
        }
        else
        { 
            nextQuestion(id,'connection',false)
        }
     }
 }

function addIframe(iid,isrc,iheight,iwidth)
{   // this function will load the content of an iframe only if it hasn't already been loaded
    // this is designed to allow content to be brought into a page as and when needed to 
    // conserve bandwidth and speed up the loading of the page.
    // iid - the name of the tag after which the iframe will be loaded
    // isrc - the name of the page that will be loaded in the iframe
    // iheight - the height of the iframe
    // iwidth - the width of the iframe
    unsolved('show') // show a button that brings up a support form
    
   if (!document.getElementById(iid + '_iframe')) // only execute first time
    {
        document.getElementById("loading").innerHTML='Please wait while help is loading'
        iObj = document.createElement("iframe")
        iObj.src = isrc
        iObj.height = iheight
        iObj.width = iwidth
        iObj.frameborder = '0'
        iObj.margin = '0'
        iObj.padding = '0'
        iObj.style.border='0px' // if you don't do this you get a border regardless of frameborder setting
        iObj.id = iid + '_iframe' //give the frame an id that can be checked 
        iframe=document.getElementById(iid)
        iframe.appendChild(iObj)
        document.getElementById("loading").innerHTML=''
        
    }

}
function noHTTPS()
{
    if (browser.make=='ie')
    {
        window.location.href='http://draft.incrediblecharts.com/help_troubleshooting/ic_internet_explorer.htm' 
    }
    else
    {
        supportForm('notIE')
    }
}
function unsolved(act)
{   
    if (act=='show')
    {
        document.getElementById('unsolved').className='show'
        document.getElementById('supportform').className = 'hidden'
    }
    else
    {
        document.getElementById('unsolved').className='hidden'
       // document.getElementById('supportform').className = 'show'
    }
    
}

function setStartpoint()
{    
    if (returnQval('startpoint') !='')
    {
        document.getElementById('downFirst').className='hidden';
        document.getElementById(returnQval('startpoint')).className='';           
    }         
}


