// function to create XmlHttp Object
function getxmlhttp( )
{

		var xmlHttp = false;
		
		if ( window.XMLHttpRequest )
		{
			
				// If IE7, Mozilla, Safari, etc: Use native object
				var xmlHttp = new XMLHttpRequest( );
				
		}
		else
		{
			
				if ( window.ActiveXObject )
				{
						
						// ...otherwise, use the ActiveX control for IE5.x and IE6
						var xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
						
				}
				
		}
		
		return xmlHttp;
		
}


//function to process an XMLHttpRequest
function process_sel( serverPage, objID, getOrPost, str )
{
	
		xmlhttp = getxmlhttp( );
		var obj = document.getElementById( objID );
		
		if ( getOrPost == "get" )
		{
				
				xmlhttp.open( "GET",serverPage );
				xmlhttp.onreadystatechange = function( )
				{
				
						if ( xmlhttp.readyState == 4 && xmlhttp.status == 200 )
						{
							
								obj.innerHTML = xmlhttp.responseText;
								
						}
						
				}
				
				xmlhttp.send( null );
				
		}
		
}

// function to detect
function detect_ie( )
{
	
		var bname = navigator.appName;
		
		if ( bname.search(/microsoft/i) == 0 )
		{
   				
				return 1;
				
   		}
		
		return 0;
		
}

// funtion to handle
function rateImg( rating, imgId )
{
		
		var serverpage = '/update.php?rating='+rating+'&imgId='+imgId;
		rating = rating * 25;
		document.getElementById( 'current-rating' ).style.width = rating+'px';
		
		if ( detect_ie( ) )
		{
				
				document.getElementById( 'current-rating' ).style.marginLeft = '-63px';
				
		}
		
		process_sel( serverpage, 'thankyou', 'get', '' );
		
}
