﻿// JScript File


var color_onmouseover="FFFF00" 
var color_onmouseout
function ss(w){window.status=w}
function showcursor(check,Loc) 
{ 
if(check=="text") 
{ color_onmouseout=Loc.style.backgroundColor
 Loc.style.backgroundColor=color_onmouseover 
} 
}

function showout(check,Loc) 
{ 
if(check=="text") 
{  Loc.style.backgroundColor=color_onmouseout
} 
}



function checkAlphaNum(z)
{
	var k,i,y
	
	regChar=/[A-Za-z0-9]|[\s]/
	
	k	=	z.value
	y	=	k.length

	if(k!="")
	{
		for(i=0;i<y;i++)
		{
			if(!regChar.test(k.charAt(i)))
			{ 
				alert("Special Characters are not allowed");
				z.focus();
				z.value=""
				return false
			}
		}
	}
}



function checkfunction(fieldthis,field) 
{
	if (fieldthis == true) 
		{
			for (i = 0; i < field.length; i++)
				{
				
				if(field[i].style.visibility!="hidden")
					field[i].checked = true;
				}
		}
		else
			 {
				for (i = 0; i < field.length; i++) 
					{
						field[i].checked = false;
					 }
			 }
}





function maxlengthcheck(FormName,FieldName,Length)
	{
		 var Fieldval;
		 Fieldval = document[FormName][FieldName].value;
		 if( (Fieldval).length > Length )
		 {
//			   alert(document[FormName][FieldName].name+" Field Length Exceeds Max Allowed ("+Length+")");
			   document[FormName][FieldName].value = (document[FormName][FieldName].value).substring(0,Length-2);
			   return(0);
		 }
		 	else {return(1);}
	}


function CheckNull(Form,Field)
{ 
  var Fieldval,i,Fieldlength; 
  Fieldval = document[Form][Field].value;
  Fieldlength=(document[Form][Field]).value.length;
  for (i=0; i < Fieldlength; i++)
  {
    
    if ((document[Form][Field].value).charAt(i) == " ") 
		{continue;}
	else
        {break;}
  }
  
  if ( Fieldlength == i)
  { 
    alert("Please Enter "+document[Form][Field].name);
    document[Form][Field].focus();
    return(0); 
  }
  else{return(1);}
}
//----------------------------------------



   function codekeypresscheck(x)
   {
     aa = event.keyCode 
     if ((aa<65 || aa>90) && (aa<48 || aa>57) && (aa<97 || aa > 122)) 
     {
           alert("Special Characters not allowed")  
           return false
	 }		
   }
   
 
   function codeblurcheck(x)
   {
     reg = /[A-Z]|[a-z]|[0-9]/
     k=x.value
     if(k!="")
       { 
		for(i=0;i<k.length;i++)
			{
			 if(!reg.test(k.charAt(i)))
			   {
			     alert("Special Characters not allowed")
				 x.focus()	   
			     return false
			   }
			}
		}	
   }



function  removechar(x)
{
if(x.value.indexOf('*')!=-1)
{
a=x.value.split('*')
if(a[1]=="")
x.value=x.value.substring(0,x.value.length-1)
if(!isInteger(a[0]))
x.value=""
}
}


function isInteger(s)
 {   var i;
     for (i = 0; i < s.value.length; i++)
     {
             var c = s.value.charAt(i);
            if (((c < "0") || (c > "9")  || (c==" "))) 
            {
            alert("Enter Numbers Only");
			s.focus()       
            return false;
            
            }
     }
        return true;
 }




function replaceAll(s)
{
	while(s.indexOf('~')!=-1)	
	{
		s=s.replace("~","'")
	}
	while(s.indexOf('^')!=-1)	
	{
		s=s.replace('^','"')
	}
	return s
}

function integerChk(x)
{
aa=event.keyCode;
if(((aa < 48 || aa >57)&& (aa!=13) &&(aa!=8))) 
{ 

 event.keyCode =0
	return false
	} 
} 

function phonenumber(v)
		{
aa=event.keyCode;
  
if(((aa < 48 || aa >57)&& (aa!=13) &&(aa!=8) &&(aa!=32) &&(aa!=40) &&(aa!=47) &&(aa!=45) && (aa!=41) &&(aa!=38))) 
{ 
 event.keyCode =0
	return false
	} 
}


function correctDiscount(y)
{
	if(parseFloat(y.value)>100.00)
	{
		alert("Discount cannot be greater than 100")
		y.focus()
		return false;
	}
	
	else
	return true
	
	
}


function chkDecimal(a,z)
{

	var a,x,y,i,z,count
	regInt=/^[0-9]|\.$/;
	x=a.length
	count=0
	for(i=0;i<x;i++)
	{

		if(!regInt.test(a.charAt(i)))
		{ 
		
			z.value=""
			z.focus()
			return false
		}
				
		if(a.charAt(i)=='.')
		{
			count++			
			if(count==1)
				y=i
		}
		
	}
	
	if(count>1)
	{
		alert("Only one Decimal Point is allowed")
		//z.value=""
		z.focus()
		return false;
	}
	
	if(x-y-1>2)
	{
	
		alert("Only two decimal digits are allowed")
         z.value=z.value.substring(0,z.value.length-1)
         event.keyCode=""
		z.focus()
		return false;
	}
	
	return true
}

function validatename(x)
{
var d
  d=event.keyCode;
  len=Trim(x.value).length
  flag=0
  //^,~,.
  if (d==94 || d==126)
   flag=1
   //.,',space
  if(d==46 || d==39 ||  d==32)
   	{		
		if(len==0) 	
		 flag=1

	}
	
	if(flag==1)
	{
	// alert("First Character Cannot be a Dot or Single Quote ")
	 //x.value=""
	 x.focus()
	 event.keyCode=0
	 return false
	 }
	 else
	 return true
}





function LTrim(str)
	
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) {
          var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;
      s = s.substring(j, i);
   }
   return s;
}
function RTrim(str)
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {

      var i = s.length - 1;     
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      s = s.substring(0, i+1);
   }

   return s;
}

	
function Trim(str)
	
  	 
	{
   return RTrim(LTrim(str));
}



//------------------------------------------
function TextAreaMaxlength(Form,Field,Length)   
{
 var Fieldval;
 Fieldval = document[Form][Field].value;
 if( (Fieldval).length > Length )
 { 
   alert(document[Form][Field].name+" Field Length Exceeds Max Allowed ("+Length+")");
   document[Form][Field].value = (document[Form][Field].value).substring(0,Length-2);
   return(0);
 }
 else {return(1);}   
}


function CheckEmail(Form,Field,Required)
{
 var str= document[Form][Field].value; 
 if (str != "")
 {
  var pos;
  pos = (str).indexOf("@");
   if ( pos < 0 ) 
     { alert("Email should be host@somexyz.com");
       document[Form][Field].focus();
       return(0);
     }
   else
    {
      if( (str).indexOf(".",pos) < 0 )  
       { alert("Email should be host@somexyz.com"); 
         document[Form][Field].focus();
         return(0);
       }
       else
       {   return(1); }
    } 
 }
 else if(Required)
 {
  alert("Email should be somexyz@domain.com");
  document[Form][Field].focus();
  return(0);
 }
 else if(!Required)
 {
   return(1);
 }  
}

function CheckSpecialChar(Form,Field)
{
 var Fieldval,Patterns;
 Patterns=/[']/;
 Fieldval = document[Form][Field].value;

  if( (Fieldval).indexOf("'") == -1)// && (Fieldval).indexOf("<") == -1 && (Fieldval).indexOf(">") == -1)
   { 
   return(1);
   }
  else
   { 
   //  alert("Special Character single quote(') is not Allowed ");
      document[Form][Field].value=(document[Form][Field].value).replace(Patterns,"`");
      document[Form][Field].focus();
      return(0);
   }
}

function SpaceBet(Form,Field)
{	
var Fieldval;
Fieldval=document[Form][Field].value;
if( (Fieldval).indexOf(" ") == -1)
   { 
   return(1);
   }
  else
   { 
alert("Blank Space Not Allowed In This Field");
document[Form][Field].value=(document[Form][Field].value).replace(" ","");
document[Form][Field].focus();
	}
}

function NumericOnly(Form,Field)
{
  var Patterns;
  Patterns=/\D/;
  document[Form][Field].value = (document[Form][Field].value).replace(Patterns,"");
  document[Form][Field].focus();
}

function CharOnly(Form,Field)
{
  var Patterns;
  Patterns=/\\|\||\^|\[|\]|[^\x20|^A-^Z]/i;
  document[Form][Field].value = (document[Form][Field].value).replace(Patterns,"");
  document[Form][Field].focus();
}


function Alphanumeric(Form,Field)
{
  var Patterns;
  Patterns=/\\|\||\^|\[|\]|[^\x20|^A-^Z|^0-^9]/i;
  document[Form][Field].value = (document[Form][Field].value).replace(Patterns,"");
  document[Form][Field].focus();
}






function datevalidatematex(element,id)
	{
		if(id.split(" ").join("")!="" )
		{
			var arr = new Array(2)
			var arr1 = new Array(2)
			var MM,DD,YYYY,sysDate,FDate
			arr = id.split("/")
			MM = arr[1]
			DD = arr[0]
			YYYY = arr[2]
			FDate   = id
			sysDat= new Date()
			var hour        = sysDat.getHours();
			var minute      = sysDat.getMinutes();
			var second      = sysDat.getSeconds();
			var monthnumber = parseInt(sysDat.getMonth()) +1; 
			var monthday    = sysDat.getDate();
			var year        = sysDat.getYear();
			sysDate=monthday +"/" + monthnumber  + "/" + year //+ " " + hour + ":" + minute +":" + second;
			arr1 = FDate.split("/")
			if(DD=="09")
				{
					DD=9
				}
			if(DD=="08")
				{
					DD=8
				}
			if(MM=="09")
				{
					MM=9
				}
			if(MM=="08")
				{
					MM=8
				}
			if(isNaN(MM) || (parseInt(MM) < 1 || parseInt(MM) > 12))
			{
				element.focus();
				alert ("Y o u  S h o u l d  E n t e r  a  V a l i d  D a t e \n \n\tT h e  D a t e  F o r m a t  i s \n\n \t DD/MM/YYYY \n\n The Month Should be BETWEEN 1 to 12 \n \n Example   \t " + sysDate);
				element.select();
			}
			else if(isNaN(DD) || (parseInt(DD) < 1 || parseInt(DD) > 31) )
			{
				element.focus();
				alert ("Y o u  S h o u l d  E n t e r  a  V a l i d  D a t e \n \ntT h e  D a t e  F o r m a t  i s \n\n \t DD/MM/YYYY  \n\n The Day Should be BETWEEN 1 to 28/29/30/31 \n \n Example   \t " + sysDate);
				element.select();
			}
			else if(isNaN(YYYY))
			{
				element.focus();
				alert ("yyyY o u  S h o u l d  E n t e r  a  V a l i d  D a t e \n\tT h e  D a t e  F o r m a t  i s \n\n \t DD/MM/YYYY  \n\n The Year Should be > 1999 \n \n Example   \t " + sysDate);
				element.select();
			}
			/*else if( parseInt(YYYY)< parseInt(arr1[2]) )
			{
				element.focus();
				alert ("To Date should be greaterthan \n\n or equal to From Date ");
				element.select();
			}
			else if( parseInt(YYYY)== parseInt(arr1[2]) && parseInt(MM) < parseInt(arr1[0]))
			{
				element.focus();
				alert ("To Date should be greaterthan \n\n or equal to From Date ");
				element.select();
			}
			else if( parseInt(YYYY)== parseInt(arr1[2]) && parseInt(MM) <= parseInt(arr1[0]) && parseInt(DD) < parseInt(arr1[1]))
			{
				element.focus();
				alert ("To Date should be greaterthan \n\n or equal to From Date ");
				element.select();
			}
			else if(parseInt(YYYY) > ((parseInt(arr1[2])+10)) )
			{
				element.focus()
				alert("To Date should be with in TEN years from From Date ")
				element.select()
			}*/
			else if((parseInt(MM) == 4 || parseInt(MM) == 6 || parseInt(MM) == 9 || parseInt(MM) == 11 )  && parseInt(DD) == 31 )
			{
				element.focus()
				alert("31 is an invalid Date in "+MM + "th Month")
				element.select()
			}
			else if(parseInt(MM) == 2 && (parseInt(DD) > 29) )
			{
				element.focus()
				alert(DD +" is an invalid Date in "+MM + "nd Month")
				element.select()
			}
			else if(parseInt(MM) == 2 && parseInt(DD) == 29 && ((parseInt(YYYY)%4)!= 0))
			{
				element.focus()
				alert( YYYY + " is not a LEAP year \n 29 is not a valid date " )
				element.select()
			}
		}
	}







function datevalidate(element)
	{
		if(element.value.split(" ").join("")!="" )
		{
			var arr = new Array(2)
			var arr1 = new Array(2)
			var MM,DD,YYYY,sysDate,FDate
			arr = element.value.split("/")
			MM = arr[1]
			DD = arr[0]
			YYYY = arr[2]
			FDate   = element.value
			sysDat= new Date()
			var hour        = sysDat.getHours();
			var minute      = sysDat.getMinutes();
			var second      = sysDat.getSeconds();
			var monthnumber = parseInt(sysDat.getMonth()) +1; 
			var monthday    = sysDat.getDate();
			var year        = sysDat.getYear();
			sysDate=monthday +"/" + monthnumber  + "/" + year //+ " " + hour + ":" + minute +":" + second;
			arr1 = FDate.split("/")
			if(DD=="09")
				{
					DD=9
				}
			if(DD=="08")
				{
					DD=8
				}
			if(MM=="09")
				{
					MM=9
				}
			if(MM=="08")
				{
					MM=8
				}
			if(isNaN(MM) || (parseInt(MM) < 1 || parseInt(MM) > 12))
			{
				element.focus();
				alert ("Y o u  S h o u l d  E n t e r  a  V a l i d  D a t e \n \n\tT h e  D a t e  F o r m a t  i s \n\n \t DD/MM/YYYY \n\n The Month Should be BETWEEN 1 to 12 \n \n Example   \t " + sysDate);
				element.select();
			}
			else if(isNaN(DD) || (parseInt(DD) < 1 || parseInt(DD) > 31) )
			{
				element.focus();
				alert ("Y o u  S h o u l d  E n t e r  a  V a l i d  D a t e \n \ntT h e  D a t e  F o r m a t  i s \n\n \t DD/MM/YYYY  \n\n The Day Should be BETWEEN 1 to 28/29/30/31 \n \n Example   \t " + sysDate);
				element.select();
			}
			else if(isNaN(YYYY))
			{
				element.focus();
				alert ("yyyY o u  S h o u l d  E n t e r  a  V a l i d  D a t e \n\tT h e  D a t e  F o r m a t  i s \n\n \t DD/MM/YYYY  \n\n The Year Should be > 1999 \n \n Example   \t " + sysDate);
				element.select();
			}
			/*else if( parseInt(YYYY)< parseInt(arr1[2]) )
			{
				element.focus();
				alert ("To Date should be greaterthan \n\n or equal to From Date ");
				element.select();
			}
			else if( parseInt(YYYY)== parseInt(arr1[2]) && parseInt(MM) < parseInt(arr1[0]))
			{
				element.focus();
				alert ("To Date should be greaterthan \n\n or equal to From Date ");
				element.select();
			}
			else if( parseInt(YYYY)== parseInt(arr1[2]) && parseInt(MM) <= parseInt(arr1[0]) && parseInt(DD) < parseInt(arr1[1]))
			{
				element.focus();
				alert ("To Date should be greaterthan \n\n or equal to From Date ");
				element.select();
			}
			else if(parseInt(YYYY) > ((parseInt(arr1[2])+10)) )
			{
				element.focus()
				alert("To Date should be with in TEN years from From Date ")
				element.select()
			}*/
			else if((parseInt(MM) == 4 || parseInt(MM) == 6 || parseInt(MM) == 9 || parseInt(MM) == 11 )  && parseInt(DD) == 31 )
			{
				element.focus()
				alert("31 is an invalid Date in "+MM + "th Month")
				element.select()
			}
			else if(parseInt(MM) == 2 && (parseInt(DD) > 29) )
			{
				element.focus()
				alert(DD +" is an invalid Date in "+MM + "nd Month")
				element.select()
			}
			else if(parseInt(MM) == 2 && parseInt(DD) == 29 && ((parseInt(YYYY)%4)!= 0))
			{
				element.focus()
				alert( YYYY + " is not a LEAP year \n 29 is not a valid date " )
				element.select()
			}
		}
	}




function datecompare(Field1,Field2)
	{

		var Farr1 = new Array(2);
		var Tarr2 = new Array(2);
		Farr = Field1.value.split("/");

		FMM = Farr[1];
		FDD = Farr[0];
		FYYYY = Farr[2];

		Tarr = Field2.value.split("/");
		TMM = Tarr[1];
		TDD = Tarr[0];
		TYYYY = Tarr[2];
			sysDat= new Date()
			var hour        = sysDat.getHours();
			var minute      = sysDat.getMinutes();
			var second      = sysDat.getSeconds();
			var monthnumber = parseInt(sysDat.getMonth()) +1;
			var monthday    = sysDat.getDate();
			var year        = sysDat.getYear();
		sysDate=monthday +"/" + monthnumber  + "/" + year //+ " " + hour + ":" + minute +":" + second;
					
			

		if(FDD=="09")
			{
				FDD=9;
			}
		if(FDD=="08")
				{
				FDD=8;
			}
		if(FMM=="09")
			{
			FMM=9;
			}
		if(FMM=="08")
			{
				FMM=8;
			}

		if(TDD=="09")
			{
				TDD=9;
			}
		if(TDD=="08")
			{
				TDD=8;
			}
		if(TMM=="09")
			{
				TMM=9;
			}
		if(TMM=="08")
			{
				TMM=8;
			}

		if(isNaN(FMM) || (parseInt(FMM) < 1 || parseInt(FMM) > 12))
		{
			alert ("Y o u  S h o u l d  E n t e r  a  V a l i d  D a t e \n \n\tT h e  D a t e  F o r m a t  i s \n\n \t MM/DD/YYYY \n\n The Month Should be BETWEEN 1 to 12 \n \n Example   \t " + sysDate);
			return false;
		}
		else if(isNaN(FDD) || (parseInt(FDD) < 1 || parseInt(FDD) > 31) )
		{
			alert ("Y o u  S h o u l d  E n t e r  a  V a l i d  D a t e \n \ntT h e  D a t e  F o r m a t  i s \n\n \t MM/DD/YYYY \n\n The Day Should be BETWEEN 1 to 28/29/30/31 \n \n Example   \t " + sysDate);
			return false;
		}
		else if(isNaN(FYYYY))
		{
			alert ("Y o u  S h o u l d  E n t e r  a  V a l i d  D a t e \n\tT h e  D a t e  F o r m a t  i s \n\n \t MM/DD/YYYY \n\n The Year Should be > 1999 \n \n Example   \t " + sysDate);
			return false;
		}
		if(isNaN(TMM) || (parseInt(TMM) < 1 || parseInt(TMM) > 12))
		{
			alert ("Y o u  S h o u l d  E n t e r  a  V a l i d  D a t e \n \n\tT h e  D a t e  F o r m a t  i s \n\n \t MM/DD/YYYY \n\n The Month Should be BETWEEN 1 to 12 \n \n Example   \t " + sysDate);
			return false;
		}
		else if(isNaN(TDD) || (parseInt(TDD) < 1 || parseInt(TDD) > 31) )
		{
			alert ("Y o u  S h o u l d  E n t e r  a  V a l i d  D a t e \n \ntT h e  D a t e  F o r m a t  i s \n\n \t MM/DD/YYYY \n\n The Day Should be BETWEEN 1 to 28/29/30/31 \n \n Example   \t " + sysDate);
			return false;
		}
		else if(isNaN(TYYYY))
		{
			alert ("Y o u  S h o u l d  E n t e r  a  V a l i d  D a t e \n\tT h e  D a t e  F o r m a t  i s \n\n \t MM/DD/YYYY \n\n The Year Should be > 1999 \n \n Example   \t " + sysDate);
			return false;
		}

		else if( parseInt(TYYYY) < parseInt(FYYYY) )
		{
			alert ("To Year should be greater than \n\n or equal to From Year");
			return false;
		}
		else if( parseInt(TYYYY)== parseInt(FYYYY) && parseInt(TMM) < parseInt(FMM))
		{
			alert ("To Month should be greaterthan \n\n or equal to From Month");
			return false;
		}
		else if( parseInt(TYYYY)== parseInt(FYYYY) && parseInt(TMM) <= parseInt(FMM) && parseInt(TDD) < parseInt(FDD))
		{
			alert ("To Date should be greaterthan \n\n or equal to From Date ");
			return false;
		}
		else if(parseInt(TYYYY) > ((parseInt(FYYYY)+10)) )
		{
			alert("To Date should be with in TEN years from From Date ");
			return false;
		}
		else if((parseInt(FMM) == 4 || parseInt(FMM) == 6 || parseInt(FMM) == 9 || parseInt(FMM) == 11 )  && parseInt(FDD) == 31)
		{
			alert("31 is an invalid Date in "+FMM + "th Month");
			return false;
		}
		else if((parseInt(TMM) == 4 || parseInt(TMM) == 6 || parseInt(TMM) == 9 || parseInt(TMM) == 11 )  && parseInt(TDD) == 31)
		{
			alert("31 is an invalid Date in "+TMM + "th Month");
			return false;
		}
		else if(parseInt(FMM) == 2 && (parseInt(FDD) > 29) )
		{
			alert(FDD +" is an invalid Date in "+FMM + "nd Month");
			return false;
		}
		else if(parseInt(TMM) == 2 && (parseInt(TDD) > 29) )
		{
			alert(TDD +" is an invalid Date in "+TMM + "nd Month");
			return false;
		}
		else if(parseInt(FMM) == 2 && parseInt(FDD) == 29 && ((parseInt(FYYYY)%4)!= 0))
		{
			alert( FYYYY + " is not a LEAP year \n 29 is not a valid date " );
			return false;
		}
		else if(parseInt(TMM) == 2 && parseInt(TDD) == 29 && ((parseInt(TYYYY)%4)!= 0))
		{
			alert( TYYYY + " is not a LEAP year \n 29 is not a valid date " );
			return false;
		}

		return true;
}

//--Aruna

function Textareamaxlengthcheck(obj,maxlen)
{
	var object=obj.value;
	var objectlen=obj.value.length;
	if(objectlen>maxlen)
	{
		alert("Maxmium Characters allowed : " +maxlen+' but Entered ' +objectlen);
		obj.value=obj.value.substring(0,240)
		obj.select();
	}
	/*for(var i=0;i<objectlen;i++)
	{
		if(object.charAt(i)=="&" || object.charAt(i)=="'"  || object.charAt(i)=='"'  || object.charAt(i)=='#' )
		{
			alert("Special Character  " +object.charAt(i)+' not allowed')
			obj.select();
			break;
		}
	}*/
}




   function Passwordchecking(x)
   {
     reg = /[A-Z]|[a-z]|[0-9]/
     k=x.value
     ll=0
     if(k!="")
       { 
		for(i=0;i<k.length;i++)
			{
			 if(!reg.test(k.charAt(i)))
			   {
			    // alert("Special Characters not allowed")
			    ll=1
				  }
			}
			
			if(ll==1)
			{
			 alert("Special Characters not allowed");
			 x.focus()	   
			  return false
			}
			
			   if(k.length<7)
			   {
			    alert("Enter minimum seven alphanumeric")
				 x.focus();	   
			     return false;
			   }
		}	
   }

//-----


//Auction Room related functions
 function NumericDataOnly()
    {
       var key = event.keyCode;
       //alert(key);
       if (( key > 47 && key < 58 )|| (key==13) ||(key==8) ||(key==9) ||(key==32)||(key==190)||(key==110)||(key==46)||( key > 95 && key < 106 )||( key > 36 && key < 41 ))
       {
           return;
       }
       else
          window.event.returnValue = null;
    }
    
    
    
        
    function check_box()
    {
        var frm = document.forms[0];
        var j=0;
        
        for (i=0; i<frm.length; i++)
        {
            elm=document.forms[0].elements[i]
            if(elm.type=='checkbox' )
            {
              /*   if(frm.elements[i].checked == true && frm.elements[i+2].checked == true)
                 {
                     alert("Select ANY one type of Bidding\n(Manual or Proxy bid)"); 
                     frm.elements[i].focus();
                     return false;
                 }*/
                 
               
                 if(frm.elements[i].checked == true)
                 {
                    j=1;
                 }
                 
                 /*if((frm.elements[i].checked == true && (frm.elements[i+1].value.split(" ").join("") =="0" ||frm.elements[i+1].value.split(" ").join("") =="")) ||frm.elements[i].checked == true && (frm.elements[i-1].value.split(" ").join("") =="0" ||frm.elements[i-1].value.split(" ").join("") ==""))*/
                 if(frm.elements[i].checked == true && (frm.elements[i+1].value.split(" ").join("") =="0" ||frm.elements[i+1].value.split(" ").join("") ==""))
                 {
                    alert("Invalid Bid Amount");
                    frm.elements[i].focus();
                    return false;
                 }
                 
                 if(frm.elements[i].checked == true)
                 {
                    if(frm.elements[i-1].type == 'text')
                    {
                        var a,x,j,count,y
                        regInt=/^[0-9]|\.$/;
                        a=frm.elements[i-1].value
	                    x=a.length
	                    count=0
	                    for(j=0;j<x;j++)
	                    {
	                        if(!regInt.test(a.charAt(j)))
		                    { 
		                        alert("Invalid Bid Amount");
		                        frm.elements[i].focus();
			                    return false
		                    }
	                    
	                    
		                    if(a.charAt(j)=='.')
		                    {
			                    count++		
			                    if(count==1)
				                    y=j	
		                    }
	                    }
	                    if(count>1)
                        {
	                        alert("Only one Decimal Point is allowed")
	                        frm.elements[i].focus();
	                        return false;
                        }
                        if(x-y-1>2)
	                    {
                    	
		                    alert("Only two decimal digits are allowed")
		                    frm.elements[i].focus();
                            return false;
	                    }
                    }
                    
                    if(frm.elements[i+1].type == 'text')
                    {
                        var a,x,j,count
                        regInt=/^[0-9]|\.$/;
                        a=frm.elements[i+1].value
	                    x=a.length
	                    count=0
	                    for(j=0;j<x;j++)
	                    {
	                        if(!regInt.test(a.charAt(j)))
		                    { 
		                        alert("Invalid Bid Amount");
		                        frm.elements[i].focus();
			                    return false
		                    }
		                    if(a.charAt(j)=='.')
		                    {
			                    count++	
			                    if(count==1)
				                    y=j			
		                    }
	                    }
	                    if(count>1)
                        {
	                        alert("Only one Decimal Point is allowed")
	                        frm.elements[i].focus();
	                        return false;
                        }
                        if(x-y-1>2)
	                    {
                    	
		                    alert("Only two decimal digits are allowed")
		                    frm.elements[i].focus();
                            return false;
	                    }
                    }
                 }
	        }  
        }
        
        if(j==0)
        {
            alert("Select Product to Bid");
            return false;
        } 
        else
        {
           //Confirmation To Submit Bids 
           var conlbl="Do You want to Submit your Bid(s)";
           var bidsubres = window.confirm(conlbl);
           if(bidsubres == false)
           {
                return false;
           }
        }      
        return true;
    }


//Auction Room related functions

function checkboxSelection()  //for chcking check box seletion in clear bid
{
        var frm = document.forms[0];
        var j=0;
        
        for (i=0; i<frm.length; i++)
        {
            elm=document.forms[0].elements[i]
            if(elm.type=='checkbox' )
            {
                 if(elm.checked == true)
                 {
                    j=j+1;
                 }
            }
        }
        if(j==0)
        {
        alert("Select the first bid");
        return false;
        }
        return true;
}




function extractNumber(obj, decimalPlaces, allowNegative)
{
	 var temp = obj.value;
	 // avoid changing things if already formatted correctly
	 var reg0Str = '[0-9]*';
	 if (decimalPlaces > 0)
	 {
		  reg0Str += '\\.?[0-9]{0,' + decimalPlaces + '}';
	 } 
	else if (decimalPlaces < 0) 
	{
		reg0Str += '\\.?[0-9]*';
	 }
	 reg0Str = allowNegative ? '^-?' + reg0Str : '^' + reg0Str;
	 reg0Str = reg0Str + '$';
	 var reg0 = new RegExp(reg0Str);
	 if (reg0.test(temp)) return true;
 
	 // first replace all non numbers
	var reg1Str = '[^0-9' + (decimalPlaces != 0 ? '.' : '') + (allowNegative ? '-' : '') + ']';
	var reg1 = new RegExp(reg1Str, 'g');
	temp = temp.replace(reg1, '');
 
	if (allowNegative)
	{
		// replace extra negative
		var hasNegative = temp.length > 0 && temp.charAt(0) == '-';
		var reg2 = /-/g;
		temp = temp.replace(reg2, '');
		if (hasNegative) temp = '-' + temp;
 	}
 
	if (decimalPlaces != 0)
	{
		var reg3 = /\./g;
		var reg3Array = reg3.exec(temp);
		if (reg3Array != null)
		{
			// keep only first occurrence of .
			//  and the number of places specified by decimalPlaces or the entire string if decimalPlaces < 0
			var reg3Right = temp.substring(reg3Array.index + reg3Array[0].length);
			reg3Right = reg3Right.replace(reg3, '');
			reg3Right = decimalPlaces > 0 ? reg3Right.substring(0, decimalPlaces) : reg3Right;
			temp = temp.substring(0,reg3Array.index) + '.' + reg3Right;
		}
 	}
 
	obj.value = temp;
}

function blockNonNumbers(obj, e, allowDecimal, allowNegative)
	{
		var key;
		var isCtrl = false;
		var keychar;
		var reg;
  
 		if(window.event) 
		{
			key = e.keyCode;
			isCtrl = window.event.ctrlKey
 		}
		else if(e.which) 
		{
			key = e.which;
			isCtrl = e.ctrlKey;
 		}
 
		if (isNaN(key)) return true;
 
		keychar = String.fromCharCode(key);
 
		// check for backspace or delete, or if Ctrl was pressed
		if (key == 8 || isCtrl ||  key==13)
 		{
			return true;
 		}
 
		reg = /\d/;
		var isFirstN = allowNegative ? keychar == '-' && obj.value.indexOf('-') == -1 : false;
		var isFirstD = allowDecimal ? keychar == '.' && obj.value.indexOf('.') == -1 : false;
 
		return isFirstN || isFirstD || reg.test(keychar);
	}


function checkURL (field) 
{
        var v = new RegExp(); 
    	
    	
    	 v.compile("(http:)//www.[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$"); 
    	
    	if (!v.test(document.getElementById(field).value))
    	{ 
        alert("You must supply a valid URL(http://www.mysite.com)."); 
        return false; 
        }
        
        return true;
   
   
}



var keys = document.all?true:false;
function butFocus(butname)
{
    var _char=keys?event.keyCode:e.which;
        if(_char==13 )
        {
        document.getElementById(butname).focus();
        }
}

//---------------------------------
//For Closed Auction ( Custom)
function DateonlyValidation(element)
	{
		if(element.value.split(" ").join("")!="" )
		{
		var arr = new Array(2)
			var arr1 = new Array(2)
			var MM,DD,YYYY,sysDate,FDate
			arr = element.value.split("/")
			MM = arr[1]
			DD = arr[0]
			YYYY = arr[2]
			FDate   = element.value
			sysDat= new Date()
			var hour        = sysDat.getHours();
			var minute      = sysDat.getMinutes();
			var second      = sysDat.getSeconds();
			var monthnumber = parseInt(sysDat.getMonth()) +1; 
			var monthday    = sysDat.getDate();
			var year        = sysDat.getYear();
			sysDate=monthday +"/" + monthnumber  + "/" + year;
		    arr1 = FDate.split("/")
			
			if(DD=="09")
				{
					DD=9
				}
			if(DD=="08")
				{
					DD=8
				}
			if(MM=="09")
				{
					MM=9
				}
			if(MM=="08")
				{
					MM=8
				}
	    			
	            if(FDate.substring(2,3)!='/')
                {
                      alert("Enter Valid Date\nThe Date Format is :\nDD/MM/YYYY\n \n Example: " + sysDate );
                      return false;      
                }
                if(FDate.substring(5,6)!='/')
                {
                      alert("Enter Valid Date\nThe Date Format is :\nDD/MM/YYYY\n \n Example: " + sysDate );
                      return false;    
                }
                 if(isNaN(MM) || (parseInt(MM) < 1 || parseInt(MM) > 12))
			    {
				    alert ("Enter Valid Date\nThe Date Format is :\n\nDD/MM/YYYY  \n\n The Month Should be BETWEEN 1 to 12");
				    return false;
			    }
			    else if(isNaN(DD) || (parseInt(DD) < 1 || parseInt(DD) > 31) )
			    {
				    alert ("Enter Valid Date\nThe Date Format is :\n\nDD/MM/YYYY \n\n The Day Should be BETWEEN 1 to 28/29/30/31");
				    return false;
			    }
			    else if(isNaN(YYYY))
			    {
				    alert ("Enter Valid Date\nThe Date Format is :\n\nDD/MM/YYYY");
				    return false;
			    }
			    else if((parseInt(MM) == 4 || parseInt(MM) == 6 || parseInt(MM) == 9 || parseInt(MM) == 11 )  && parseInt(DD) == 31 )
			    {
    				alert("31 is an Invalid Date in "+MM + "th Month")
    				return false;
			    }
			    else if(parseInt(MM) == 2 && (parseInt(DD) > 29) )
			    {
				    alert(DD +" is an Invalid Date in "+MM + "nd Month")
				    return false;
			    }
			    else if(parseInt(MM) == 2 && parseInt(DD) == 29 && ((parseInt(YYYY)%4)!= 0))
			    {
				    alert( YYYY + " is not a LEAP year \n 29 is not a valid date " )
				    return false;
			    }
			    else if( parseInt(YYYY)== parseInt(year) && parseInt(MM) >= parseInt(monthnumber) && parseInt(DD) > parseInt(monthday))
	         	    {
			        alert ("Selected Date should not be greater than Today ");
			        return false;
		            }
                return true;        	
		}
	}
//---------------------------------



//-----------------------------------------------
//-----------------------------------------------
/*Functions to Block the Entry of +,-,%,<,>
  on key up call the second function
  onkeyup="BlockSplChars(this);"
  furst function will return 
  with out executing first function if the user enters 
  'left arrow' or 'right arrow' to move inside a textbox.
*/

    function spcharcheck(t)
    {
      var charcheck = "+-%&<>";
      var w = "";
      for (i=0; i < t.value.length; i++) 
      {
        x = t.value.charAt(i);
        if (charcheck.indexOf(x,0) == -1)
        w += x;
      }
      t.value = w;
    }
    
    function BlockSplChars(m)
    {
       var key = event.keyCode;
       //alert(key);
       if((key==37)||(key==39))
       return;
       else
       spcharcheck(m);
    }
//----------------------------------------------------
//----------------------------------------------------


//Function Allows Only Decimal Point and numbers
function AllowNumericPlusDecimal()  
   {
     if(event.keyCode == 46 ||event.keyCode >= 48 && event.keyCode <= 57 ||event.keyCode == 13)
        {
            event.returnValue= true;
        }
     
     else
        {
         event.returnValue= false;
         alert("Please enter numbers only")
        }
   }	
//
// for number is convert into character
function outString(input) 
{
    var words2="";
    flag="false";
    var num2=null;
    set=new Array();
    typearr=new Array(" Thousand "," Lakhs"," Million, "," billion, "," trillion, "," quadrillion, ");
    arr=new Array();
    arr[2]=new Array("","One Hundred","Two Hundred","Three Hundred","Four Hundred","Five Hundred","Six Hundred","Seven Hundred","Eight Hundred","Nine Hundred");
    arr[1]=new Array("","Ten","Twenty","Thirty","Fourty","Fifty","Sixty","Seventy","Eighty","Ninty");
    arr[0]=new Array("","One","Two","Three","Four","Five","Six","Seven","Eight","Nine");
    teens=new Array("Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen")
    count=0;
    x=0;
    y=0;
    var num2=input;
    var num1
    var mflag=0
    var tmpflag =0
    var mtmp =0
    numarr=num2.split(",");
    num2=numarr.join("");
    num1 = parseFloat(num2)
    num2 = ""+num1
     if (parseFloat(num2)==0) {words2="Zero";}
    else {
      while (num2.charAt(0)=="0") {
    }
    set[x]=new Array();
      for (i=1;i<=num2.length;i++) {
        if (y>2) {
           y=0;
          x++;
           set[x]=new Array();
        }
        set[x][y]=num2.charAt(num2.length-i);
        y++;
      }
      for (j=x;j>=0;j--) {
         for (k=set[j].length-1;k>=0;k--) {
             if (k==1&&parseInt(set[j][k])==1&&parseInt(set[j][0])>0) {
              words2+=teens[parseInt(set[j][0])-1];
              k=0;
           } else
            {	if (k==0 && j==2)
					 {
					  if (set[j][k] ==1&&(set[j-1][k+2])>0)
						  {
					        words2+=teens[parseInt(set[j-1][k+2])- 1] + typearr[1]
					        mflag =1
					        tmpflag = 1
					        mtmp = 1
						  } 
					     if (set[j][k] >=1&&(set[j-1][k+2])==0)
					       {
					      words2+=arr[1][parseInt(set[j][k])] + " "
					      
					      	}
					     if (set[j][k] >1&&(set[j-1][k+2])>0)
					       {
					         words2+=arr[1][parseInt(set[j][k])]  + " "
					      
							}
						 
					}				
					 
						 else
						   {
						   
					 		 if (k==2 && j==1 && mflag !=1)
							   { 
							     words2+=arr[k - 2][parseInt(set[j][k])] + typearr[k -1] + "  "
							   
							      mflag =0	
							      mtmp =1
							   }
							 else 
							   {
							   
							    if (tmpflag != 1)
							     {
							   
							   	words2+=arr[k][parseInt(set[j][k])];
							   	tmpflag = 0
							   	}
							 tmpflag =0  
							}
							
		           }
		           
				}	
           if (k==2) {
             if (parseFloat(set[j][k])!=0&&parseFloat(set[j][1]+set[j][0])!=0 && mtmp ==0) {
                words2+=" AND ";
             }
             mtmp = 0
             if (j==0&&parseInt(set[j][k])==0) {
               if (words2.substr(words2.length-2,2)==",") {
                  words2=words2.substr(0,words2.length-2);
                  
                }
                if (parseFloat(set[j][1]+set[j][0])!=0) {
                  words2+=" AND ";
                }
              } 
           }
           if (k==1)
           {
           if (parseInt(set[j][0])!=0&&parseInt(set[j][k])>1) {words2+=" ";}
           }
           if (k==0 && j>0 && j!=2)
            {	
				  if (parseFloat(set[j].join(""))>0) {
				    if(set[1][0] >0 || set[1][1] >0)
				     {				    
						words2+=typearr[j-1];
					 }
                
             }
           }
         }
      }
   }
   return words2;
 }
 
 

