String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}//trim
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}//ltrim
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}//rtrim		

function CheckForm()
{
/*	if(document.getElementById("Name").value.trim() == "")
	{
		alert("Please enter name");
		document.getElementById("Name").focus();
		return false;
	}
	if(document.getElementById("DobDate").value.trim() == "")
	{
		alert("Please select date");
		document.getElementById("DobDate").focus();
		return false;
	}
	if(document.getElementById("DobMon").value.trim() == "")
	{
		alert("Please select month");
		document.getElementById("DobMon").focus();
		return false;
	}
	if(document.getElementById("DobYear").value.trim() == "")
	{
		alert("Please select year");
		document.getElementById("DobYear").focus();
		return false;
	}
	if(document.getElementById("Email").value.trim() == "")
	{
		alert("Please enter email");
		document.getElementById("Email").focus();
		return false;
	}*/
	if(document.getElementById("Email").value.trim() != "")
	{
		if(emailCheck(document.getElementById("Email").value) == false)
		{
			alert("Please enter valid email");
			document.getElementById("Email").focus();
			return false;
		}
	}
/*	if(document.getElementById("Phone").value.trim() == "")
	{
		alert("Please enter phone");
		document.getElementById("Phone").focus();
		return false;
	}
	if(document.getElementById("Phone").value.trim() != "")
	{
		if(checknumber(document.getElementById("Phone").value) == false)
		{
			alert("Please enter valid phone");
			document.getElementById("Phone").focus();
			return false;
		}
	}
	if(document.getElementById("AltPhone").value.trim() != "")
	{
		if(checknumber(document.getElementById("AltPhone").value) == false)
		{
			alert("Please enter valid alt phone");
			document.getElementById("AltPhone").focus();
			return false;
		}
	}*/
	if(document.getElementById("UploadImage").value.trim() != "")
	{
		if(PhotoLimitAttach(document.getElementById("UploadImage").value) == false)
		{
			alert("Please upload valid image.");
			document.getElementById("UploadImage").focus();
			return false;
		}
	}
}

function UploadVideo()
{
	window.open("YtubeApi/demos/Zend/Gdata/YouTubeVideoApp/index.php","mywindow","location=1,status=1,scrollbars=1,width=700,height=500"); 		
}//UploadVideo

function UploadManualSubmission()
{
	window.open("PopManualSubmission.php","mywindow","location=1,status=1,scrollbars=1,width=700,height=500"); 		
}//UploadVideo


PhotoArray1 = new Array(".gif", ".jpg", ".jpeg", ".png",".GIF", ".JPG", ".PNG", ".JPEG", ".bmp", ".BMP");
	
function PhotoLimitAttach(file) 
{
	allowSubmit = false;
	if (!file) return;
	while (file.indexOf("\\") != -1)
	file = file.slice(file.indexOf("\\") + 1);
	ext = file.slice(file.indexOf(".")).toLowerCase();
	for (var i = 0; i < PhotoArray1.length; i++) 
	{
		if (PhotoArray1[i] == ext) 
		{ 
			allowSubmit = true; 
			break; 
		}//if
	}//for
	if (allowSubmit) 
	{
		return true;
	}//if
	else
	{
		return false;
    }//else	
}//LimitAttach


function checknumber(x)
{
	var anum=/(^\d+$)|(^\d+\.\d+$)/
	if (anum.test(x))
	testresult=true
	else{
	testresult=false
	}
	return (testresult)
}


function emailCheck(emailStr) 
{
	var emailPat=/^(.+)@(.+)$/
	var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
	var validChars="\[^\\s" + specialChars + "\]"
	var quotedUser="(\"[^\"]*\")"
	var ipDomainPat=/^\[(\d)\.(\d)\.(\d)\.(\d)\]$/
	var atom=validChars + '+'
	var word="(" + atom + "|" + quotedUser + ")"
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	
	
	var matchArray=emailStr.match(emailPat)
	if (matchArray==null) {
	        return false
	}
	var user=matchArray[1]
	var domain=matchArray[2]
	
	if (user.match(userPat)==null) {
	    return false
	}
	
	var IPArray=domain.match(ipDomainPat)
	if (IPArray!=null) {
	          for (var i=1;i<=4;i++) {
	            if (IPArray[i]>255) {
	                return false
	            }
	    }
	    return true
	}
	
	var domainArray=domain.match(domainPat)
	if (domainArray==null) {
	    return false
	}
	
	var atomPat=new RegExp(atom,"g")
	var domArr=domain.match(atomPat)
	var len=domArr.length
	if (domArr[domArr.length-1].length<2 ||
	    domArr[domArr.length-1].length>3) {
	   return false
	}

	if (len< 2) {
	   return false
	}
	return true;
}//emailCheck

function isValidURL(url) 
{
	var regEx = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;
	return regEx.test(url);
}
