// All scripts in this file require prototype
//       some Require scrip.ac.lious
//
// Copyright Alan Cole (Kal-El) 2008
//	   Encore CMS Js Lib
//
//  DO NOT STEAL, USE WITH CREDIT!

function randomString(len) {
	var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz";
	var string_length = len;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}

function randomnumString(len) {
	var chars = "0123456789";
	var string_length = len;
	var randomstring = '';
	for (var i=0; i<string_length; i++) {
		var rnum = Math.floor(Math.random() * chars.length);
		randomstring += chars.substring(rnum,rnum+1);
	}
	return randomstring;
}



function makeeditable(ele,idx,hash){
	new Ajax.InPlaceEditor($(ele), 'update.php?idx='+idx+'&hash='+hash, { rows:5 });
}


var isselected = "";

function sselect(ele){
	uploader.doit();
	alert(ele);
	var backcolor = 'fff';
	var restore = 'ff00cc';
	if(isselected == ele){
		$(ele).setStyle({backColor: restore});
		isselected = "";
	} else {
		$('buttons').descendants().each(function(s){
			s.setStyle({backColor: restore});
			$(ele).setStyle({backColor: backcolor});
			isselected = ele;
		});
	}
}

function copy2clipboard(form,field){
	if (window.clipboardData) {
		alert("copied");
		window.clipboardData.setData("Text",document.form.field.value);
	} else {
		alert('Sorry, your browser does not support this function. Please right-click in the textbox and select \'select all\' and then right click again and select \'copy\'.');
	}
}

function doit(idx){
	window.location = "switch-account_"+ $F(idx) +".html";
}

function replace(ele, cont){
	alert($(ele).innerHTML);
	$(ele).innerHTML = cont;
}

function switch2textbox(ele,name){
	alert(name);
	var t = "<input type='text' name='"+name+"' />";
	document.getElementById(ele).innerHTML = t;
}

function change(id){
	var changeto = document.getElementById(id).innerHTML;
	document.getElementById('right').innerHTML = changeto;				
}