function rs()
{
toSwap = document.getElementById("toRot").value

r1 = document.getElementById("rs1").value -0
r2 = document.getElementById("rs2").value -0
len = document.getElementById("rs3").value -0

rdiff = r2-r1

swapResult = ""

if(((r1 > r2) && (r1 < r2 + len)) || ((r2 > r1) && (r2 < r1 + len)))
{
window.alert("Ranges overlap!")
return	
}

/*
if(r2 < r1 + len)
alert("COLLISION!")
return
}
else
{
if(r1 < r2 + len)
alert("COLLISION!")
return
}
*/
	
for(i=0; i<toSwap.length; i++) //>)
{
charC = toSwap.charCodeAt(i)

if(charC > r1-1 && charC < r1+len)
{
swapResult += String.fromCharCode(charC + rdiff)
}
else if(charC > r2-1 && charC < r2+len)
{
swapResult += String.fromCharCode(charC - rdiff)
}
else
{
swapResult += String.fromCharCode(charC)
}

}

document.getElementById("toRot").value = swapResult
}

function xor1()
{
toXOR = document.getElementById("toRot").value
XOResult = ""

XORBy = document.getElementById("xor").value -0

for(i=0; i<toXOR.length; i++) //>)
{
XOResult += String.fromCharCode(toXOR.charCodeAt(i) ^ XORBy)
}

document.getElementById("toRot").value = XOResult
}

function xor2()
{
//window.status = ""

toXOR = document.getElementById("toRot").value
XOResult = ""

XORBy = document.getElementById("xor").value

for(i=0; i<toXOR.length; i++) //>)
{
XORBed = XORBy.charCodeAt(i % XORBy.length)

//window.status = window.status + "|" + (i % XORBy.length)
//window.status = window.status + "|" + (i % XORBy.length) + "-" + (toXOR.charCodeAt(i)) + "-" + (toXOR.charCodeAt(i) ^ XORBed)

XOResult += String.fromCharCode(toXOR.charCodeAt(i) ^ XORBed)
}

document.getElementById("toRot").value = XOResult
}

function rot()
{
rotFrom = document.getElementById("toRot").value

//window.alert(rotFrom)
rotTo = ""




for(i=0; i<rotFrom.length; i++) //>)
{
charc = rotFrom.charCodeAt(i)

if(charc >96 && charc < 110)//>)
{
charc += 13	
}
else if(charc> 109 && charc < 123)//>)
{
charc -= 13	
}

if(charc >64 && charc < 78) //>)
{
charc += 13	
}
else if(charc> 77 && charc < 91)//>)
{
charc -= 13	
}
	
rotTo += String.fromCharCode(charc)	
}



document.getElementById("toRot").value = rotTo
}

