//isValidImage
function isValidImage(imagename)
{
	imagefile_value = imagename;
	var checkimg = imagefile_value.toLowerCase();
	if (!checkimg.match(/(\.jpg|\.gif|\.png|\.JPG|\.GIF|\.PNG|\.jpeg|\.JPEG)$/))
	{
		return false;
	}else{
		return true;
	}
}

//isValidVideo
function isValidVideo(videoname)
{
	imagefile_value = videoname;
	var checkimg = imagefile_value.toLowerCase();
	if (!checkimg.match(/(\.flv|\.FLV)$/))
	{
		return false;
	}else{
		return true;
	}
}

// Url Validatin check
function isValidUrl(userUrl)
{
	var regUrl = /^(((ht|f){1}(tp:[/][/]){1})|((www.){1}))[-a-zA-Z0-9@:%_\+.~#?&//=]+$/;
	if(regUrl.test(userUrl) == false)
	{
		return false;
	}else{
		return true;
	}
}

/*check email formate*/
function checkEmail(str)
{
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		  // alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   //alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   // alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   // alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   // alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    //alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	
}


//creating xml object for ajax
function GetXmlHttpObject() {
	var xmlHttp=null;
        try {
		xmlHttp=new XMLHttpRequest();
	}
        catch (e) {
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
        return xmlHttp;
}
/*Member login validation function*/
function checkLogin(frm)
{
	//name
	if(frm.ausername.value.trim()=="")
	{
		document.getElementById("checkLogin1").innerHTML = "Please enter the username";
		frm.ausername.focus();
	    return false;
	}
	// Password
	if(frm.apassword.value.trim()=="")
	{
		document.getElementById("checkLogin2").innerHTML = "Please enter the password";
		frm.apassword.focus();
	    return false;
	}
	 return true;
}

/*Show div*/
function showsDiv(boxid)
{
   document.getElementById(boxid).style.display="block";
}
/*Hide div*/
function hidesDiv(boxid)
{
   document.getElementById(boxid).style.display="none";
}

/////////////////////////////////////

function remove_name(val,frm2)
{	

    if(val=='name'){
	     document.frm2.name.value = '';
	}
}
function back_name(val,frm2)
{
    if(val==''){
	     document.frm2.name.value = 'name';
	}
}
/////////////////////////////////////
function remove_email(val,frm2)
{
    if(val=='email address'){
	     document.frm2.email.value = '';
	}
}
function back_email(val,frm2)
{
    if(val==''){
	     document.frm2.email.value = 'email address';
	}
}

/////////////////////////////////

/*Member login validation function*/
function checkHeaderPro(frm)
{
	//name
	if(frm.name.value.trim()=="name")
	{
		document.getElementById("err1").innerHTML = "Please enter the name";
		frm.name.focus();
	    return false;
	}
	if(frm.name.value.trim()=="")
	{
		document.getElementById("err1").innerHTML = "Please enter the name";
		frm.name.focus();
	    return false;
	}
	// email
	if(frm.email.value.trim()=="email address")
	{
		document.getElementById("err1").innerHTML = "Please enter the email";
		frm.email.focus();
	    return false;
	}
	if(frm.email.value.trim()=="")
	{
		document.getElementById("err1").innerHTML = "Please enter the email";
		frm.email.focus();
	    return false;
	}
	if(!checkEmail(frm.email.value)) 
	{
		document.getElementById("err1").innerHTML = "Please enter valid email ";
		frm.email.focus();
	   return false;
	}
	 return true;
}

/*Member login validation function*/
function checkFooterPro(frm)
{
	//name
	if(frm.name.value.trim()=="name")
	{
		document.getElementById("errorFooter1").innerHTML = "Please enter the name";
		frm.name.focus();
	    return false;
	}
	if(frm.name.value.trim()=="")
	{
		document.getElementById("errorFooter1").innerHTML = "Please enter the name";
		frm.name.focus();
	    return false;
	}
	// email
	if(frm.email.value.trim()=="email address")
	{
		document.getElementById("errorFooter1").innerHTML = "Please enter the email";
		frm.email.focus();
	    return false;
	}
	if(frm.email.value.trim()=="")
	{
		document.getElementById("errorFooter1").innerHTML = "Please enter the email";
		frm.email.focus();
	    return false;
	}
	if(!checkEmail(frm.email.value)) 
	{
		document.getElementById("errorFooter1").innerHTML = "Please enter valid email ";
		frm.email.focus();
	   return false;
	}
	 return true;
}

