var clip = null;

function init() {
// setup single ZeroClipboard object for all our elements
clip = new ZeroClipboard.Client();
clip.setHandCursor( true );

// assign a common mouseover function for all elements using jQuery
$('div.multiple').mouseover( function() {
// set the clip text to our innerHTML
clip.setText( this.innerHTML );

// reposition the movie over our element
// or create it if this is the first time
if (clip.div) {
clip.receiveEvent('mouseout', null);
clip.reposition(this);
}
else clip.glue(this);
 
// gotta force these events due to the Flash movie
// moving all around.  This insures the CSS effects
// are properly updated.
clip.receiveEvent('mouseover', null);
} );
}

function dofocus(){
document.myform.url.focus();
}
/*function confirmDel(getId) {
if ( confirm( "Are you sure you want to delete this tidy url?" ) ) { 
location.href='delete.asp?id='+ getId +'';
}
return false;
}*/
function GotoLink(obj,linkID){
obj.target='_blank';
obj.href='http://tidy.ws?' + linkID;
}
	function SetCode(tcode) {
		document.getElementById('code').value=tcode
	}
	
	function confirmDel(getid){
	document.getElementById('code').value=getid;
	delwindow=dhtmlmodal.open('dbox', 'div', 'deldiv', 'Please Confirm', 'center=1,width=400px,height=175px,resize=0,scrolling=0')
	
}
function dodel(whichbutton,pag){
	xid = document.getElementById('code').value 
	if (whichbutton=="yes") {
		document.location.href='delete.asp?id='+xid+'&p='+pag ;
		delwindow.hide()
}
		delwindow.hide()
}
function checkCheckboxes() {
  var docForm=document.readForm;
  var len = docForm.elements.length;
  for( var i=0 ; i<len ; i++) {
	  if (docForm.elements[i].name == 'delCheck') {
	    if (docForm.elements[i].checked != '')
	      return true;
	  }
  }
  return false;
} 
	function confirmDelete(getid){
  if ( !checkCheckboxes() ) {
	selwindow=dhtmlmodal.open('dbox', 'div', 'ndiv', 'Information', 'center=1,width=400px,height=175px,resize=0,scrolling=0')
  return false;	
}
	selwindow=dhtmlmodal.open('dbox', 'div', 'seldiv', 'Please Confirm', 'center=1,width=400px,height=175px,resize=0,scrolling=0')
}
function dodelsel(whichbutton){
	if (whichbutton=="yes") {
		document.readForm.submit();
		selwindow.hide()
}
		selwindow.hide()
}

function doemail(){
	elwindow=dhtmlmodal.open('ebox', 'div', 'emaildiv', 'Contact Tidy.ws', 'center=1,width=480px,height=337px,resize=0,scrolling=0')
}

function dotest(mdoc){
twindow=dhtmlmodal.open('ebox', 'div', 'tdiv', 'Tidy.ws Info', 'center=1,width=480px,height=337px,resize=0,scrolling=0')
if (mdoc=="new") {
ntxt = "<strong>What's New:</strong><br><br>Tidt.ws now gives you the ability to check the statistics of any tidy URL simply by adding a plus sign (+) at the end. Example:<br><br>Change http://tidy.ws?bl9bBI to http://tidy.ws?bl9bBI+<br><br>This will take you to the stats page for that tidy URL.<br><br>Another new feature is adding the security check on the fly. Simply add an exclamation point (!) at the end of your tidy URL. Example: <br><br>Change http://tidy.ws?bl9bBI to http://tidy.ws?bl9bBI!";
document.getElementById("tres").innerHTML=ntxt;
}
else if (mdoc=="about") {
atxt = "<strong>About:</strong><br><br>tidy.ws was created as a free service to allow users to shorten, share, and track links (URLs). Reducing the URL length makes sharing much easier. Long web addresses that normally break and become useless can now be shortened and shared on blogs, social networks and emails.<br><br>Tidy.ws is a product of Morgan Enterprises. Programming, development and design by Steven Morgan. Copyright © Morgan Enterprises 2009. All rights reserved.";
document.getElementById("tres").innerHTML=atxt;
}
else if (mdoc=="dis") {
dtxt = "<strong>Disclaimer:</strong><br><br>tidy.ws services are provided without any warranty, assurances and liability. tidy.ws could disable any service without assigning any reason and URL at our discretion. If our services are used for spamming of any kind, authorities would be notified and a suitable action is taken.";
document.getElementById("tres").innerHTML=dtxt;
}
else if (mdoc=="sec") {
stxt = "<strong>Security Feature:</strong><br><br>Security is a concern for many people especially when you don't know where a redirect url might take you.  tidy.ws is also concerned which is why we have added a security check feature for your tidy links!  Check the 'add security check' when you enter a long url and it will add an intermediate step to the redirect process.  <br><br>When you click on the tidy link it will take you to a page that shows you where the final destination is and gives you the choice of whether or not to continue.  This gives the power to decide back in the hands of the web surfer.  At tidy.ws you can provide smaller, tidy links that don't break and feel confident that the final destination is somewhere you want to go.";
document.getElementById("tres").innerHTML=stxt;
}
}

/*function dosend(whichbutton){

	if (whichbutton=="yes") {
	//	elwindow.hide();
	dwindow=dhtmlmodal.open('exbox', 'div', 'donediv', 'Sent', 'center=1,width=480px,height=337px,resize=0,scrolling=0')

}
		elwindow.hide()
}*/

var xmlhttp

function DoSend()
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
  {
  alert ("Your browser does not support AJAX!");
  return;
  }
  var nstr=document.getElementById('ename').value;
  var estr=document.getElementById('email').value;
  var tstr=document.getElementById('comments').value;
	tstr=tstr.replace("&",";an")
	tstr=tstr.replace("=",";eq")	
	tstr=tstr.replace("+",";pl")
	tstr=tstr.replace("*",";st")
  var cstr=tstr.replace(/\n/g, '*');

var url="submit.asp";
url=url+"?n="+nstr+"&e="+estr+"&c="+cstr;
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("POST",url,true);
xmlhttp.send(null);
}

function stateChanged()
{
if (xmlhttp.readyState==4)
  {
  document.getElementById("res").innerHTML=xmlhttp.responseText;
  }
}

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
} 
