<?xml version="1.0" encoding="UTF-8" ?>
<Module>
<ModulePrefs 
title="Search Engine Rankings"

author="James Charlesworth"
author_location="Atlanta, Ga"
author_email="info@rascalnet.com"
author_affiliation="Rascalnet.com"
description="Show off your top search engine rankings to your customers! Create an xml file in the same format as ours (http://www.rascalnet.com/buzz-tavern.xml) and give the url of the file."
screenshot="http://www.rascalnet.com/images/gadget.gif"
thumbnail="http://www.rascalnet.com/images/gadget.gif"
scrolling="true"
 >
<Locale lang="en" country="us" />
</ModulePrefs>
	<UserPref name="xml_feed" display_name="XML Feed" default_value="http://www.rascalnet.com/buzz-tavern.xml" />
	  <UserPref name="top_header" display_name="Header" default_value="Top Search Rankings" />
	<UserPref name="fix" display_name="Fix" default_value="null" />	
	<UserPref name="innerborder" display_name="Color" default_value="ffff99" />

<Content type="html">
<![CDATA[
<style>
a {
text-decoration:none;
font-size:12px;
}
#results {
font-size:12px;

}
#header {

text-align:center;
}

#footer {
font-size:12px;
text-align:center;
}
#message {
padding-top:10px;
margin-bottom:5px;
text-align:center;

}

a:hover {
text-decoration:underline;

}

</style>
<div id="content_div"></div>

<script type="text/javascript">

function swap(query, aengine) {
if (aengine == 'Google') {
document.forms[0].action ="http://www.google.com/search";
  
  
document.forms[0].elements[0].value=query;
document.forms[0].elements[0].style.color='black';
document.forms[0].elements[1].value='Google';
//var the_form = '<form name="searchForm" method="get" target="_blank"><input type="text" name="q" size="30" maxlength="255" value="' + query + '" /><input type="submit" style="width:60px;" value="Google" /></form>';
}

if (aengine == 'MSN') {
document.forms[0].action ="http://search.live.com/results.aspx";
document.forms[0].elements[0].value=query;
document.forms[0].elements[0].style.color='black';
document.forms[0].elements[1].value='MSN';
//the_form = '<form name="searchForm" method="get" target="_blank" > <input type="hidden" name="cp" value="1252"/> <input type="hidden" name="FORM" value="FREEWS"/><input type="text" name="q" size="30" maxlength="255" value="' + query + '" /><input type="submit" style="width:60px;" value="MSN" /></form>';
}


if (aengine == 'Yahoo') {
document.forms[0].action ="http://search.yahoo.com/search";
document.forms[0].elements[0].value=query;
 document.forms[0].elements[0].style.color='black';
document.forms[0].elements[1].value='Yahoo';


    //  the_form = '<form name="searchForm" id="searchBoxForm_undefined" method="get" target="_blank"> <input name="ei" value="UTF-8" type="hidden"><input name="fr" value="ystg" type="hidden"><input name="vs" id="web_radio" value="" type="hidden"><input type="text" id="searchTerm" size="30" name="p" value="' + query + '" /><input type="submit" style="width:60px;" value="Yahoo" /></form>';
}

//var _mydiv = document.getElementById('swapForm');
//_mytext = _mydiv.firstChild;
//_mytext.innerHTML = the_form;

}

function displayMenu() {
// XML breakfast menu data

var prefs = new _IG_Prefs();

var header = prefs.getString("top_header");
var url = prefs.getString("xml_feed")
var color = prefs.getString("innerborder");
var fix = prefs.getString("fix")
var border_color="border:2px solid #" + color + "\"";
var bg_color='background:#' + color + '"'; 



//var url = "http://www.rascalnet.com/gadget.xml?65";

var prefs = new _IG_Prefs(__MODULE_ID__);
// calorie limit set by user
var calorieLimit = prefs.getString("mycalories");
var description = prefs.getBool("mychoice");

_IG_FetchXmlContent(url, function (response) {
if (response == null || typeof(response) != "object" || response.firstChild == null) {
_gel("content_div").innerHTML = "<i>Invalid data.</i>";
return;
}

// Start building HTML string that will be displayed in <div>.
// Set the style for the <div>.
var html = "<div style='padding: 5px;font-family:Arial, Helvetica;" +
"text-align:left;font-size:90%'>";

// Set style for title.
html +="<div id='wrapper' style=\"" + border_color + "\" ><div style=\"" + bg_color + "\" id='header'>" + header + "</div>";
html +="<div id='message'>";

//set the form

var google_search = '<div id="swapForm"><form name="searchForm" method="get" target="_blank" action="http://www.google.com/search"><input type="text" name="q" size="30" style="color:gray" maxlength="255" value="Click links to add to query" /><input type="submit" value="Google" style="width:60px;" /></form></div>';




// Display menu title. Use getElementsByTagName() to retrieve the <menu> element.
// Since there is only one menu element in the file,
// you can get to it by accessing the item at index "0".
// You can then use getAttribute to get the text associated with the
// menu "title" attribute.
var title = response.getElementsByTagName("mySearch").item(0).getAttribute("title");
var amount=response.getElementsByTagName("myurl").length ;
// Alternatively, you could retrieve the title by getting the menu element node
// and calling the "attributes" function on it. This returns an array
// of the element node's attributes. In this case, there is only one
// attribute (title), so you can display the value for the attribute at
// index 0. For example:
//
// var title = response.getElementsByTagName("menu").item(0).attributes.item(0).nodeValue;

// Append the title to the HTML string.
//html += title + "</font></h3>";

// Append the title to the HTML string.
html += google_search + "</div><div id=\"results\">";
// Get a list of the <query> element nodes in the file
var itemList = response.getElementsByTagName("query");



// Loop through all <query> nodes
for (var i = 0; i < itemList.length ; i++) {

// For each <query> node, get child nodes.
var nodeList = itemList.item(i).childNodes;
// Loop through child nodes. Extract data from the text nodes that are
// the children of the associated name, price, and calories element nodes.
for (var j = 0; j < nodeList.length ; j++) {

var node = nodeList.item(j);

if (node.nodeName == "terms") {
term = node.firstChild.nodeValue

// var phrase = '<a onclick="query(\'' + phrase + '\')>' + phrase + '</a>';









}
if (node.nodeName == "myurl") {

var myurl = node.firstChild.nodeValue;


}
if (node.nodeName == "rank") {

var rank = node.firstChild.nodeValue;

}

if (node.nodeName=="engine") {
var engine= node.firstChild.nodeValue;
var phrase = '<a href="Javascript:swap(\''+ term + '\', \'' + engine + '\')">' + term + '</a>';

}

//if (node.nodeName == "calories") {
//var calories = node.firstChild.nodeValue;
//}
// If the user chose to display descriptions and
// the nodeName is "#cdata-section", grab the
// contents of the description CDATA for display.
//if (node.nodeName == "description" && description==true)
//{
//if (node.firstChild.nodeName == "#cdata-section")
//var data = node.firstChild.nodeValue;
//}
}

// Append extracted data to the HTML string.
html += "<i><b>";
html += phrase;
html +=" - " + engine;

html += "</b></i><br>";
html += "&emsp;";
html += myurl;

html += " - ";
html +="<b>Rank: " + rank + "</b><br />";
// If "calories" is greater than the user-specified calorie limit,
// display it in red.
//if(calories > calorieLimit) {
// html += "<font color=#ff0000>";

//html += " </font>";
}
// else
// html += calories + " calories";
// html += "<br>";

// If user has chosen to display descriptions
// if (description==true)
//{
// html += "<i>" + data + "</i><br>";
// }

//}
html += "</div></div><div id='footer'><a href=\"http://www.rascalnet.com/seo-blog/?p=10\" target=\"_parent\">Google Gadget &amp; Website Design in Atlanta, Ga</div></div>";

// Display HTML string in <div>
_gel('content_div').innerHTML = html;
});
}

_IG_RegisterOnloadHandler(displayMenu);
</script>

]]>
</Content>
</Module>
