function error(element, text)
{
    document.getElementById(element).innerHTML = text;
}

function formControl(element, text)
{
    if(document.mainform.title.value == "")
    { 
        error(element, text); // Uyarıyı göster.
        return false; // Form gönderilmez.
    }
    else
    {        
        return true; // Form gönderilir.
    }
}

function delete_confirm(id)
{
 var where_to= confirm("Silmek istediginizden emin misiniz?");
 if (where_to== true)
 {
   window.location=id;
 }
}

function publish_confirm(id, text)
{
 var where_to= confirm(text);
 if (where_to== true)
 {
   window.location=id;
 }
}

function logout_confirm(id)
{
 var where_to= confirm("Çıkış yapmak istediginizden emin misiniz?");
 if (where_to== true)
 {
   window.location=id;
 }
}

function replaceChars(entry) 
{
	out = "http://";
	add = "";
	temp = "" + entry;

	while (temp.indexOf(out)>-1) 
	{
		pos= temp.indexOf(out);
		temp = "" + (temp.substring(0, pos) + add + 
		temp.substring((pos + out.length), temp.length));
	}
	document.mainform.url.value = temp;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0

	  window.open(theURL,winName,features);

} 


var keylist="1234567890abcdefghijklmnopqrstuvwxyz"
var temp=''

function generatePassword(length){
	temp=''
	for (i=0;i<length;i++){
		temp+=keylist.charAt(Math.floor(Math.random()*keylist.length))
	}
	document.mainform.title.value=temp
}

function table(tablename, type) {
	// Initialise the first table (as before)
	$(tablename).tableDnD();
	$(tablename).tableDnD({
		onDrop: function(table, row)
		{
			$.post('ajaxTableSorter.php', {'mode': 'reorder', 'ids': $.tableDnD.serialize(), 'table': type}
			);
		}
	});	
}

