function isValidURL(url)
{
	var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;
    if(RegExp.test(url)){
        return true;
    }else{
        return false;
    }
}

function isValidEmail(email, required) 
{
    if (required==undefined) {   // if not specified, assume it's required
        required=true;
    }
    if (email==null) {
        if (required) {
            return false;
        }
        return true;
    }
    if (email.length==0) {  
        if (required) {
            return false;
        }
        return true;
    }
    if (! allValidChars(email)) {  // check to make sure all characters are valid
        return false;
    }
    if (email.indexOf("@") < 1) { //  must contain @, and it must not be the first character
        return false;
    } else if (email.lastIndexOf(".") <= email.indexOf("@")) {  // last dot must be after the @
        return false;
    } else if (email.indexOf("@") == email.length) {  // @ must not be the last character
        return false;
    } else if (email.indexOf("..") >=0) { // two periods in a row is not valid
	return false;
    } else if (email.indexOf(".") == email.length) {  // . must not be the last character
	return false;
    }
    return true;
}

function allValidChars(email) 
{
  var parsed = true;
  var validchars = "abcdefghijklmnopqrstuvwxyz0123456789@.-_";
  for (var i=0; i < email.length; i++) {
    var letter = email.charAt(i).toLowerCase();
    if (validchars.indexOf(letter) != -1)
      continue;
    parsed = false;
    break;
  }
  return parsed;
}
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 SplNameChar(txt){
	if(txt.length == 0)
		return false;
	for(var i = 0;i < txt.length;i++){
		if(txt.charAt(i) == '@' || txt.charAt(i) == '#' 
			|| txt.charAt(i) == '!' || txt.charAt(i) == '$' 
			|| txt.charAt(i) == '%' || txt.charAt(i) == '&' 
			|| txt.charAt(i) == '^' || txt.charAt(i) == '*' 
			|| txt.charAt(i) == '~' || txt.charAt(i) == '-' 
			|| txt.charAt(i) == '+' || txt.charAt(i) == '|' 
			|| txt.charAt(i) == '?' || txt.charAt(i) == '<' 
			|| txt.charAt(i) == '>' || txt.charAt(i) == '/' 
			|| txt.charAt(i) == '[' || txt.charAt(i) == ']' 
			|| txt.charAt(i) == '(' || txt.charAt(i) == ')' 
			|| txt.charAt(i) == '`' || txt.charAt(i) == "," 
			|| txt.charAt(i) == ":" || txt.charAt(i) == ";" 
			|| txt.charAt(i) == "{" || txt.charAt(i) == '=' 
			|| txt.charAt(i) == "}" || txt.charAt(i) == '"'
			|| txt.charAt(i) == "1" || txt.charAt(i) == '2'
			|| txt.charAt(i) == "3" || txt.charAt(i) == '4'
			|| txt.charAt(i) == "5" || txt.charAt(i) == '6'
			|| txt.charAt(i) == "7" || txt.charAt(i) == '8'
			|| txt.charAt(i) == "9" || txt.charAt(i) == '0'
			|| txt.charAt(i) == '\\' )
			return true;
	}
	return false;
}//SplNameChar
function check_comment()
{
	frm = document.commentform;
	if(trim(frm.comment.value)=="")
	{
		var varcomment="Please Enter Your Comments.<br>";
    }
	else
	{
		var varcomment="";
	}
	strName = frm.author.value;
	if(trim(frm.author.value)=="")
	{
		var varauthor="Please Enter Name.<br>";
    }
	else if (SplNameChar(strName) == true)
	{
	    frm.author.value="";
		var varauthor="Special characters are not accepted in Name.<br>";
	}
	else
	{
		var varauthor="";
	}
    if(trim(frm.email.value)=="")
	{
		var varemail="Please Enter Email Address.<br>";
    }
	else
	{
		var varemail="";
	}
    if (!isValidEmail(trim(frm.email.value))) 
	{
        var varemail="Please Enter a valid email address.<br>";
    }
	else
	{
		var varemail="";
	}
	if(trim(frm.url.value)!="")
	{  
		if(!isValidURL(trim(frm.url.value)))
		{
			var varurl="Please Enter Valid WebSite";
		}
		else
		{
			var varurl="";
		}
	}
	else
	{
		var varurl="";
	}
	if(trim(frm.recaptcha_response_field.value)=="")
	{
		var varcapt="Please Enter the Human Verification code.<br>";
    }
	else
	{
		var varcapt="";
	}
	if((varcomment!="") || (varauthor!="") || (varemail!="") || (varurl!="") || (varcapt!=""))
	{
		showDialogComment('Error Message',varcomment+""+varauthor+""+varemail+""+varurl+""+varcapt,'comment');
		return false;
	}
	else
	{
		return true;
	}
}


function currentsweetuserclock()
{
	var now = new Date();
	var hours = now.getHours();
	var minutes = now.getMinutes();
	var seconds = now.getSeconds();
	var d = now.getDate();
	var m = now.getMonth()+1;
	//var y = now.getYear();
	var y = now.getFullYear();
	if (d < 10) d="0"+d;
	if (m < 10) m="0"+m;
	if (hours < 10) hours="0"+hours;
	if (minutes < 10) minutes="0"+minutes;
	if (seconds < 10) seconds="0"+seconds;
	timeValue=y+"-"+m+"-"+d+" "+hours+":"+minutes+":"+seconds
	document.frmcommentuser.commentclientdate.value = timeValue;	
}
function currentotheruserclock()
{
	var now = new Date();
	var hours = now.getHours();
	var minutes = now.getMinutes();
	var seconds = now.getSeconds();
	var d = now.getDate();
	var m = now.getMonth()+1;
	//var y = now.getYear();

	var y = now.getFullYear();
	if (d < 10) d="0"+d;
	if (m < 10) m="0"+m;
	if (hours < 10) hours="0"+hours;
	if (minutes < 10) minutes="0"+minutes;
	if (seconds < 10) seconds="0"+seconds;
	timeValue=y+"-"+m+"-"+d+" "+hours+":"+minutes+":"+seconds
	document.commentform.commentclientdate.value = timeValue;	
}

function currentonlycommentclock()
{
	var now = new Date();
	var hours = now.getHours();
	var minutes = now.getMinutes();
	var seconds = now.getSeconds();
	var d = now.getDate();
	var m = now.getMonth()+1;
	//var y = now.getYear();

	var y = now.getFullYear();
	if (d < 10) d="0"+d;
	if (m < 10) m="0"+m;
	if (hours < 10) hours="0"+hours;
	if (minutes < 10) minutes="0"+minutes;
	if (seconds < 10) seconds="0"+seconds;
	timeValue=y+"-"+m+"-"+d+" "+hours+":"+minutes+":"+seconds
	document.frmonlycomment.commentclientdate.value = timeValue;	
}
function currentreplyclock(fr)
{
	var now = new Date();
	var hours = now.getHours();
	var minutes = now.getMinutes();
	var seconds = now.getSeconds();
	var d = now.getDate();
	var m = now.getMonth()+1;
	//var y = now.getYear();

	var y = now.getFullYear();
	if (d < 10) d="0"+d;
	if (m < 10) m="0"+m;
	if (hours < 10) hours="0"+hours;
	if (minutes < 10) minutes="0"+minutes;
	if (seconds < 10) seconds="0"+seconds;
	timeValue=y+"-"+m+"-"+d+" "+hours+":"+minutes+":"+seconds	
	fr.replydate.value = timeValue;
}

function Existing_User()
{
	frm = document.frmcommentuser;
	if(trim(frm.comment.value)=="")
	{
		var varcomment="Please Enter Your Comments.<br>";
    }
	else
	{
		var varcomment="";
	}  
	if((trim(frm.username.value)=="") && (trim(frm.password.value)==""))
	{
		var varusername="Please Enter Your User Name / Password.<br>";
    }
	else if(trim(frm.username.value)=="")
	{
		var varusername="Please Enter Your User Name.<br>";
    }
    else if(trim(frm.password.value)=="")
	{
		var varusername="Please Enter Your Password.<br>";
    }
	else
	{
		var varusername="";
	}
	/*if(trim(frm.capt.value)=="")
	{
		var varcapt="Please Enter the Human Verification code.<br>";
    }
	else
	{
		var varcapt="";
	}*/
	if((varcomment!="") || (varusername!=""))
	{
		showDialogComment('Error Message',varcomment+""+varusername,'comment');
		return false;
	}
	else
	{
		return true;
	}	
}
function only_comment(frm)
{
	frm = document.frmonlycomment;
	if(trim(frm.comment.value)=="")
	{
		var varcomment="Please Enter Your Comments.<br>";
    }
	else
	{
		var varcomment="";
	}
	if(varcomment!="")
	{
		showDialogComment('Error Message',varcomment,'comment');
		return false;
	}
	else
	{
		return true;
	}
}
function textCounter(field,cntfield,maxlimit) 
{
	if (field.value.length > maxlimit) // if too long...trim it!
		field.value = field.value.substring(0, maxlimit);
	else
		cntfield.value = maxlimit - field.value.length;
}
function currentclock()
{
	var now = new Date();	
	var hours = now.getHours();
	var minutes = now.getMinutes();
	var seconds = now.getSeconds();
	var d = now.getDate();
	var m = now.getMonth()+1;
	var y = now.getFullYear();
	if (d < 10) d="0"+d;
	if (m < 10) m="0"+m;
	if (hours < 10) hours="0"+hours;
	if (minutes < 10) minutes="0"+minutes;
	if (seconds < 10) seconds="0"+seconds;
	DatetimeValue=y+"-"+m+"-"+d+" "+hours+":"+minutes+":"+seconds
	document.frmGossipad.createdate.value = DatetimeValue;
}
function showElement(layer)
{
	var myLayer = document.getElementById(layer);
	if(myLayer.style.display=="none")
	{
		myLayer.style.display="block";
		myLayer.backgroundPosition="top";
	}
	else
	{
		myLayer.style.display="none";
	}
}
function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}

function ContactUs()
{
	frm = document.frmISOCContact;	
	strName = frm.txtName.value;
	if(trim(frm.txtName.value)=="")
	{
		var varName="Please Enter Name.<br>";
    }
	else if (SplNameChar(strName) == true)
	{
	    frm.txtName.value="";
		var varName="Special characters are not accepted in Name.<br>";
	}
	else
	{
		var varName="";
	}
    if(trim(frm.txtEmail.value)=="")
	{
		var varEmail="Please Enter Email Address.<br>";
    }
	else
	{
		var varEmail="";
	}
    if (!isValidEmail(trim(frm.txtEmail.value))) 
	{
        var varEmail="Please Enter a valid email address.<br>";
    }
	else
	{
		var varEmail="";
	}
	if(trim(frm.txtSubject.value)=="")
	{
		var varSubject="Please Enter Your Subject.<br>";
    }
	else
	{
		var varSubject="";
	}
	if(trim(frm.txtMessage.value)=="")
	{
		var varMessage="Please Enter Your Message.<br>";
    }
	else
	{
		var varMessage="";
	}
	if(trim(frm.recaptcha_response_field.value)=="")
	{
		var varCapt="Please Enter the Human Verification code.<br>";
    }
	else
	{
		var varCapt="";
	}
	if((varName!="") || (varEmail!="") || (varSubject!="") || (varMessage!="") || (varCapt!=""))
	{
		showDialogContactUs('Error Message',varName+""+varEmail+""+varSubject+""+varMessage+""+varCapt,'comment');
		return false;
	}
	else
	{
		return true;
	}
}
function AddMemberProfile()
{
	frm = document.frmISOCaddmember;	
	if(trim(frm.txtisocimage.value)=="")
	{
		var varImage="Please Upload Your Photo.<br>";
    }
	else
	{
		var varImage="";
	}
	if(trim(frm.txtMessage.value)=="")
	{
		var varMessage="Please Enter Short Note about your self.<br>";
    }
	else
	{
		var varMessage="";
	}
	if((varImage!="") || (varMessage!=""))
	{
		showDialogContactUs('Error Message',varImage+""+varMessage,'comment');
		return false;
	}
	else
	{
		return true;
	}
}