// JavaScript Document
function checkSuggest()
{
	ctl = getCtl('suggest');
	if(ctl.value.search(sth)==-1)
	{
		alert("Enter a valid url");	
		ctl.focus();
		return false;
	}
	
	if(ctl.value.search(sth)!=-1)
	{
	
		
		rt =  fastCheckURL('suggest');
		
		if(rt ==-1)
		{
			return false;
		}
		
	}


var element = document.getElementById('suggest');
var raw_url = element.value.toLowerCase();
if(raw_url !== "")
{
var http_index = raw_url.indexOf("http://");
var https_index = raw_url.indexOf("https://");

	if(https_index !== -1)
	{
		len = raw_url.length;
		if(len<9)
		{
			alert("Enter full URL");
			element.focus();
			return false;
		}
		
	}
	else if(http_index !== -1)
	{
		len = raw_url.length;
		if(len<8)
		{
			alert("Enter full URL");
			element.focus();
			return false;
		}
	}
}
	
	ctl = getCtl('ycoments');
	if(ctl.value.search(sth)==-1)
	{
		alert("Enter your comment");	
		ctl.focus();
		return false;
	}
	
}


function fastCheckURL(element_id){
var autohttp = false;
// true = enable auto prepend 'http://' function
// false = disable auto prepend 'http://' function

var element = document.getElementById(element_id);
var raw_url = element.value.toLowerCase();
if(raw_url !== "")
{
var http_index = raw_url.indexOf("http://");
var https_index = raw_url.indexOf("https://");

	if(http_index !== 0 && https_index !== 0)
	{
		if(autohttp)
		{
		
		var confirm_autohttp = confirm("Your URL is not begin with either 'http://' or 'https://'.\nDo you want to correct it into 'http://" + raw_url + "'?");
		
				if(confirm_autohttp)
				{
					element.value = "http://" + raw_url;
				}
		}
		else
		{
			alert("Warning: Enter full url with 'http://' or 'https://'.");
			return -1;
		}
	}
	
	
}

}

