/*
W.Pitera @ FlyOnTheWire.Com @ 5/6/2007 
video cahnge handler
based on:

Page:           rating.js
Created:        Aug 2006
Last Mod:       Mar 11 2007
Handles actions and requests for rating bars.	
--------------------------------------------------------- 
ryan masuga, masugadesign.com
ryan@masugadesign.com 
Licensed under a Creative Commons Attribution 3.0 License.
http://creativecommons.org/licenses/by/3.0/
See readme.txt for full credit details.
--------------------------------------------------------- */

var xmlhttp
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	  try {
	  xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
	    xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	   xmlhttp=false
	  }
	 }
	@else
	 xmlhttp=false
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	 try {
	  xmlhttp = new XMLHttpRequest();
	 } catch (e) {
	  xmlhttp=false
	 }
	}
	function myXMLHttpRequest() {
	  var xmlhttplocal;
	  try {
	    xmlhttplocal= new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
	    xmlhttplocal= new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	    xmlhttplocal=false;
	  }
	 }

	if (!xmlhttplocal && typeof XMLHttpRequest!='undefined') {
	 try {
	  var xmlhttplocal = new XMLHttpRequest();
	 } catch (e) {
	  var xmlhttplocal=false;
	  alert('couldn\'t create xmlhttp object');
	 }
	}
	return(xmlhttplocal);
}

function sndVideoChangeReq(id) {
	//var theUL = document.getElementById('unit_ul'+id_num); // the UL
	
	// switch UL with a loading div
	//theUL.innerHTML = '<div class="loading"></div>';
	
    xmlhttp.open('get', 'handleVideoChange.php?id='+id);
    xmlhttp.onreadystatechange = handleVideoResponse;
    xmlhttp.send(null);	
}

function handleVideoResponse() {
  if(xmlhttp.readyState == 4){
		if (xmlhttp.status == 200){
       	
        var response = xmlhttp.responseText;
        var update = new Array();

        if(response.indexOf('|') != -1) {
            update = response.split('|');
            changeText('videoRating', update[0]);//videoRating div
			changeText('mediaText', update[1]);//mediaText div
			changeText('commentsPanel', update[2]);//commetnsPanel  div
			changeText('commentsLoggedIn', update[3]);//commentsLoggedIn div 
			//alert(update[4]);
			changeText('shareVideo', update[4]);//shareVideo div
			Behaviour.apply(ratingAction);
        }
		}
    }
}