﻿// JScript File

function setOpacity(eID, opacityLevel)
{
    var eStyle = document.getElementById(eID).style;

    eStyle.opacity = opacityLevel / 100;
    eStyle.filter = 'alpha(opacity=' + opacityLevel + ')';
}

function fade(eID, startOpacity, stopOpacity, duration)
{
//    var speed = Math.round(duration / 100);
    var speed = 20;
    var timer = 0;

    // fade in
    if (startOpacity < stopOpacity)
    {
        for (var i = startOpacity; i <= stopOpacity; i++)
        {
            setTimeout("setOpacity('" + eID + "'," + i + ")", timer * speed);
            timer++;
        }
        return;
    }

    // fade out
    for (var i = startOpacity; i >= stopOpacity; i--)
    {
        setTimeout("setOpacity('" + eID + "'," + i + ")", timer * speed);
        timer++;
    }
}

var myArray = [];

myArray[0] = 'Your customer service people are as helpful as any I have ever dealt with. &nbsp;<img alt=\"quote2\" src=\"../../McKissock/images/quotes_02.gif\" /><br /> &nbsp; - Dave F.'
myArray[1] = 'The most terrific online course I have ever experienced!  It was comprehensive, fair and complete.  I would recommend McKissock to anyone who has a computer in their home.&nbsp; <img alt=\"quote2\" src=\"../../McKissock/images/quotes_02.gif\" />&nbsp; - Lauren B.'
myArray[2] = 'The course information and the exams really gave me an opportunity not just to learn, but to retain the information.&nbsp; <img alt=\"quote2\" src=\"../../McKissock/images/quotes_02.gif\" />&nbsp; - Juanita M.'
myArray[3] = 'I love the self-paced instruction. It was very easy to navigate through <br />the course.&nbsp; <img alt=\"quote2\" src=\"../../McKissock/images/quotes_02.gif\" /> &nbsp; - Elizabeth B.'
myArray[4] = 'Continuing education finally made enjoyable.  You\'ll never sit through classes again.  McKissock is the only way to go.&nbsp; <img alt=\"quote2\" src=\"../../McKissock/images/quotes_02.gif\" />&nbsp; - Will N.'
myArray[5] = 'I was nervous about taking a class online, but I found McKissock to be well-organized and easy to use.  I highly recommend them!&nbsp; <img alt=\"quote2\" src=\"../../McKissock/images/quotes_02.gif\" /> <br /> &nbsp;- Scott M.'
myArray[6] = 'For people who have many things going on in their lives, this online opportunity was wonderful.&nbsp; <img alt=\"quote2\" src=\"../../McKissock/images/quotes_02.gif\" />&nbsp;- Janet C.'
myArray[7] = 'I was very pleased with the course format, clarity of instruction and easy maneuverability within the course material.&nbsp; <img alt=\"quote2\" src=\"../../McKissock/images/quotes_02.gif\" />&nbsp;- Randy E.'
myArray[8] = 'Your course selection is the best I could find, and the software is such that even the least computer-savvy could handle it.&nbsp; <img alt=\"quote2\" src=\"../../McKissock/images/quotes_02.gif\" /> &nbsp;- Maureen M.' 
myArray[9] = 'I was challenged and able to learn at my own pace and from the comfort and ease of my office.&nbsp; <img alt=\"quote2\" src=\"../../McKissock/images/quotes_02.gif\" />  &nbsp;- Peter S.' 
myArray[10] = 'I continue to use McKissock\'s online courses as they are the most complete and easiest to learn from.&nbsp; <img alt=\"quote2\" src=\"../../McKissock/images/quotes_02.gif\" />  &nbsp;- Gail K.'
myArray[11] = 'I liked the easy to read and navigate layout of the course.&nbsp; <img alt=\"quote2\" src=\"../../McKissock/images/quotes_02.gif\" /> &nbsp;- Karen A.' 
myArray[12] = 'It’s nice to see topics that are not addressed often enough in typical CEU courses.&nbsp; <img alt=\"quote2\" src=\"../../McKissock/images/quotes_02.gif\" />  &nbsp;- Heidi G.' 
myArray[13] = 'It’s great to have courses that provide information I can actually use!&nbsp; <img alt=\"quote2\" src=\"../../McKissock/images/quotes_02.gif\" />  &nbsp;- Cathy S.'

var quoteNum = 0;
var fadeTime = 2000;
var waitTime = 3000;

function throb() 
{
    //    var fadeTime = 2000;
    //    var waitTime = 3000;
    var qt = document.getElementById("myQuotes");

    // stuff a quote into the target div
    qt.innerHTML = "<img alt=\"quote\" src=\"../../McKissock/images/quotes_01.gif\" />&nbsp;" + myArray[quoteNum];
    
    // cycle our array offset value
    quoteNum = (++quoteNum % myArray.length);

    // fade In
    fade("myQuotes", 0, 100, fadeTime);

    // fade out after a certain amount of time
    setTimeout(function() { fade("myQuotes", 100, 0, fadeTime); }, 7000 );
    //setTimeout(function() { fade("myQuotes", 100, 0, fadeTime); }, (fadeTime * 2) + waitTime );

    //Call Next removed in favour of a setinterval in calling page
    //setTimeout(function() { throb(); }, 10000);
    //setTimeout(function() { throb(); }, (fadeTime * 2) + (waitTime * 2));
}
function showState(type, id, license) {    
    MAGIservice.GetCourseStatesAndPrice(id, license, CourseReturn);   
    document.getElementById("selectState").onchange = function() {courseAction(type, id, license, this.options[this.selectedIndex].value);};
    
}

function CourseReturn(ret){
    //alert(ret);
    var ddl = document.getElementById("selectState");
    ddl.options.length=0;
    ///alert(ddl);
    var arr = ret.split(",");
    ddl.options.lenght=arr.length;
    //var theOption = new Option;
    var theOption=document.createElement('option');
    theOption.text="(Select State)";
    theOption.value="0";
    //theOption = new Option("(Select State)", "0");
    //alert(theOption);
    try{
    ddl.add(theOption,null);
    }catch(ex){
    ddl.add(theOption);
    }
    //theOption.text="(Select State)";
    //theOption.value="0";
    //ddl.add(theOption);
    //alert(arr.length);
    for(i=0;i<arr.length;i++){
        //alert(i);
        var theOption=document.createElement('option');
        theOption.text=arr[i].substring(0,2);
        theOption.value=arr[i];
        //theOption = new Option(arr[i].substring(0,2), arr[i]);
        
        //alert(theOption);
        try{
        ddl.add(theOption,null);
        }catch(ex){
        ddl.add(theOption);
        }
        
        //alert(i);
    }
    //alert('after for');
    document.getElementById("selectStateDiv").style.display = 'block';
    
}

function courseAction(action, CID, LICENSE, ST) {
    //alert('in course action');
    //Parse the ST value    
    
    var stateSplit = "";
    if (action == 'sample') {
        stateSplit = ST.split(';');
        
        window.open("http://www.mckissock.com/Mckissock/Sample/Sample.aspx?CID=" + CID + "&ST=" + stateSplit[0] + "&LID=" + LICENSE,"_blank","menubar=no,resizable=yes,scrollbars=yes");
    } else if (action == 'course'){
        stateSplit = ST.split(';');
        //alert(stateSplit[0]);
        //alert(stateSplit[1]);
        //iCallID = service.MagiServ.callService(AddToCartReturn, "TestCart", 1);
        
        document.getElementById("course" + CID + "Image").style.display = "inline";
        document.getElementById("course" + CID + "Link").style.display = "none";
        JavaToCartLanding("course" + CID,0 , 0, CID, stateSplit[1],0,'','','',LICENSE,stateSplit[0], 0);
        //alert("past add to cart");
    } 
    document.getElementById("selectStateDiv").style.display = 'none';
    document.getElementById("selectState").selectedIndex = 0;
}
function JavaToCartLanding(id, studentID, myCartId ,itemID, itemAmount ,itemType, packageID, seminarID, enrollmentID, lictypeid, state, partnershipId){
        //Use the ajax web service to add an item to the cart.  On success, it call the
        //javascript function AddedToCart.
        MAGIservice.AddToCart(id, studentID,myCartId ,itemID, itemAmount ,itemType,packageID ,seminarID, enrollmentID, lictypeid,state,partnershipId, AddedToCartLanding);
}


function AddedToCartLanding(result){
        //First get the link that was clicked, the id of the link is returned in result
        var stringID = String(result);
    
        var link = document.getElementById(stringID + "Link");
        var image = document.getElementById(stringID + "Image");
        //change the text and href to point to the cart.
        link.href="../../CommonForms/ShoppingCart/viewCart.aspx";
        link.innerHTML="In Cart/View";
        link.style.display="inline";
        image.style.display = "None";
    
}
function AddToCartReturn(res){
    //alert("In Result");
    if (!res.error) {
    alert("Successful call. Result is " + res.value);
    }
    else {
        alert("Unsuccessful call. Error is "
        + res.errorDetail.string);
  }
}
