
  ////////////////////////////////////////////////////////////////////////////
 //                     Validation Functions                               //
////////////////////////////////////////////////////////////////////////////

function CheckName(sValue)
{

	for (var i=0;i<sValue.length;i++)
	{
		var ch = sValue.substring(i, i + 1);
		if( (ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch) && (ch!=" ") && (ch!="'") && (ch!=".") )
		{
			return false;
		}
	}
	return true;
}

function CheckProdName(sValue)
{

	for (var i=0;i<sValue.length;i++)
	{
		var ch = sValue.substring(i, i + 1);
		if( (ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch) && (ch!=" ") && (ch!="'") && (ch!=".") && (ch < "0" || "9" < ch) )
		{
			return false;
		}
	}
	return true;
}
function CheckUserName(sValue)
{
	for (var i=0;i<sValue.length;i++)
	{
		var ch = sValue.substring(i, i + 1);
		if( (ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch) &&
            (ch < "0" || "9" < ch) && (ch!="-") && (ch!="_") && (ch!=".") )
		{
			return false;
		}
	}
	return true;
}

function CheckPassword(sValue)
{
	for (var i=0;i<sValue.length;i++)
	{
		var ch = sValue.substring(i, i + 1);
		if( (ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch) && (ch < "0" || "9" < ch) )
		{
			return false;
		}
	}
	return true;
}

function CheckZipCode(sValue)
{
	for (var i=0;i<sValue.length;i++)
	{
		var ch = sValue.substring(i, i + 1);
		if( (ch < "0" || "9" < ch) )
		{
			return false;
		}
	}
	return true;
}
function CheckZipCode1(sValue)
{
	for (var i=0;i<sValue.length;i++)
	{
		var ch = sValue.substring(i, i + 1);
		if( (ch < "0" || "9" < ch) && (ch!=" ")&& (ch < "A" || "Z" < ch) && (ch < "a" || "z" < ch) )
		{
			return false;
		}
	}
	return true;
}
function CheckPhone(sValue)
{
	for (var i=0;i<sValue.length;i++)
	{
		var ch = sValue.substring(i, i + 1);
		if( (ch < "0" || "9" < ch) && (ch!="-")&& (ch!=" ")&& (ch!="(")&& (ch!=")"))
		{
			return false;
		}
	}
	return true;
}

function CheckState(sValue)
{
	
    for (var i = 0; i < sValue.length; i++)
        {
        var ch = sValue.substring(i, i + 1);
        if (((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch) && (ch!=" ") ))
            {                             
                return false;
            }
        }
        
        return true;
    }


function trim(sVal)
{
	return sVal.replace( /(^\s*)|(\s*$)/g, '' ) ;
}



function CheckCity(sValue)
    {
    var i=0;
    var ch="";
 
    for (var i = 0; i < sValue.length; i++)
        {
        var ch = sValue.substring(i, i + 1);
        if (((ch < "a" || "z" < ch) && (ch < "A" || "Z" < ch) && (ch!=" ") ))
            {                             
                return false;
            }
        }
        
        return true;
    }

//----------Deepika  start---------------------
function vSiteName(sValue) 
{
var result = true;
var string = sValue.length;
for (var i = 0; i < string; i++) 
{
    var ch = sValue.substring(i, i + 1);
    if((ch== "+") || (ch=="/")  || (ch=="?")  || (ch == "%" )  || (ch == "#" ) || (ch == "." ) || (ch == " " ) || (ch == "&" ) || (ch == "," ) || (ch == "!" ) || (ch == "<" ) || (ch == ">" ))
    {
    return false;
    }
}


} 

function CheckTollFree(sValue)
{
	for (var i=0;i<sValue.length;i++)
	{
		var ch = sValue.substring(i, i + 1);
		if( (ch < "0" || "9" < ch)&&(ch!="-") )
		{
			return false;
		}
	}
	return true;
}
function CheckFax(sValue)
{
	for (var i=0;i<sValue.length;i++)
	{
		var ch = sValue.substring(i, i + 1);
		if( (ch < "0" || "9" < ch))
		{
			return false;
		}
	}
	return true;
}
//----------Deepika   End---------------------

function CheckCreditCardNo(sValue)
{
	for (var i=0;i<sValue.length;i++)
	{
		var ch = sValue.substring(i, i + 1);
		if( (ch < "0" || "9" < ch) )
		{
			return false;
		}
	}
	return true;
}




//    String.prototype.isDate = function() { return isNaN(Date.parse(this)); }
//    function checkDate(date)
//    {
//        var d;
//        if(Date.parse(date) < (d = new Date()).getTime() || !date.isDate() || (date == d && d.getHours() < 11)) return false;
//        return true;
//    }

function CheckCardNumber(sValue)
{
	for (var i=0;i<sValue.length;i++)
	{
		var ch = sValue.substring(i, i + 1);
		if( (ch < "0" || "9" < ch))
		{
			return false;
		}
	}
	return true;
}

function CheckCVV2(sValue)
{
	for (var i=0;i<sValue.length;i++)
	{
		var ch = sValue.substring(i, i + 1);
		if( (ch < "0" || "9" < ch))
		{
			return false;
		}
	}
	return true;
}
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 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;
}






  ////////////////////////////////////////////////////////////////////////////
 //                     Popup related functions                            //
////////////////////////////////////////////////////////////////////////////


var _objDiv;
var _TimerID;
var _top;

function ShowPopup(DivID)
{
	var nHeight = document.getElementById('tblMain').scrollHeight;

//alert(nHeight);	

	//document.getElementById('divdisablewind').style.height = nHeight + "px";
	//document.getElementById('divdisablewind').style.display = "block";


	_objDiv = document.getElementById(DivID);
	var nWidth = parseInt(_objDiv.style.width) / 2;
	
	//alert((parseInt(_objDiv.style.height) / 2));
	
	_top = 310 - (parseInt(_objDiv.style.height) / 2);
	if (isNaN(_top)) _top = 200;
	
	if (isNaN(nWidth)) nWidth = 200;
	
		
	_objDiv.style.left = (screen.width / 2)- nWidth + "px";
	_objDiv.style.display = "block";

	//_TimerID = setInterval(function(){SetTop()}, 20);----This is used to scroll popup also
	SetTop();//'----This does not scroll popup
}

function SetTop()
{
	//_objDiv.style.top = _top + "px";
	_objDiv.style.top = _top + GetEdge() + "px";
}

function GetEdge()
{
	var edge;
		
    edge = window.pageYOffset? window.pageYOffset : truebody().scrollTop? truebody().scrollTop : 0;
	return edge;
}

function truebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function HidePopup()
{
	try
	{
		window.clearInterval(_TimerID);
		//document.getElementById('divdisablewind').style.display = "none";
		_objDiv.style.display = "None";
	}
	catch(e)
	{
	}
}











// Extends the Array object, creating a "addItem" method on it.
Array.prototype.addItem = function( item )
{
	var i = this.length ;
	this[ i ] = item ;
	return i ;
}

Array.prototype.indexOf = function( value )
{
	for ( var i = 0 ; i < this.length ; i++ )
	{
		if ( this[i] == value )
			return i ;
	}
	return -1 ;
}

String.prototype.startsWith = function( value )
{
	return ( this.substr( 0, value.length ) == value ) ;
}

// Extends the String object, creating a "endsWith" method on it.
String.prototype.endsWith = function( value )
{
	var L1 = this.length ;
	var L2 = value.length ;
	
	if ( L2 > L1 )
		return false ;
		
	return ( L2 == 0 || this.substr( L1 - L2, L2 ) == value ) ;
}

String.prototype.remove = function( start, length )
{
	var s = '' ;
	
	if ( start > 0 )
		s = this.substring( 0, start ) ;
	
	if ( start + length < this.length )
		s += this.substring( start + length , this.length ) ;
		
	return s ;
}

String.prototype.trim = function()
{
	return this.replace( /(^\s*)|(\s*$)/g, '' ) ;
}

String.prototype.ltrim = function()
{
	return this.replace( /^\s*/g, '' ) ;
}

String.prototype.rtrim = function()
{
	return this.replace( /\s*$/g, '' ) ;
}

String.prototype.replaceNewLineChars = function( replacement )
{
	return this.replace( /\n/g, replacement ) ;
}


function ShowHideDv(divname)
{
    try
    {
        var divBox;
        divBox=document.getElementById(divname);
        if(divBox.style.display=="none")
        {
            if(divname == "ctl00_ContentPlaceHolder1_dvPrice") SetMargin();
            divBox.style.display="Block";
        }
        else
        {
            divBox.style.display="none";
        }
    }
    catch(e)
    {
        alert(e.message);
        return false;
    }
    return false;
}

function ShowHideDvAP(divname,type)
{

   if (type=="true")
    {
    document.getElementById("hAP").innerHTML="Accept Payment"
    }
    else
    {
        document.getElementById("hAP").innerHTML="Change Payment Status"

    }
  

    try
    {
        var divBox;
        divBox=document.getElementById(divname);
        if(divBox.style.display=="none")
        {
            if(divname == "ctl00_ContentPlaceHolder1_dvPrice") SetMargin();
            divBox.style.display="Block";
        }
        else
        {
            divBox.style.display="none";
        }
    }
    catch(e)
    {
        alert(e.message);
        return false;
    }
    return false;
}