// JavaScript Document
var scripts = document.getElementsByTagName('script');
var myScript = scripts[ scripts.length - 1 ];
var queryString = myScript.src.replace(/^[^\?]+\??/,'');
var params = parseQuery( queryString );


function parseQuery ( query ) {
   var Params = new Object ();
   if ( ! query ) return Params; // return empty object
   var Pairs = query.split(/[;&]/);
   for ( var i = 0; i < Pairs.length; i++ ) {
      var KeyVal = Pairs[i].split('=');
      if ( ! KeyVal || KeyVal.length != 2 ) continue;
      var key = unescape( KeyVal[0] );
      var val = unescape( KeyVal[1] );
      val = val.replace(/\+/g, ' ');
      Params[key] = val;
   }
   return Params;
}

function printData(data){
	//document.open();
	//var frag = document.createDocumentFragment();
	
	//newChild = newDiv.appendChild(document.createTextNode(xmlhr.responseText));
	iframe = '<iframe id="widgetbox_widget_iframe_0" width="320" scrolling="no" height="538" frameborder="0" name="widgetbox_widget_iframe_0" border="0" src="" style="z-index:10" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" ></iframe>';
	//alert(iframe);
	//http://localhost/weather/get_weather.php?'+data+'
	
	var parentName = myScript.parentNode.nodeName.toLowerCase();
	if(parentName=='head'||parentName=='title'||parentName=='html')
		{
		alert("This Widget code have to put under body tag to get desired result.");
		}
	else
		{
		var newDiv = document.createElement('div');	
		myScript.parentNode.appendChild(newDiv);
		newDiv.innerHTML = iframe;
		newDiv.style.zIndex = -10000;
		ifr = document.getElementById('widgetbox_widget_iframe_0');
		ifr.style.display="block";
		ifr.style.visibility="visible";	
		ifr.src = 'http://vacationrealtywidgets.com/contactformwidget/widget.php?'+data;	
		//document.write(iframe);
		//alert(ifr);
		}
	
	//myScript.parentNode.appendChild(newDiv);
	//newDiv.innerHTML = iframe;
	
	//frag.appendChild(newChild);
	//document.body.appendChild(frag);
	//document.body.appendChild(frag);
	//document.write(data);
	//document.close();
	}
function init()
	{
	//getData(queryLocation);	
	//alert(params.queryLocation);
	//alert(params.temp);
	
	send_data = "params="+params.appId;
	printData(send_data);
	}

init();
//getData(queryLocation);