/*
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 obj_caption_xmlhttp = createCaptionRequestObject();

function createCaptionRequestObject() {

   if (window.XMLHttpRequest) {
	
	   return new XMLHttpRequest();
	
	} else if(window.ActiveXObject) {
	
	   return new ActiveXObject("Microsoft.XMLHTTP");
	
    } else { 
             //If it gets to here, an error has occurred and we inform the user of this 
       alert("An Error Has Occurred!"); 

   } 


}



function get_caption($userid, $picno) {
	
	if (obj_caption_xmlhttp.readyState == 4 || obj_caption_xmlhttp.readyState == 0) { 

        obj_caption_xmlhttp.open('get', 'getpiccaption.php?id='+$userid+'&picno='+$picno);
        obj_caption_xmlhttp.onreadystatechange = handleResponse_caption;

        obj_caption_xmlhttp.send(null);	
    
	}

}

function handleResponse_caption() {
  
    if (obj_caption_xmlhttp.readyState == 4 ) { 

       	
		var response = obj_caption_xmlhttp.responseText;
		var update = new Array();
		if(response.indexOf('<c>') != -1) {
  
			update = response.split('<c>',3);
			changeText(update[0], update[1], update[2]);
	
        }

    }

}

function changeText( $userid, $caption, $pic_description ) {
 
    var $caption         = ( $caption         == null ) ? "" : $caption
    var $pic_description = ( $pic_description == null ) ? "" : $pic_description

//  Detect Browser
	var div_caption = 'pic_c' + $userid;
	var div_pic_dsc = 'pic_d' + $userid;

	var IE = ( document.all ) ? 1 : 0;
    var DOM = 0; 
    if ( parseInt( navigator.appVersion ) >= 5 ) { DOM = 1 };

    // Grab the content from the requested "div" and show it in the "container"
    if (DOM) {
		//display the title
        var viewer = document.getElementById(div_caption);
        viewer.innerHTML = $caption;
        //display the description
		var viewer = document.getElementById(div_pic_dsc);
        viewer.innerHTML = $pic_description;
    
	}  else if(IE) {
        //display the title
	    document.all[div_caption].innerHTML = '<b>' + $caption + '</b>';
		//display the description
		document.all[div_pic_dsc].innerHTML = $pic_description;

    }

}
