/*
 * Copy this file in your html page
 * <script src="http://dip.europages.com/europages-hook/js/ip.js" type="text/javascript"></script>
 *  
 * and call the function in a windows.load javascript function and specify the element id
 * 
  <script type="text/javascript">
	window.onload = function(){
		giveMyIpAdress('clientIpAdress');
	}
    </script>	
 * 
 */


function giveMyIpAdress(element_id){
	giveMyIpAdressByUrl('http://dip.europages.com/europages-hook/getip-by-callback.jsp', element_id);
}

function giveMyIpAdressByUrl(url, element_id){
	 
	 var script = document.createElement('script');
	 script.src = url;
	//callback function, give the function method to call
	 script.src += '?func=callbackFunction'; 
	 script.src += '&element_id='+element_id;
	 script.type = 'text/javascript';
	 
	 //inject in DOM model
	 var head = document.getElementsByTagName('HEAD')[0];
	 head.appendChild(script);
}
 
function callbackFunction(element_id, value){
   if (value) {
	   document.getElementById(element_id).value='S'+value;
   }
   else {
	   document.getElementById(element_id).value = 'ERROR';
   }
} 

