$(document).ready(function () { 
	$('.confirm').click(function() { 
		return confirm("Are you sure?"); 
	}); 
	
	$('#search').keydown(function (e) {
		if (e.keyCode == 13) { $('#search_button').click(); return false; }
	});
	
	var bFound = false;
	for (f=0; f < document.forms.length; f++)
	{
		for(i=0; i < document.forms[f].length; i++)
		{
			if (document.forms[f][i].disabled == false && document.forms[f][i].type == "text" && document.forms[f][i].id != "snap_preview_anywhere_box")
			{
				setTimeout("try_focus('" + document.forms[f][i].id + "')",0);
				bFound = true;
			}
			if (bFound == true)	break;
		}
		if (bFound == true)	break;
	}
});

function try_focus(e) {
	try {
		document.getElementById(e).focus();
	}
	catch(err) {
	}
}

function copy_to_clipboard(e, id) {
	$.post("Ajax.aspx",{ 
		action: "clipboard", 
		action2: "copy",
		id: id
	},function(xml){
		if (xml.documentElement.attributes[0].value == "0")
			$(e).fadeOut("normal", function () { $(e).parent().html('<span class=g style="position: absolute; right: 0px;">(copied)</span>'); });
		else
			alert($('response',xml).text());
	});	
}

function remove_from_clipboard(e, id) {
	$.post("Ajax.aspx",{ 
		action: "clipboard", 
		action2: "remove",
		id: id
	},function(xml){
		if (xml.documentElement.attributes[0].value == "0")
			$(e).fadeOut("normal");
		else
			alert($('response',xml).text());
	});	
}

function paste_from_clipboard(e, id) {
	$.post("Ajax.aspx",{ 
		action: "clipboard", 
		action2: "paste",
		id: id
	},function(xml){
		if (xml.documentElement.attributes[0].value == "0")
			$(e).fadeOut("normal");
		else
			alert($('response',xml).text());
	});	
}

function clone_from_clipboard(e, id) {
	$.post("Ajax.aspx",{ 
		action: "clipboard", 
		action2: "clone",
		id: id
	},function(xml){
		if (xml.documentElement.attributes[0].value == "0")
			$(e).fadeOut("normal");
		else
			alert($('response',xml).text());
	});	
}