// 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();
	mainsize = params.size;
	size = params.size.split('X');
	if(size.length==2)
		{
		fsizeY = parseInt(size[1])+60;	
		//newChild = newDiv.appendChild(document.createTextNode(xmlhr.responseText));
		iframe = '<iframe id="widgetbox_widget_iframe_0" width="'+size[0]+'" scrolling="no" height="'+fsizeY+'" frameborder="0" name="widgetbox_widget_iframe_0" border="0" src="" marginwidth="0" marginheight="0" vspace="0" hspace="0" allowtransparency="true" ></iframe>';
		//alert(iframe);
		//http://project.cybernetikz.com/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;
			ifr = document.getElementById('widgetbox_widget_iframe_0');
			ifr.style.display="block";
			ifr.style.visibility="visible";	
			ifr.src = 'http://vacationrealtywidgets.com/rsswidget/show_rss.php?size='+mainsize+'&'+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);
	//alert(params.params);
	send_data = "params="+params.params;
	printData(send_data);
	}

init();
//getData(queryLocation);