var url = document.getElementById('siteurl').value;

$(function()
{
  Date.format = 'yyyy-mm-dd';
	$('.date-pick').datePicker({startDate:'1996-01-01'});
});

//this function removes unwanted characters on typing
function removeSpecialChars(id)
{
	var field = document.getElementById(id);
	var maintainplus = '';
	var numval = field.value;
	if ( numval.charAt(0)=='+' ){ var maintainplus = '';}
	curphonevar = numval.replace(/[\\!\"£@$%^&*+={};:'()#~,¦\/<>?|`¬\]\[]/g,'');
	field.value = maintainplus + curphonevar;
	var maintainplus = '';
	field.focus;
}



//TRIM FUNCTION

function trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
    chars = chars || "\\s";
    return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}


//=======================================================


function checkAvailability(username, div)
{
	$.get(url+"users/check_username_availability/" + username, function(data){
			$('#' + div).html(data);
		});
}


function highlight(id)
{
	//document.getElementById(id).style.background = '#e1ded1';
	document.getElementById(id).style.border= '1px solid #9d9a8d';
}

function remove_highlight(id)
{
	//document.getElementById(id).style.background = 'none';
	document.getElementById(id).style.border= '1px solid #e9e0bf';
}



function highlight_list(id)
{
	document.getElementById(id).style.background = '#e7daab';
	//document.getElementById(id).style.border= '1px solid #9d9a8d';
}

function remove_highlight_list(id)
{
	document.getElementById(id).style.background = 'none';
	//document.getElementById(id).style.border= '1px solid #e9e0bf';
}


function progress_div_show()
{
	document.getElementById('progress_div').style.display = 'block';
}
