function showEmailPopUp(e) {
		
	var posx = 0;
	var posy = 0;

	var scrolly = (document.documentElement) ? document.documentElement.scrollTop : window.pageYOffset
	var scrollx = (document.documentElement) ? document.documentElement.scrollLeft : window.pageXOffset
	
	var myWidth = 0, myHeight = 0;
	
	if( typeof( window.innerWidth ) == 'number' ) {
	    	//Non-IE
	  	  myWidth = window.innerWidth;
	  	  myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    	//IE 6+ in 'standards compliant mode'
	    	myWidth = document.documentElement.clientWidth;
	  	myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	   	//IE 4 compatible
	    	myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
  	}
	
	posy = scrolly+((myHeight-508)/2);
	posx = scrollx+((myWidth-440)/2);
	
	var popUpLayer = document.getElementById('emailHover');
	popUpLayer.style.top = posy + 'px';
	popUpLayer.style.left = posx + 'px';
	popUpLayer.style.display = 'block';
	grayOut(true);	
			
}
function hideEmailPopUp() {
	var popUpLayer = document.getElementById('emailHover');
	popUpLayer.style.display='none';
	grayOut(false);
}
function showPopUp(e) {
		
	var posx = 0;
	var posy = 0;

	var scrolly = (document.documentElement) ? document.documentElement.scrollTop : window.pageYOffset
	var scrollx = (document.documentElement) ? document.documentElement.scrollLeft : window.pageXOffset
	
	var myWidth = 0, myHeight = 0;
	
	if( typeof( window.innerWidth ) == 'number' ) {
	    	//Non-IE
	  	  myWidth = window.innerWidth;
	  	  myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    	//IE 6+ in 'standards compliant mode'
	    	myWidth = document.documentElement.clientWidth;
	  	myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	   	//IE 4 compatible
	    	myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
  	}
	
	posy = scrolly+((myHeight-608)/2);
	posx = scrollx+((myWidth-690)/2);
	
	var popUpLayer = document.getElementById('photosHover');
	popUpLayer.style.top = posy + 'px';
	popUpLayer.style.left = posx + 'px';
	popUpLayer.style.display = 'block';
	grayOut(true);
			
}
function hidePopUp() {
	var popUpLayer = document.getElementById('photosHover');
	popUpLayer.style.display='none';
	grayOut(false);
}
function showUsedByPopUp() {
    var popUpLayer = document.getElementById('usedByHover');
    popUpLayer.style.display='block';
}
function hideUsedByPopUp() {
	var popUpLayer = document.getElementById('usedByHover');
	popUpLayer.style.display='none';
}

function showClubOver() {
    var popUpLayer = document.getElementById('clubHover');
    popUpLayer.style.display='block';
}

function hideClubOut() {
    var popUpLayer = document.getElementById('clubHover');
    popUpLayer.style.display='none';
}

function showCoursePopUp(e) {
		
	var posx = 0;
	var posy = 0;

	var scrolly = (document.documentElement) ? document.documentElement.scrollTop : window.pageYOffset
	var scrollx = (document.documentElement) ? document.documentElement.scrollLeft : window.pageXOffset
	
	var myWidth = 0, myHeight = 0;
	
	if( typeof( window.innerWidth ) == 'number' ) {
	    	//Non-IE
	  	  myWidth = window.innerWidth;
	  	  myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    	//IE 6+ in 'standards compliant mode'
	    	myWidth = document.documentElement.clientWidth;
	  	myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	   	//IE 4 compatible
	    	myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
  	}
	
	posy = scrolly+((myHeight-428)/2);
	posx = scrollx+((myWidth-540)/2);
	
	var popUpLayer = document.getElementById('courseHover');
	popUpLayer.style.top = posy + 'px';
	popUpLayer.style.left = posx + 'px';
	popUpLayer.style.display = 'block';	
			
}
function hideCoursePopUp() {
	var popUpLayer = document.getElementById('courseHover');
	popUpLayer.style.display='none';
}
function showRollOver() {
    var popUpLayer = document.getElementById('tvHover');
    popUpLayer.style.display='block';
    
}
function hideRollOver() {
	var popUpLayer = document.getElementById('tvHover');
	popUpLayer.style.display='none';
}
function videoLoginPop() {
    var posx = 0;
	var posy = 0;

	var scrolly = (document.documentElement) ? document.documentElement.scrollTop : window.pageYOffset
	var scrollx = (document.documentElement) ? document.documentElement.scrollLeft : window.pageXOffset
	
	var myWidth = 0, myHeight = 0;
	
	if( typeof( window.innerWidth ) == 'number' ) {
	    	//Non-IE
	  	  myWidth = window.innerWidth;
	  	  myHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	    	//IE 6+ in 'standards compliant mode'
	    	myWidth = document.documentElement.clientWidth;
	  	myHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	   	//IE 4 compatible
	    	myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
  	}
	
	posy = scrolly+((myHeight-420)/2);
	posx = scrollx+((myWidth-577)/2);
	
	var popUpLayer = document.getElementById('videoLogin');
	popUpLayer.style.top = posy + 'px';
	popUpLayer.style.left = posx + 'px';
	popUpLayer.style.display = 'block';
	grayOut(false);	
	
	var player = document.getElementById('player');
	player.style.visibility = 'hidden';
}
function hideVideoLogin(){
    var popUpLayer = document.getElementById('videoLogin');
	popUpLayer.style.display='none';
	grayOut(false);
}


function grayOut(vis, options) {
  // Pass true to gray out screen, false to ungray
  // options are optional.  This is a JSON object with the following (optional) properties
  // opacity:0-100         // Lower number = less grayout higher = more of a blackout 
  // zindex: #             // HTML elements with a higher zindex appear on top of the gray out
  // bgcolor: (#xxxxxx)    // Standard RGB Hex color code
  // grayOut(true, {'zindex':'50', 'bgcolor':'#0000FF', 'opacity':'70'});
  // Because options is JSON opacity/zindex/bgcolor are all optional and can appear
  // in any order.  Pass only the properties you need to set.
  var options = options || {}; 
  var zindex = options.zindex || 50;
  var opacity = options.opacity || 60;
  var opaque = (opacity / 100);
  var bgcolor = options.bgcolor || '#000000';
  var dark=document.getElementById('darkenScreenObject');
  var selects = document.getElementsByTagName("select"); 
    for (i = 0; i != selects.length; i++) 
        { 
            selects[i].style.visibility = "hidden"; 
        }    
  if (!dark) {
    // The dark layer doesn't exist, it's never been created.  So we'll
    // create it here and apply some basic styles.
    // If you are getting errors in IE see: http://support.microsoft.com/default.aspx/kb/927917
    var tbody = document.getElementsByTagName("body")[0];
    var selects = document.getElementsByTagName("select"); 
    for (i = 0; i != selects.length; i++) 
        { 
            selects[i].style.visibility = "hidden"; 
        }    
    var tnode = document.createElement('div');           // Create the layer.
        tnode.style.position='absolute';                 // Position absolutely
        tnode.style.top = '0px';                           // In the top
        
        tnode.style.left='0px';                          // Left corner of the page
        tnode.style.overflow='hidden';                   // Try to avoid making scroll bars            
        tnode.style.display='none';                      // Start out Hidden
        tnode.id='darkenScreenObject';                   // Name it so we can find it later

    tbody.appendChild(tnode);                            // Add it to the web page
    
    dark=document.getElementById('darkenScreenObject');  // Get the object.
  }
  if (vis) {
    // Calculate the page width and height 
    if( document.body && ( document.body.scrollWidth || document.body.scrollHeight ) ) {
        var pageWidth = document.body.scrollWidth+'px';
        var pageHeight = document.body.scrollHeight+'px';
    } else if( document.body.offsetWidth ) {
      var pageWidth = document.body.offsetWidth+'px';
      var pageHeight = document.body.offsetHeight+'px';
    } else {
       var pageWidth='100%';
       var pageHeight='100%';
    }   
    //set the shader to cover the entire page and make it visible.
    dark.style.opacity=opaque;                      
    dark.style.MozOpacity=opaque;                   
    dark.style.filter='alpha(opacity='+opacity+')'; 
    dark.style.zIndex=zindex;        
    dark.style.backgroundColor=bgcolor;  
    dark.style.width= pageWidth;
    dark.style.height= pageHeight;
    dark.style.display = 'block';    
  } else {
     dark.style.display='none';
     var selects = document.getElementsByTagName("select"); 
     for (i = 0; i != selects.length; i++) 
        { 
            selects[i].style.visibility = "visible"; 
        } 
  }
}

function showLoginPopUp(e) {
    var posx = 0;
    var posy = 0;

    var scrolly = (document.documentElement) ? document.documentElement.scrollTop : window.pageYOffset
    var scrollx = (document.documentElement) ? document.documentElement.scrollLeft : window.pageXOffset

    var myWidth = 0, myHeight = 0;

    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }

    posy = scrolly + ((myHeight - 508) / 2);
    posx = scrollx + ((myWidth - 440) / 2);

    var dLogin = $("loginPopupWin") ? $("loginPopupWin") : $(document.createElement('div'));
    
    dLogin.setStyle(
        {        
            backgroundColor : "#FFFFFF",
            padding: "10px 10px 10px 10px",
            width: "300px"
        }
    );
    
    dLogin.id = 'loginPopupWin';
    dLogin.innerHTML = "<div style=\"text-align: right;\"><a onclick='hideLoginPopUp(this.parentNode.parentNode)' style=\"cursor: pointer;\"><img src=\"http://images.thegolfchannel.com/images/pr/351457.gif\" alt=\"Close Window\" border=\"0\" /></a></div><div>Loading...</div>";

    // CONNECT TO SERVER FOR LOGIN CONTROL
    new Ajax.Request('scripts/drive.ashx',
    {
        method: 'get',
        parameters: {
        "function": "getLogin"
        },
        onSuccess: function(transport) {            
            var response = transport.responseText;
            dLogin.childElements()[1].innerHTML = response;            
        },
        onFailure: function() {
            alert("There was an error trying to login."); 
        },
        onCreate: function() {
            
        },
        onComplete: function() {    
            
        }        
    });
    
    popUpLayer = dLogin;

    popUpLayer.style.top = posy + 'px';
    popUpLayer.style.left = posx + 'px';
    popUpLayer.style.display = 'block';
    popUpLayer.style.position = 'absolute';

    popUpLayer.style.zIndex = 200000;

    grayOut(true);
    document.getElementsByTagName("body")[0].appendChild(popUpLayer);
}

function hideLoginPopUp(handle) {
    if (handle)
        handle.style.display = 'none';
    else
        $("loginPopupWin").style.display = 'none';
    grayOut(false);
}

function DynamicLogin(callbackFunc) {
    //Send AJAX request to authenticate
    new Ajax.Request('scripts/drive.ashx',
    {
        method: 'get',
        parameters: {
            "function": "loginMyLessonPlan",
            email: $("glbLoginEmail").getValue(),
            pass: $("glbLoginPassword").getValue(),
            globalLogin: "true"
        },
        onSuccess: function(transport) {
            if (transport.responseText.length > 0) {                
                $("glbLoginError").innerHTML = transport.responseText;                
            } else {
                hideLoginPopUp();                 
                location.reload();
            }
        },
        onFailure: function(transport) {
            alert("There was an error logging in");
        }
    });
}

function showVGPSearchPopUp(tabNum) {
            
    var posx = 0;
    var posy = 0;

    var scrolly = (document.documentElement) ? document.documentElement.scrollTop : window.pageYOffset
    var scrollx = (document.documentElement) ? document.documentElement.scrollLeft : window.pageXOffset

    var myWidth = 0, myHeight = 0;

    if (typeof (window.innerWidth) == 'number') {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }

    posy = scrolly + ((myHeight - 508) / 2);
    posx = scrollx + ((myWidth - 440) / 2);

    popUpLayer = document.getElementById('vgpSearchHover');
        
    popUpLayer.style.top = posy + 'px';
    popUpLayer.style.left = posx + 'px';
    popUpLayer.style.display = 'block';
    popUpLayer.style.position = 'absolute';    
    
    popUpLayer.style.zIndex = 200000;

    if (tabNum != null)
        toggleTab(tabNum, 4);

    grayOut(true);
    document.getElementsByTagName("body")[0].appendChild(popUpLayer);
}

function hideVGPSearchPopUp() {
    var popUpLayer = document.getElementById('vgpSearchHover');
    popUpLayer.style.display = 'none';
    grayOut(false);
}

function showVGPLessonPlanPopUp(anchorPoint, popUpLayer, userid, videoKey) {    
    //if (typeof popUpLayer == 'string')
        //popUpLayer = document.getElementById(popUpLayer);
    var containerHandle = $(popUpLayer).childElements()[2];
    var buffer = "";        
       
    objVGPPopUpLessonPlans = new Object;
    objVGPPopUpLessonPlans.handle = popUpLayer;
    objVGPPopUpLessonPlans.userid = userid;
    objVGPPopUpLessonPlans.videoKey = videoKey;
    objVGPPopUpLessonPlans.containerHandle = containerHandle;

    new Ajax.Request('scripts/drive.ashx',
    {
        method: 'get',
        parameters: {
            "function": "lessonPlansByVid",
            video: videoKey,
            userid: userid
        },
        onSuccess: function(transport) {
            var xmlDoc = transport.responseXML.documentElement;
            objNodeErrorList = xmlDoc.getElementsByTagName("error");
            if (objNodeErrorList.length != 0) {
                containerHandle.innerHTML = objNodeErrorList[0].childNodes[0].nodeValue;
                alert("You must be logged in to modify Lesson Plans");
                showLoginPopUp();
                return;
            }
            objNodeList = xmlDoc.getElementsByTagName("lessonplan");
            if (objNodeList.length == 0) {
                containerHandle.innerHTML = "<div style=\"text-align:center; width:100%; height: 100%; padding-top:20px;\">You have no Lesson Plans</div>";
                $(popUpLayer).childElements()[$(popUpLayer).childElements().length - 1].childElements()[0].hide();                
            }
            else {
                for (i = 0; i < objNodeList.length; i++)
                    buffer += '<input  id="' + objNodeList[i].getAttribute("id") + '" name="' + objNodeList[i].getAttribute("id") + '" type="checkbox" ' + (objNodeList[i].getAttribute("containsvideoid") == "1" ? " checked" : "") + '/> <span>' + objNodeList[i].getAttribute("name") + '</span><br/>';
                containerHandle.innerHTML = buffer;
                $(popUpLayer).childElements()[$(popUpLayer).childElements().length - 1].childElements()[0].show();                
            }
            showVGPPopUp(anchorPoint, popUpLayer);
        },
        onComplete: function(transport) {
        },
        onFailure: function(transport) {
            alert("There was an error connecting to the server. Please try again.");
        },
        onException: function(request, exception, json) {
            alert("There was an exception error connecting to the server. Please try again.");
        }
    });            
}

function showVGPPopUp(anchorPoint, popUpLayer, preserveLastWindow) {
    var posx = 0;
    var posy = 0;

    if (anchorPoint.id == undefined)
        anchorPoint = document.getElementById(anchorPoint);
    if(popUpLayer == null)
        popUpLayer = document.getElementById(popUpLayer);
    if (popUpLayer.id == undefined)
        popUpLayer = document.getElementById(popUpLayer);
    
    if (preserveLastWindow != true) {
        if (typeof lastOpenedVGPPopUp != 'undefined')
            hideVGPPopUp(lastOpenedVGPPopUp);

        lastOpenedVGPPopUp = popUpLayer;
    }
        
    popUpLayer.style.display = 'block';
    popUpLayer.style.position = 'absolute';
    popUpLayer.zIndex = 200000;
    if (!Prototype.Browser.IE7)
        grayOut(true);


//    var newElem = popUpLayer.parentNode.firstDescendant();    
//    document.getElementsByTagName("body")[0].appendChild(popUpLayer);
//    $(newElem).insert({after: popUpLayer});
    //$(popUpLayer).replace(newElem);
    
    $(popUpLayer).clonePosition(anchorPoint, { setLeft: true, setTop: true, setHeight: false, setWidth: false, offsetLeft: 0, offsetTop: 0 })
}

function showLPPopup(anchorPoint, popUpLayer) {
    showVGPPopUp(anchorPoint, popUpLayer);
    // make asynchronous call to retrieve data from server    
    var e = document.getElementById(popUpLayer);
    //getLessonPlansByVideo(userid, videoKey, e.childNodes[2]);    
    // ----------------------------------
}

function hideVGPPopUp(popUpLayer) {
    if (popUpLayer.id == undefined)
        popUpLayer = document.getElementById(popUpLayer);
    popUpLayer.style.display = 'none';
    if (lastOpenedVGPPopUp == popUpLayer)
        grayOut(false);
}

function getLessonPlansByVideo(userid, videoKey, containerHandle) {
    url = 'scripts/drive.ashx?function=lessonPlansByVid&video=' + videoKey + '&userid=' + userid;
    containerHandle.innerHTML = "<div style=\"text-align:center; width:100%; height: 100%; padding-top:20px;\">Loading...</div>";
    buffer = "";
    // TODO -need feedback for timeout or no connection
    var xmlHttp = createXMLHTTP();
    if (xmlHttp != null) {
        xmlHttp.onreadystatechange = function() {
            if (xmlHttp.readyState == 4) {
                var xmlDoc = xmlHttp.responseXML.documentElement;
                objNodeErrorList = xmlDoc.getElementsByTagName("error");
                if (objNodeErrorList.length != 0) {
                    containerHandle.innerHTML = objNodeErrorList[0].childElements()[0].nodeValue;
                    hideVGPPopUp(objVGPPopUpLessonPlans.handle);
                    alert("You must be logged in to modify Lesson Plans");
                    showLoginPopUp();
                    return;
                }
                objNodeList = xmlDoc.getElementsByTagName("lessonplan");
                if (objNodeList.length == 0) {
                    containerHandle.innerHTML = "<div style=\"text-align:center; width:100%; height: 100%; padding-top:20px;\">You have no Lesson Plans</div>";
                    $(containerHandle.parentNode.childElements()[4].childElements()[0]).hide();
                }
                else {
                    for (i = 0; i < objNodeList.length; i++)
                        buffer += '<input  id="' + objNodeList[i].getAttribute("id") + '" name="' + objNodeList[i].getAttribute("id") + '" type="checkbox" ' + (objNodeList[i].getAttribute("containsvideoid") == "1" ? " checked" : "") + '/> <span>' + objNodeList[i].getAttribute("name") + '</span><br/>';
                    containerHandle.innerHTML = buffer;
                    $(containerHandle.parentNode.childElements()[4].childElements()[0]).show();
                }
            }
        }
        
        xmlHttp.open('GET', url, true);
        xmlHttp.send(null);
    }
}

function UpdateVideoInLessonPlans(containerHandle, userid, videoKey) {
    var url = 'scripts/drive.ashx';
    var kids = $A($(containerHandle).childElements());
    var buffer = new Array();
    var data = new Array();
    
    buffer.push({ "userid": userid });
    buffer.push({ "videoKey": videoKey });
    buffer.push({ "function": "editLessonsPlansByVid" });
    kids.each(function(child) {
        if (child.tagName == "INPUT") 
            data.push({ "id": child.id, "containsvideoid": (child.checked ? 1 : 0) });
    });
    buffer.push({ "data": data });

    // Send messsage to server
    var xmlHttp = createXMLHTTP();
    if (xmlHttp != null) {
        xmlHttp.onreadystatechange = function() {
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.responseText.indexOf('success')) {
                    //alert('Your lesson plans have been updated');
                    alert(xmlHttp.responseText);
                    refreshMyLessonPlan();
                    if (document.getElementById('ctl05_DataList1') != null)
                        raiseAsyncPostback();
                } else if (xmlHttp.responseText.indexOf('problem'))
                    alert('There was an error updating your lesson plans.');
                else
                    alert('There were no changes made to your lesson plans.');
            }
        };
    }
    xmlHttp.open('POST', url, true);
    xmlHttp.setRequestHeader("Content-Type", "application/json");
    xmlHttp.send(buffer.toJSON());

    // TODO - SHOULD FUNCTION DEPENDING ON RESULTS FROM AJAX CALL
    hideVGPPopUp(lastOpenedVGPPopUp);
}

function CreateNewLessonPlan(containerHandle, userid, isCallback) {
    containerHandle = $(containerHandle);
    var url = 'scripts/drive.ashx?function=newLessonPlan&userid=' + userid;
    var kids = $A($(containerHandle).childElements());
    var lessonPlan;

    kids.each(function(child) {
        if (typeof lessonPlan == 'undefined' && child.tagName == "INPUT") {
            lessonPlan = child.value;
            child.value = "";            
        }
    });

    url += "&newLessonPlanName=" + lessonPlan;

    // Send messsage to server
    var xmlHttp = createXMLHTTP();
    if (xmlHttp != null) {
        xmlHttp.onreadystatechange = function() {
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.responseText.indexOf('success') == -1)
                    alert(xmlHttp.responseText);
                else {
                    hideVGPPopUp(containerHandle.parentNode.parentNode);
                    // refresh lesson plan window
                    if (typeof objVGPPopUpLessonPlans != 'undefined')
                        getLessonPlansByVideo(objVGPPopUpLessonPlans.userid, objVGPPopUpLessonPlans.videoKey, objVGPPopUpLessonPlans.containerHandle);
                    refreshMyLessonPlan();
                    if (isCallback)
                        raiseAsyncPostback();
                }
            }
        };
    }

    xmlHttp.open('GET', url, true);
    xmlHttp.send(null);        
}

function RenameLessonPlan(containerHandle, userid, LessonPlanKey, NewLessonPlanName) {
    LessonPlanKey = GetSelectedOption();
    
    String.prototype.trim = function() {
        return this.replace(/^\s+|\s+$/g,"");
    }
    if(LessonPlanKey == null || NewLessonPlanName.trim() == "")
        return;
    containerHandle = $(containerHandle);    
    var url = 'scripts/drive.ashx?function=renameLessonPlan&userid=' + userid;
    var lessonPlan;
    url += "&LessonPlanKey=" + LessonPlanKey + "&newLessonPlanName=" + NewLessonPlanName;

    // Send messsage to server
    var xmlHttp = createXMLHTTP();
    if (xmlHttp != null) {
        xmlHttp.onreadystatechange = function() {
            if (xmlHttp.readyState == 4) {
                if (xmlHttp.responseText.indexOf('success'))
                {
                    hideVGPPopUp(containerHandle.parentNode.parentNode);
                    raiseAsyncPostback(); 
                }
                else
                    alert('An error occured. The lesson plan was not renamed.');
            }
        };
    }

    xmlHttp.open('GET', url, true);
    xmlHttp.send(null);
}


function UpdateLessonOrder(lessonPlanKey, lessonKey, OrderValue)
{   
    var url = 'scripts/drive.ashx';
    var buffer = new Array();
    
    buffer.push({ "lessonPlanKey": lessonPlanKey });
    buffer.push({ "lessonKey": lessonKey });
    buffer.push({ "orderValue": OrderValue });
    buffer.push({ "function": "editLessonsPlansByOrder" });

    // Send messsage to server
    var xmlHttp = createXMLHTTP();
    if (xmlHttp != null) {
        xmlHttp.onreadystatechange = function() {
            if (xmlHttp.readyState == 4) {
                if (!xmlHttp.responseText.indexOf('success'))
                {
                    alert('Lesson order was not updated!');
                    return;
                }
            }
        };
    }
    
    xmlHttp.open('POST', url, true);
    xmlHttp.setRequestHeader("Content-Type", "application/json");
    xmlHttp.send(buffer.toJSON());        
    // TODO - SHOULD FUNCTION DEPENDING ON RESULTS FROM AJAX CALL
    raiseAsyncPostback(); 
    alert('Lesson order has been updated.'); 
}


