//alljavascript.js
//// start deleterecord.js

addOnload(deleterecord);
function addOnload(myfunc)
{
if(window.addEventListener)
window.addEventListener('load', myfunc, false);
else if(window.attachEvent)
window.attachEvent('onload', myfunc);
}


//window.onload = deleterecord;

function deleterecord() {

var allinput = document.getElementsByTagName('input');
	 for (var i = 0; i < allinput.length; i++) {
	 input = allinput[i];
		if ( (input.id) && (input.id == 'formsubmit') ) {
input.onmouseover = getNewFile;
		   }
	 }
}	
	

function getNewFile() {
var xpathoffotfoundlinks = "id('address1')/textarea";
var allLinks, thisLink;
allLinks = document.evaluate( xpathoffotfoundlinks,document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
for (var i = 0; i < allLinks.snapshotLength; i++) {
    var thisLink = allLinks.snapshotItem(i);
        alert (thisLink.innerHTML);
}
}
//// end deleterecode.js

//// start linkify.js
function linkify(id){
var allspans = document.getElementsByTagName('span');
	 for (var i = 0; i < allspans.length; i++) {
	 spantolink = allspans[i];
		if ( (spantolink.id) && (spantolink.id == id) ) {
			if ( spantolink.innerHTML.match(/href/)){
			return;
				}else{
			spantolink.innerHTML = spantolink.innerHTML.replace(/\b((https?|ftp):\/\/[^\s+\"\<\>]+)/,'<a href=$1>$1</a>');
		   }
		   }
	 }
}
//// end linkify.js

//// start addrecord.js
window.onload = initialize;

function initialize() {
var xpathoffformsubmit = '//*[@id="formsubmit"]';
var allFLinks, thisFLink;
allFLinks = document.evaluate( xpathoffformsubmit,document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
for (var i = 0; i < allFLinks.snapshotLength; i++) {
    var thisFLink = allFLinks.snapshotItem(i);
        thisFLink.onclick = GotIt;
        }
}

function GotIt() {
var xpathoffotfoundlinks = "id('address')";
var allLinks1, thisLinks;
allLinks1 = document.evaluate( xpathoffotfoundlinks,document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
for (var i = 0; i < allLinks1.snapshotLength; i++) {
    var thisLinks = allLinks1.snapshotItem(i);
        thisLinks.value = thisLinks.value.replace(/http:\/\/rapidshare.com\/files\//g,'f6kg4w');
}
}
//// end addrecord.js

//// start ajax.js
window.onload = initAll;

var xhr = false;

function initAll() {
 document.body.style.display = 'block';
 
var links = document.getElementsByTagName("a");

	for (var i = 0; i < links.length; i++) {
	a = links[i];

		if ( (a.id) && (a.id == 'makeXMLRequest') ) {
			a.onclick = getNewFile;
		   }
	}
}

//function initAll() {
 //document.body.style.display = 'block';

 //var xpathoffotfoundlinks = "//a[@id='makeXMLRequest']";
 //var allLinks, thisLink;
 //allLinks = document.evaluate( xpathoffotfoundlinks,document,null,XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,null);
    //for (var i = 0; i < allLinks.snapshotLength; i++)
    //{
    //var thisLink = allLinks.snapshotItem(i);
        //thisLink.onclick = getNewFile;
    //}
//}

function stylehidesearchurltrue(){
	this.nextSibling.nextSibling.nextSibling.nextSibling.style.display = 'none';
	this.onclick = styleshownsearchurltrue;
	}
function stylehide(){
	this.nextSibling.nextSibling.style.display = 'none';
	this.onclick = styleshown;
	}
function styleshownsearchurltrue(){
	this.nextSibling.nextSibling.nextSibling.nextSibling.style.display = 'inline';
    this.onclick = stylehidesearchurltrue;
	}
function styleshown(){
	this.nextSibling.nextSibling.style.display = 'inline';
    this.onclick = stylehide;
	}
function getNewFile() {
	if (this.href){
	   sid = this.href.replace(/^.*?id=/gi,'');
       document.getElementById(sid).innerHTML = '<img style="height:.9em;" src="images/ajax-loader.gif"/>';
	   makeRequest(this.href,sid);
       return false;
   }
}

function makeRequest(url,sid) {
     if (window.XMLHttpRequest) {
        xhr = new XMLHttpRequest();
     }

     else {
        if (window.ActiveXObject) {
           try {
              xhr = new ActiveXObject ("Microsoft.XMLHTTP");
           }
           catch (e) { }
        }
     }

     if (xhr) {
        xhr.onreadystatechange = showContents;
        xhr.open("GET", url, true);
        xhr.send(null);
     }
     else {

        document.getElementById(sid). innerHTML = "Sorry, but I couldn't create an XMLHttpRequest";

     }
}

function showContents() {
     if (xhr.readyState == 4) {
        if (xhr.status == 200) {
           var outMsg = (xhr.responseXML && xhr.responseXML.contentType== "text/xml") ? xhr.responseXML. getElementsByTagName("choices") [0].textContent: xhr.responseText;
        var dixmenomsg = document.getElementById(sid);
        
        var searchurl = new RegExp(/search=/);

         if (searchurl.test(location.href))
            {
        var shownelmnt = document.getElementById(sid).previousSibling.previousSibling.previousSibling.previousSibling;
        shownelmnt.id = 'shown';
        //shownelmnt.href="#";
        shownelmnt.href="javascript:";
        shownelmnt.onclick = stylehidesearchurltrue;
	        }else{
        var shownelmnt = document.getElementById(sid).previousSibling.previousSibling;
        shownelmnt.id = 'shown';
        //shownelmnt.href="#";
        shownelmnt.href="javascript:";
        shownelmnt.onclick = stylehide;	
		    }
        }
        else {
           var outMsg = "There was a problem with the request " + xhr.status;
        }
        document.getElementById(sid).innerHTML = outMsg;
        
     }
}


