﻿// JScript File

function ValidateCorpoInfoline()
{
    if(document.getElementById("txtCompName").value.trim()=="" )
	{
		 alert("Enter Company Name!");
		 document.getElementById("txtCompName").focus();
		 return false;
	}
	return true;
}

function function1()
    {
        if (navigator.appName == "Microsoft Internet Explorer")
        {
            document.all.MarqueeId.direction = "left";
        }
        else 
        {
            document.getElementById('MarqueeId').direction= "left";
        }
    }
    function function2()
    {
        if (navigator.appName == "Microsoft Internet Explorer")
        {
            document.all.MarqueeId.direction = "right";
        }
        else 
        {
           document.getElementById('MarqueeId').direction= "right";
        }
    }

function DownloadValidity2(vFID)
{
   
    var vDisp = document.getElementById("Top1_divLogin");
    if(vDisp.style.display=="none")
    {
        return true
    }
    else
    {
        alert("Please Login")
        document.getElementById("Top1_txtUserName").focus();
        return false;
    }
    return false;
}

function DownloadValidity(vFID)
{
   
    var vDisp = document.getElementById("Top1_divLogin");
    if(vDisp.style.display=="none")
    {
        if (vFID!=0)
            window.location.href= "../Reports/DownloadReport.aspx?FID="+vFID
        else
            return true;
    }
    else
    {
        alert("Please Login")
        document.getElementById("Top1_txtUserName").focus();
        return false;
    }
    return false;
}


function DownloadValidity1(vFileName)
{
    var vDisp = document.getElementById("Top1_divLogin");
    if(vDisp.style.display=="none")
    {
        if (vFileName!=0)
            window.location.href= "../Reports/DownloadReport.aspx?vFID="+vFileName
        else
            return true;
    }
    else
    {
        alert("Please Login")
        document.getElementById("Top1_txtUserName").focus();
        return false;
    }
    return false;
}

function DownloadValidity3(vhrefName)
{
    var vDisp = document.getElementById("Top1_divLogin");
    if(vDisp.style.display=="none")
    {
        if (vhrefName!=0)
            window.location.href= vhrefName
        else
            return true;
    }
    else
    {
        alert("Please Login")
        document.getElementById("Top1_txtUserName").focus();
        return false;
    }
    return false;
}


String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}

function LoginValidate(UserName,Passward)
{
    //alert('Hi')
	if(document.getElementById(UserName).value.trim()=="" || document.getElementById(UserName).value.trim()==null)
	{
		 alert("Enter User Name!");
		 document.getElementById(UserName).focus();
		 return false;
	}
	else if(document.getElementById(Passward).value.trim()=="" || document.getElementById(Passward).value.trim()==null)
	{
		alert("Enter Password!");
		document.getElementById(Passward).focus();
		return false;
	}
	return true;	
}

function HomeValidate()
{
    if(document.getElementById("txtUserName").value.trim()=="" )
	{
		 alert("Enter User Name!");
		 document.getElementById("txtUserName").focus();
		 return false;
	}
	else if(document.getElementById("txtPassword").value.trim()=="" )
	{
		alert("Enter Password!");
		document.getElementById("txtPassword").focus();
		return false;
	}
	return true;
}
function CareerValidation()
{
    if(document.getElementById("UcCareerRequest1_txtName").value.trim()=="")
	{
		 alert("Enter Name!");
		 document.getElementById("UcCareerRequest1_txtName").focus();
		 return false;
	}
	else if(document.getElementById("UcCareerRequest1_txtTelephone").value.trim()=="")
	{
		 alert("Enter Contact No.!");
		 document.getElementById("UcCareerRequest1_txtTelephone").focus();
		 return false;
	}
	else if(document.getElementById("UcCareerRequest1_txtEmailId").value.trim()=="")
	{
		 alert("Enter Email Id!");
		 document.getElementById("UcCareerRequest1_txtEmailId").focus();
		 return false;
	}
	else if(document.getElementById("UcCareerRequest1_drpQualification").value.trim()=="")
	{
		 alert("Select Highest Qualification.!");
		 document.getElementById("UcCareerRequest1_drpQualification").focus();
		 return false;
	}
	
	if (document.getElementById("UcCareerRequest1_txtTelephone").value.trim() !="")
	{
	    if (checknumber(document.getElementById("UcCareerRequest1_txtTelephone").value.trim()))
	    {
	        alert("Contact No. should be numeric!");
	        document.getElementById("UcCareerRequest1_txtTelephone").focus();
	        return false;
	    }
	}
	
	if(echeck(document.getElementById("UcCareerRequest1_txtEmailId").value.trim()))
	{
	    return true;
	}
	else
	{
	    document.getElementById("UcCareerRequest1_txtEmailId").focus();
	    return false;
	}
	
	return true;
}

function FeedbackValidation()
{
    if(document.getElementById("UcFeedback1_txtName").value.trim()=="")
	{
		 alert("Enter Name!");
		 document.getElementById("UcFeedback1_txtName").focus();
		 return false;
	}
	else if(document.getElementById("UcFeedback1_txtContact").value.trim()=="")
	{
		 alert("Enter Contact No.!");
		 document.getElementById("UcFeedback1_txtContact").focus();
		 return false;
	}
	else if(document.getElementById("UcFeedback1_txtEmail").value.trim()=="")
	{
		 alert("Enter Email Id!");
		 document.getElementById("UcFeedback1_txtEmail").focus();
		 return false;
	}
	
	if (document.getElementById("UcFeedback1_txtContact").value.trim() !="")
	{
	    if (checknumber(document.getElementById("UcFeedback1_txtContact").value.trim()))
	    {
	        alert("Contact No. should be numeric!");
	        document.getElementById("UcFeedback1_txtContact").focus();
	        return false;
	    }
	}
	
	if(echeck(document.getElementById("UcFeedback1_txtEmail").value.trim()))
	{
	    return true;
	}
	else
	{
	    document.getElementById("UcFeedback1_txtEmail").focus();
	    return false;
	}
	
	return true;
}

function EnquiryValidation()
{
    if(document.getElementById("UcEnquiry1_txtName").value.trim()=="")
	{
		 alert("Enter Name!");
		 document.getElementById("UcEnquiry1_txtName").focus();
		 return false;
	}
	else if(document.getElementById("UcEnquiry1_txtContact").value.trim()=="")
	{
		 alert("Enter Contact No.!");
		 document.getElementById("UcEnquiry1_txtContact").focus();
		 return false;
	}
	else if(document.getElementById("UcEnquiry1_txtEmail").value.trim()=="")
	{
		 alert("Enter Email Id!");
		 document.getElementById("UcEnquiry1_txtEmail").focus();
		 return false;
	}
	else if(document.getElementById("UcEnquiry1_drpEnquiryAbout").value.trim()=="")
	{
		 alert("Select Enqury About.!");
		 document.getElementById("UcEnquiry1_drpEnquiryAbout").focus();
		 return false;
	}
	
	if (document.getElementById("UcEnquiry1_txtContact").value.trim() !="")
	{
	    if (checknumber(document.getElementById("UcEnquiry1_txtContact").value.trim()))
	    {
	        alert("Contact No. should be numeric!");
	        document.getElementById("UcEnquiry1_txtContact").focus();
	        return false;
	    }
	}
	
	if(echeck(document.getElementById("UcEnquiry1_txtEmail").value.trim()))
	{
	    return true;
	}
	else
	{
	    document.getElementById("UcEnquiry1_txtEmail").focus();
	    return false;
	}
	
	return true;
}


//*****End Of Menu***************************************

function  ShowGraphDiv(vDivId)
{
	HideAll();
	obj = document.getElementById(vDivId);
	obj.style.display = "block";
}

function HideAll()
{
	var i;
	var divs = document.getElementById("MyDiv").getElementsByTagName("div");
	for(i = 0; i < divs.length; i++)
	{
	    divs[i].style.display = "none";
	}
}

//==============================================================================================



function checknumber(vSTR)
{
    var anum=/(^\d+$)|(^\d+\.\d+$)/
    if (anum.test(vSTR))
        testresult=false;
    else
    {
        testresult=true;
    }
        return testresult;
}

function echeck(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 Email ID!")
		   return false;
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		{
		   alert("Invalid Email ID!")
		   return false;
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr-1)
		{
		    alert("Invalid Email ID!")
		    return false;
		}
    	if (str.indexOf(at,(lat+1))!=-1)
		{
		   alert("Invalid Email ID!")
		   return false;
		}

		if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		{
		   alert("Invalid Email ID!")
		   return false;
		}

		if (str.indexOf(dot,(lat+2))==-1)
		{
		   alert("Invalid Email ID!")
		   return false;
		}
		if (str.indexOf(" ")!=-1)
		{
		   alert("Invalid Email ID!")
		   return false;
		}
		return true;
}
