function addProvider(url,adult) {
if (adult == "true") {
var confirmAdult = confirm("This search plugin points to a website which may contain adult content. By clicking 'OK' you confirm you are old enough and it is legal in your country of residence to view this type of content.")
if (confirmAdult) {

} else {
return;
}
}
try {
window.external.AddSearchProvider(url);
} catch (e) {
alert("You need to be using IE7 or Firefox2 to add a search engine\r\nYou can also install search plugins by using the drop down menu to the right of the search box.");
return;
}
}

function changeIcon() {
var dropDownValue = document.getElementById("ctl00_mainContent_searchicon").value
if (dropDownValue == "upload") {
document.getElementById(dropDownValue).style.display = "block";
document.getElementById("favicon").style.display = "none";
}
if (dropDownValue == "favicon") {
document.getElementById(dropDownValue).style.display = "block";
document.getElementById("upload").style.display = "none";
}
if (dropDownValue == "none") {
document.getElementById("favicon").style.display = "none";
document.getElementById("upload").style.display = "none";
}
}

function styleForm() {
if (document.getElementById("uploadicon").value == "") {
document.getElementById("uploadicon").disabled = true;
document.getElementById("searchicon").disabled = false;
} else {
document.getElementById("uploadicon").disabled = false;
document.getElementById("searchicon").disabled = true;
}
}

function validateTestURL(sender,args) {
var testTest = args.Value;
if (testTest.indexOf("TEST") < 0) {
args.IsValid =  false;
} else {
args.IsValid = true;
}
}

function validateTestError(sender,args) {
var testError = args.Value;
if (testError.match(/[\/|=|%28]TEST/)) {
args.IsValid = true;
} else {
args.IsValid = false;
}
}

function validateHttpURL(sender,args) {
var testHttp = args.Value;
if (testHttp.match(/(^http[s]?:\/\/)/)) {
args.IsValid = true;
} else {
args.IsValid = false;
}
}

function checkTagLength(sender,args) {
var testTag = args.Value;
if (testTag.length <= 50) {
args.IsValid = true;
} else {
args.IsValid = false;
}
}

function checkJavaScript(divid) {
document.getElementById("nojavascript").style.display = "none";
document.getElementById(divid).style.visibility = "visible";
}

function inputMod(obj) {
obj.hlptext = "Search the plugin list";
if (obj.value==obj.hlptext) {
obj.hlptext=obj.value
obj.value=(obj.hlptext==obj.value)?'':(obj.value=='')?obj.hlptext:obj.value
}
}

function showKey(text) {
if (document.getElementById("keyp").style.display == "none") {
document.getElementById("keyp").style.display = "block";
document.getElementById("showhidekey").innerHTML = "Hide "+text+" -";
} else {
document.getElementById("keyp").style.display = "none";
document.getElementById("showhidekey").innerHTML = "Show "+text+" +";
}
}

function checkURL(sender,args) {
var testURL = args.Value;

if (window.XMLHttpRequest) {
request = new XMLHttpRequest();
} else if (window.ActiveXObject) {
request = new ActiveXObject("Msxml2.XMLHTTP");
if (!request) {
request = new ActiveXObject("Microsoft.XMLHTTP");
}
}
if (request) {
//request.onreadystatechange=handleResponse;
request.open("GET","http://www.searchplugins.net/test/test.asp?url="+testURL,false)
request.send(null)

if (request.readyState == 4) {
if (request.status == 200) {
var doc = request.responseXML;
var root = doc.documentElement;
for (var x=0;x<root.childNodes.length;x++) {
if (root.childNodes[x].nodeName == "url") {
var urlStatus = root.childNodes[x].firstChild.nodeValue;
}
}
if (urlStatus == "error" && testURL != "http://www.searchplugins.net/pluginlist.aspx?q=TEST") {
args.IsValid = false;
} else {
args.IsValid = true;
} 
}
}
}
}