// JavaScript Document
var color='#ffffa0';
var Rcolor='#F5F5F5';
var dtCh= "-";
var minYear=1900;
var maxYear=2100;
var rValue; 
var xmlHttp;
var myObject;
var File_Path;
var AmountFieldLength = 0;

function Display(Id)
{
	var valueField =document.getElementById(Id).value;
	if (valueField == "Cash")
	{
		document.getElementById("CashType1").style.display = '';
		document.getElementById("CashType2").style.display = '';
		
		document.getElementById("ChqueType1").style.display = 'none';
		document.getElementById("ChqueType2").style.display = 'none';
		document.getElementById("ChqueType3").style.display = 'none';
		
		document.getElementById("BankTransferType1").style.display = 'none';
		document.getElementById("BankTransferType2").style.display = 'none';
		document.getElementById("BankTransferType3").style.display = 'none';
		document.getElementById("BankTransferType4").style.display = 'none';
	}
	
	if (valueField == "Chque")
	{
		document.getElementById("CashType1").style.display = 'none';
		document.getElementById("CashType2").style.display = 'none';
		
		document.getElementById("ChqueType1").style.display = '';
		document.getElementById("ChqueType2").style.display = '';
		document.getElementById("ChqueType3").style.display = '';
		
		document.getElementById("BankTransferType1").style.display = 'none';
		document.getElementById("BankTransferType2").style.display = 'none';
		document.getElementById("BankTransferType3").style.display = 'none';
		document.getElementById("BankTransferType4").style.display = 'none';
	}
	
	if (valueField == "Bank_Transfer")
	{
		document.getElementById("CashType1").style.display = 'none';
		document.getElementById("CashType2").style.display = 'none';
		
		document.getElementById("ChqueType1").style.display = 'none';
		document.getElementById("ChqueType2").style.display = 'none';
		document.getElementById("ChqueType3").style.display = 'none';
		
		document.getElementById("BankTransferType1").style.display = '';
		document.getElementById("BankTransferType2").style.display = '';
		document.getElementById("BankTransferType3").style.display = '';
		document.getElementById("BankTransferType4").style.display = '';
	}
	
	if (valueField == "")
	{
		document.getElementById("CashType1").style.display = 'none';
		document.getElementById("CashType2").style.display = 'none';
		
		document.getElementById("ChqueType1").style.display = 'none';
		document.getElementById("ChqueType2").style.display = 'none';
		document.getElementById("ChqueType3").style.display = 'none';
		
		document.getElementById("BankTransferType1").style.display = 'none';
		document.getElementById("BankTransferType2").style.display = 'none';
		document.getElementById("BankTransferType3").style.display = 'none';
		document.getElementById("BankTransferType4").style.display = 'none';
	} 
	
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}




function Customer_ID(Id)
{ 
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	  {
	  alert ("Your browser does not support AJAX!");
	  return;
	  } 
	var url="./Customer_ID.php";
	url=url+"?q="+document.getElementById("Selected_Option1").value;
	url=url+"&Id="+Id;
	url=url+"&rand="+Math.random();
	xmlHttp.onreadystatechange=stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function stateChanged()
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		var Card = xmlHttp.responseText;
		var T_Card = Card.substr(0,3);
		
		
		if (T_Card == "LCR")
		Color = "#FF0000";
		if (T_Card == "LCG")
		Color = "#006633";
		if (T_Card == "LCB")
		Color = "#0000FF";
		
		if (T_Card == "LCF")
		var T_Card = Card.substr(0,4);
		
		if (T_Card == "LCFM")
		Color = "#000000";
		
		document.getElementById("Customer_Code_TD").innerHTML="<span style=color:"+Color+">"+xmlHttp.responseText+"</span>";
		if (T_Card != "LCFM")
		document.getElementById("Random_Id").value = Card.substr(4,Card.length);
		if (T_Card == "LCFM")
		document.getElementById("Random_Id").value = Card.substr(5,Card.length);
	}
}


function submitForm(myform)
{
	//document.getElementById("frmAccount").submit();
	document.getElementById("frmAccount").submit();
}

function PaymentsTotal(val,F_Id)
{	
	var Total_Value = document.getElementById(F_Id).value;
	if (Total_Value < val)
	{
		alert("Payments cannot be less than "+val);
		return false;
	}
	if (Total_Value > val)
	{
		alert("Payments cannot be more than "+val);
		return false;
	}
	if (Total_Value == val)
	{
		return true;
	}
}	

function isProper(Id) {
var string_len = document.getElementById(Id).value.length;
var string = document.getElementById(Id).value;
var iChars = "*|,\":<>[]{}`\';()@&$#%";

	for (var t = 0; t < string_len; t++)
	{
		if (iChars.indexOf(string.charAt(t)) != -1)
		{
			return false;
		}
	}

} 

function IntegerValue(s){
	if(isNaN(s))
	{
		return false;
    }
	else
	{
	return true;	
	}
}

function isInteger(s){
	var w;
    for (w = 0; w < s.length; w++){   
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    for (q = 0; q < s.length; q++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var a = 1; a <= n; a++) {
		this[a] = 31
		if (a==4 || a==6 || a==9 || a==11) {this[a] = 30}
		if (a==2) {this[a] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12);
	var pos1=dtStr.indexOf(dtCh);
	var pos2=dtStr.indexOf(dtCh,pos1+1);
	var strDay=dtStr.substring(0,pos1);
	var strMonth=dtStr.substring(pos1+1,pos2);
	var strYear=dtStr.substring(pos2+1);
	strYr=strYear;
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : dd-mm-yyyy")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
/*	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}*/
return true
}

function checkfile(Id)
{
	//File_Path = document.getElementById(Id).value;
	/*myObject = GetScriptObject();
	if (myObject == null)
	{
		  alert ("Your browser does not support AJAX!");
		  return;
	}
	else
	{
		alert("Support ");	
	}*/
	
	//myObject = new ActiveXObject("Scripting.FileSystemObject");
	/*if(myObject.FileExists(File_Path))
	{
	   //return true;
	   alert("Yes");
	} else {
	   //return false;
	   alert("No");
	}*/
}

function Phone_Format(Id, Length, Text)
{
	var M_Value = document.getElementById(Id).value;
	var string_len = document.getElementById(Id).value.length;
	var string = document.getElementById(Id).value;
	var iChars = "*ASDFGHJKLZXCVBNMQWERTYUIOPasdfghjklzxcvbnmqwertyuiop|,\":<>[]{}`\';()@&$#%_-=+*";
	
	var M_string_len = document.getElementById(Id).value.length;
	if (M_string_len == Length)
	{
		M_Value = document.getElementById(Id).value;
		M_string_len = document.getElementById(Id).value.length;
		String_1 = M_Value.substr(0,Length);
		String_2 = M_Value.substr(Length,M_string_len);
		
		document.getElementById(Id).value=String_1+'-'+String_2;
	}
	
	if (string_len <= Length )
	{
		for (var t = 0; t < string_len; t++)
		{
			if (iChars.indexOf(string.charAt(t)) != -1)
			{
				alert("Please Enter "+Text+" In Integer!.");
				document.getElementById(Id).focus();
				document.getElementById(Id).style.backgroundColor=color;
				document.getElementById(Id).value="";
				return false;
			}
		}
	}
	
	if (string_len > Length)
	{
		for (var t = Length+1; t < string_len; t++)
		{
			if (iChars.indexOf(string.charAt(t)) != -1)
			{
				alert("Please Enter "+Text+" In Integer!.");
				document.getElementById(Id).focus();
				document.getElementById(Id).style.backgroundColor=color;
				document.getElementById(Id).value="";
				return false;
			}
		}
	}
}


function Amount_Format(Id, Length, Text)
{
	var M_Value = document.getElementById(Id).value;
	var string_len = document.getElementById(Id).value.length;
	var string = document.getElementById(Id).value;
	var iChars = "*ASDFGHJKLZXCVBNMQWERTYUIOPasdfghjklzxcvbnmqwertyuiop|\":<>[]{}`\';()@&$#%_-=+*";
	
	var M_string_len = document.getElementById(Id).value.length;
	//AmountFieldLength = AmountFieldLength + Length
	
		M_Value = document.getElementById(Id).value;
		M_string_len = document.getElementById(Id).value.length;
		if (M_string_len == Length)
		{
		String_1 = M_Value.substr(AmountFieldLength,Length);
		String_2 = M_Value.substr(Length,M_string_len);
		document.getElementById(Id).value=String_1+','+String_2;
		Length =Length + Length;
		}

	
	if (string_len <= Length )
	{
		for (var t = 0; t < string_len; t++)
		{
			if (iChars.indexOf(string.charAt(t)) != -1)
			{
				alert("Please Enter "+Text+" In Integer!.");
				document.getElementById(Id).focus();
				document.getElementById(Id).style.backgroundColor=color;
				document.getElementById(Id).value="";
				return false;
			}
		}
	}
	
	if (string_len > Length)
	{
		for (var t = Length+1; t < string_len; t++)
		{
			if (iChars.indexOf(string.charAt(t)) != -1)
			{
				alert("Please Enter "+Text+" In Integer!.");
				document.getElementById(Id).focus();
				document.getElementById(Id).style.backgroundColor=color;
				document.getElementById(Id).value="";
				return false;
			}
		}
	}
}


function UploadFile(file_Path, Id)
{
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		  {
		  alert ("Your browser does not support AJAX!");
		  return;
		  } 
		var url="./AjaxClass/UploadFileExist.php";
		url=url+"?q="+file_Path+"&Id="+Id;
		xmlHttp.onreadystatechange=stateChanged_UP;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
}

function stateChanged_UP()
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		total_str=xmlHttp.responseText;
		ID_Pos1=total_str.indexOf("ID-")+3;
		ID_Pos2=total_str.indexOf("-ID");
		ID=total_str.slice(ID_Pos1,ID_Pos2);
		
		total_str=xmlHttp.responseText;
		CON_Pos1=total_str.indexOf("CON-")+4;
		CON_Pos2=total_str.indexOf("-CON");
		CON=total_str.slice(CON_Pos1,CON_Pos2);
		
		if (CON == "0")
		{
			alert("Please Enter Correct Path!.");
			document.getElementById(ID).focus();
			//document.getElementById(ID).select();
			document.getElementById(ID).style.backgroundColor=color;
			return i=1000;
		}
	}
}

function Public_Validation(Id , Type ,Text ,SType, P1)
{
	switch (SType)
	{
		case "Alphanumeric":
			if(document.getElementById(Id).value == "")
			{
				alert("Please "+ Type +" "+ Text +"!.");
				document.getElementById(Id).focus();
				document.getElementById(Id).style.backgroundColor=color;
				//document.getElementById(Id).select();
				return i=1000;
			}
			else
			{	
				document.getElementById(Id).style.backgroundColor=Rcolor;
				if (isProper(Id) == false)
				{
					alert('Please enter a proper value for the "' + Text +'" field.'); 
					document.getElementById(Id).focus();
					//document.getElementById(Id).select();
					document.getElementById(Id).style.backgroundColor=color;
					return i=1000;
				}
				else
				{
					document.getElementById(Id).style.backgroundColor=Rcolor;
				}
			}
		break;
		
		case "All_Data":
			if(document.getElementById(Id).value == "")
			{
				alert("Please "+ Type +" "+ Text +"!.");
				document.getElementById(Id).focus();
				document.getElementById(Id).style.backgroundColor=color;
				//document.getElementById(Id).select();
				return i=1000;
			}
			else
			{	
				document.getElementById(Id).style.backgroundColor=Rcolor;
			}
		break;
		
		case "Date":
			if(document.getElementById(Id).value == ""){
			alert("Please "+ Type +" "+ Text +"!.");
			document.getElementById(Id).focus();
			//document.getElementById(Id).select();
			document.getElementById(Id).style.backgroundColor=color;
			return i=1000;
			}
			else
			{
				document.getElementById(Id).style.backgroundColor=Rcolor;
				var DateValue = document.getElementById(Id).value;
				if (isDate(DateValue) == false)
				{
					document.getElementById(Id).focus();
					//document.getElementById(Id).select();
					document.getElementById(Id).style.backgroundColor=color;
					return i=1000;
				}
				else
				{
					document.getElementById(Id).style.backgroundColor=Rcolor;	
				}
			}
		break;
		
		case "Integer":
			if(document.getElementById(Id).value == ""){
			alert("Please "+ Type +" "+ Text +"!.");
			document.getElementById(Id).focus();
			//document.getElementById(Id).select();
			document.getElementById(Id).style.backgroundColor=color;
			return i=1000;
			}
			else
			{
			document.getElementById(Id).style.backgroundColor=Rcolor;
			InterValue = document.getElementById(Id).value;
			 	if (IntegerValue(InterValue) == false)
			   	{
					alert("Please "+ Type +" "+ Text +" in "+ SType +"!.");
					document.getElementById(Id).focus();
					//document.getElementById(Id).select();
					document.getElementById(Id).style.backgroundColor=color;
					return i=1000;
			   	}
				else
				{
					document.getElementById(Id).style.backgroundColor=Rcolor;	
				}
			}
		break;
		
		case "ID_Card":
			if(document.getElementById(Id).value == ""){
			alert("Please "+ Type +" "+ Text +"!.");
			document.getElementById(Id).focus();
			//document.getElementById(Id).select();
			document.getElementById(Id).style.backgroundColor=color;
			return i=1000;
			}
			else
			{
			document.getElementById(Id).style.backgroundColor=Rcolor;
			InterValue = document.getElementById(Id).value;
			InterValue_Split = InterValue.split("-");
			Count_0 = InterValue_Split['0'].length;
			if (InterValue_Split.length != 3) {
				alert("Please "+ Type +" "+ Text +" in Format 'xxxxx-xxxxxxx-x' !.");
				document.getElementById(Id).focus();
				document.getElementById(Id).style.backgroundColor=color;
				return i=1000;
			}
			
			if (Count_0 != 5) {
				alert("Please "+ Type +" "+ Text +" in Format 'xxxxx-xxxxxxx-x' !.");
				document.getElementById(Id).focus();
				document.getElementById(Id).style.backgroundColor=color;
				return i=1000;
			}
			
			Count_1 = InterValue_Split['1'].length;
			if (Count_1 != 7) {
				alert("Please "+ Type +" "+ Text +" in Format 'xxxxx-xxxxxxx-x' !.");
				document.getElementById(Id).focus();
				document.getElementById(Id).style.backgroundColor=color;
				return i=1000;
			}
			
			Count_2 = InterValue_Split['2'].length;
			if (Count_2 != 1) {
				alert("Please "+ Type +" "+ Text +" in Format 'xxxxx-xxxxxxx-x' !.");
				document.getElementById(Id).focus();
				document.getElementById(Id).style.backgroundColor=color;
				return i=1000;
			}
					
			 	if (IntegerValue(InterValue_Split['0']) == false)
			   	{
					alert("Please "+ Type +" "+ Text +" in Integer!.");
					alert("Please "+ Type +" "+ Text +" in Format 'xxxxx-xxxxxxx-x' !.");
					document.getElementById(Id).focus();
					//document.getElementById(Id).select();
					document.getElementById(Id).style.backgroundColor=color;
					return i=1000;
			   	} else if (IntegerValue(InterValue_Split['1']) == false)
			   	{
					alert("Please "+ Type +" "+ Text +" in Integer!.");
					alert("Please "+ Type +" "+ Text +" in Format 'xxxxx-xxxxxxx-x' !.");
					document.getElementById(Id).focus();
					//document.getElementById(Id).select();
					document.getElementById(Id).style.backgroundColor=color;
					return i=1000;
			   	} else if (IntegerValue(InterValue_Split['2']) == false)
			   	{
					alert("Please "+ Type +" "+ Text +" in Integer!.");
					alert("Please "+ Type +" "+ Text +" in Format 'xxxxx-xxxxxxx-x' !.");
					document.getElementById(Id).focus();
					//document.getElementById(Id).select();
					document.getElementById(Id).style.backgroundColor=color;
					return i=1000;
			   	} else {
					document.getElementById(Id).style.backgroundColor=Rcolor;	
				}
			}
		break;
		
		case "Phone_Number":
			if(document.getElementById(Id).value == ""){
			alert("Please "+ Type +" "+ Text +"!.");
			document.getElementById(Id).focus();
			//document.getElementById(Id).select();
			document.getElementById(Id).style.backgroundColor=color;
			return i=1000;
			}
			else
			{
			document.getElementById(Id).style.backgroundColor=Rcolor;
			InterValue = document.getElementById(Id).value;
			InterValue_Split = InterValue.split("-");
			if (InterValue_Split.length != 3) {
				alert("Please "+ Type +" "+ Text +" in Format '00xx-xxx-xxxxxxxx' !.");
				document.getElementById(Id).focus();
				document.getElementById(Id).style.backgroundColor=color;
				return i=1000;
			}
			
			Count_0 = InterValue_Split['0'].length;
			if (Count_0 != 4) {
				alert("Please "+ Type +" "+ Text +" in Format '00xx-xxx-xxxxxxxx' !.");
				document.getElementById(Id).focus();
				document.getElementById(Id).style.backgroundColor=color;
				return i=1000;
			}
			
			Count_1 = InterValue_Split['1'].length;
			if (Count_1 != 3) {
				alert("Please "+ Type +" "+ Text +" in Format '00xx-xxx-xxxxxxxx' !.");
				document.getElementById(Id).focus();
				document.getElementById(Id).style.backgroundColor=color;
				return i=1000;
			}
			
			Count_2 = InterValue_Split['2'].length;
			if (Count_2 != 8) {
				alert("Please "+ Type +" "+ Text +" in Format '00xx-xxx-xxxxxxxx' !.");
				document.getElementById(Id).focus();
				document.getElementById(Id).style.backgroundColor=color;
				return i=1000;
			}
					
			 	if (IntegerValue(InterValue_Split['0']) == false)
			   	{
					alert("Please "+ Type +" "+ Text +" in Integer!.");
					alert("Please "+ Type +" "+ Text +" in Format '00xx-xxx-xxxxxxxx' !.");
					document.getElementById(Id).focus();
					//document.getElementById(Id).select();
					document.getElementById(Id).style.backgroundColor=color;
					return i=1000;
			   	} else if (IntegerValue(InterValue_Split['1']) == false)
			   	{
					alert("Please "+ Type +" "+ Text +" in Integer!.");
					alert("Please "+ Type +" "+ Text +" in Format '00xx-xxx-xxxxxxxx' !.");
					document.getElementById(Id).focus();
					//document.getElementById(Id).select();
					document.getElementById(Id).style.backgroundColor=color;
					return i=1000;
			   	} else if (IntegerValue(InterValue_Split['2']) == false)
			   	{
					alert("Please "+ Type +" "+ Text +" in Integer!.");
					alert("Please "+ Type +" "+ Text +" in Format '00xx-xxx-xxxxxxxx' !.");
					document.getElementById(Id).focus();
					//document.getElementById(Id).select();
					document.getElementById(Id).style.backgroundColor=color;
					return i=1000;
			   	} else {
					document.getElementById(Id).style.backgroundColor=Rcolor;	
				}
			}
		break;
		
		case "Cell_Number":
			if(document.getElementById(Id).value == ""){
			alert("Please "+ Type +" "+ Text +"!.");
			document.getElementById(Id).focus();
			//document.getElementById(Id).select();
			document.getElementById(Id).style.backgroundColor=color;
			return i=1000;
			}
			else
			{
			document.getElementById(Id).style.backgroundColor=Rcolor;
			InterValue = document.getElementById(Id).value;
			InterValue_Split = InterValue.split("-");
			if (InterValue_Split.length != 3) {
				alert("Please "+ Type +" "+ Text +" in Format '00xx-xxx-xxxxxxx' !.");
				document.getElementById(Id).focus();
				document.getElementById(Id).style.backgroundColor=color;
				return i=1000;
			}
			
			Count_0 = InterValue_Split['0'].length;
			if (Count_0 != 4) {
				alert("Please "+ Type +" "+ Text +" in Format '00xx-xxx-xxxxxxx' !.");
				document.getElementById(Id).focus();
				document.getElementById(Id).style.backgroundColor=color;
				return i=1000;
			}
			
			Count_1 = InterValue_Split['1'].length;
			if (Count_1 != 3) {
				alert("Please "+ Type +" "+ Text +" in Format '00xx-xxx-xxxxxxx' !.");
				document.getElementById(Id).focus();
				document.getElementById(Id).style.backgroundColor=color;
				return i=1000;
			}
			
			Count_2 = InterValue_Split['2'].length;
			if (Count_2 != 7) {
				alert("Please "+ Type +" "+ Text +" in Format '00xx-xxx-xxxxxxx' !.");
				document.getElementById(Id).focus();
				document.getElementById(Id).style.backgroundColor=color;
				return i=1000;
			}
					
			 	if (IntegerValue(InterValue_Split['0']) == false)
			   	{
					alert("Please "+ Type +" "+ Text +" in Integer!.");
					alert("Please "+ Type +" "+ Text +" in Format '00xx-xxx-xxxxxxx' !.");
					document.getElementById(Id).focus();
					//document.getElementById(Id).select();
					document.getElementById(Id).style.backgroundColor=color;
					return i=1000;
			   	} else if (IntegerValue(InterValue_Split['1']) == false)
			   	{
					alert("Please "+ Type +" "+ Text +" in Integer!.");
					alert("Please "+ Type +" "+ Text +" in Format '00xx-xxx-xxxxxxx' !.");
					document.getElementById(Id).focus();
					//document.getElementById(Id).select();
					document.getElementById(Id).style.backgroundColor=color;
					return i=1000;
			   	} else if (IntegerValue(InterValue_Split['2']) == false)
			   	{
					alert("Please "+ Type +" "+ Text +" in Integer!.");
					alert("Please "+ Type +" "+ Text +" in Format '00xx-xxx-xxxxxxx' !.");
					document.getElementById(Id).focus();
					//document.getElementById(Id).select();
					document.getElementById(Id).style.backgroundColor=color;
					return i=1000;
			   	} else {
					document.getElementById(Id).style.backgroundColor=Rcolor;	
				}
			}
		break;
		
		case "Integer_NComp":
			if(document.getElementById(Id).value != ""){
			InterValue = document.getElementById(Id).value;
			 	if (IntegerValue(InterValue) == false)
			   	{
					alert("Please "+ Type +" "+ Text +" in Integer!.");
					document.getElementById(Id).focus();
					//document.getElementById(Id).select();
					document.getElementById(Id).style.backgroundColor=color;
					return i=1000;
			   	}
				else
				{
					document.getElementById(Id).style.backgroundColor=Rcolor;	
				}
			}
		break;
		
		case "UploadFile":
			/*if(document.getElementById(Id).value != "")
			{
				Upload_Path = document.getElementById(Id).value;
				UploadFile(Upload_Path, Id);
			}*/
			//checkfile(Id);
			/*if (checkfile(Id) == false)
			{
				alert("Please "+ Type +" "+ Text +" !.");
				document.getElementById(Id).focus();
				document.getElementById(Id).style.backgroundColor=color;
				return i=1000;
			}*/
			if(document.getElementById(Id).value == "")
			{
				alert("Please "+ Type +" "+ Text +"!.");
				document.getElementById(Id).focus();
				document.getElementById(Id).style.backgroundColor=color;
				//document.getElementById(Id).select();
				return i=1000;
			}
		break;
		
		case "Email":
			if(document.getElementById(Id).value == ""){
			alert("Please enter e-mail address!.");
			document.getElementById(Id).focus();
			return i=1000;
			}
			else if(document.getElementById(Id).value.indexOf('@') == -1){
			alert("Please enter a valid e-mail address. Missing '@' sign!.");
			document.getElementById(Id).focus();
			return i=1000;
			}
			else if(document.getElementById(Id).value.indexOf('.') == -1){
			alert("Please enter a valid e-mail address.\nMissing '.' in your e-mail address!.");
			document.getElementById(Id).focus();
			return i=1000;
			}
			else
			{
			document.getElementById(Id).style.backgroundColor=Rcolor;	
			}
		break;
		
		case "Phone":
		var M_Value = document.getElementById(Id).value;
		if (M_Value != "")
		{
			if (Phone_Format(Id, 4, Text) == false)
			{
			return i=1000;
			}
			else
			{
				if (document.getElementById(Id).value.length < P1)
				{
					alert("Please Complete "+ Text +" Numbers!.");
					document.getElementById(Id).focus();
					document.getElementById(Id).style.backgroundColor=color;
					return i=1000;
				}	
			}
		}
		else
		{
			alert("Please "+ Type +" "+ Text +"!.");
			document.getElementById(Id).focus();
			//document.getElementById(Id).select();
			document.getElementById(Id).style.backgroundColor=color;
			return i=1000;
		}
		break;
		
		default :
		alert("Invalid Parameter");
		break;
	}

}

function Validation_Information(TheForm, Start , Stop, Action, Image_Option)
{
	for (i=Start; i <= Stop; i++)
	{
		switch (i)
		{
			case 1:
			if (Image_Option == "3")
			Public_Validation("Title" , "Select" ,"Product Name" ,"Alphanumeric");
			else
			Public_Validation("Title" , "Enter" ,"Title" ,"Alphanumeric");
			break;
			
			case 2:
			if ((Image_Option != "2") && (Image_Option != "3"))
			Public_Validation("Description" , "Enter" ,"Description" ,"All_Data");
			break;
			
			case 3:
			if ((Action == 0) && ( (Image_Option == "1") || (Image_Option == "2") || (Image_Option == "3")) )
			{
			Public_Validation("Image_Src" , "Select" ,"Image" ,"UploadFile");
			}
			break;
			
			case 4:
			submitForm(TheForm);
			break;
		}
	}
	if (i > 1000)
	return false;

}

function Validation_Manage_Card(TheForm, Start , Stop, Action, Image_Option)
{
	Start = 0;
	Stop = 20;
	for (i=Start; i <= Stop; i++)
	{
		switch (i)
		{
			case 1:
			Public_Validation("Card_Name" , "Select" ,"Card Name" ,"Alphanumeric");
			break;
			
			case 2:
			//Public_Validation("Selected_Option2" , "Select" ,"Sale Person" ,"Alphanumeric");
			break;
			
			case 3:
			Public_Validation("First_Name" , "Enter" ,"First Name" ,"Alphanumeric");
			break;
			
			case 4:
			//Public_Validation("Title2" , "Enter" ,"Middle Name" ,"Alphanumeric");
			break;
			
			case 5:
			Public_Validation("Last_Name" , "Enter" ,"Last Name" ,"Alphanumeric");
			break;
			
			case 6:
			//Public_Validation("Title4" , "Enter" ,"Company Name" ,"Alphanumeric");
			break;
			
			case 7:
			//Public_Validation("Title5" , "Enter" ,"Designation" ,"Alphanumeric");
			break;
			
			case 8:
			//Public_Validation("Title6" , "Enter" ,"Office Address" ,"Alphanumeric");
			break;
			
			case 9:
			Public_Validation("Home_Address" , "Enter" ,"Home Address" ,"All_Data");
			break;
			
			case 10:
			Public_Validation("Cell_Number" , "Enter" ,"Cell Number" ,"Cell_Number");
			break;
			
			case 11:
			Public_Validation("E_Mail_Address" , "Enter" ,"E-Mail Address" ,"Email");
			break;
			
			case 12:
			//if (document.getElementById("Complimentary_Card").checked == false)
			//Public_Validation("Selected_Option3" , "Select" ,"Mode of Payments" ,"Alphanumeric");
			break;
			
			case 13:
			//if ((document.getElementById("Complimentary_Card").checked == false) && (document.getElementById("Selected_Option3").value == "Cash"))
			//Public_Validation("Title15" , "Enter" ,"Receipt No" ,"Alphanumeric");
			break;
			
			case 14:
			//if ((document.getElementById("Complimentary_Card").checked == false) && (document.getElementById("Selected_Option3").value == "Cash"))
			//Public_Validation("Title8" , "Select" ,"Date" ,"All_Data");
			break;
			
			case 15:
			//if ((document.getElementById("Complimentary_Card").checked == false) && (document.getElementById("Selected_Option3").value == "Credit Card"))
			//Public_Validation("Credit_Card" , "Select" ,"Credit Card" ,"Alphanumeric");
			break;
			
			case 16:
			//if ((document.getElementById("Complimentary_Card").checked == false) && (document.getElementById("Selected_Option3").value == "Credit Card"))
			//Public_Validation("Name_Of_Credit_Card_Holder" , "Enter" ,"Name Of Credit Card Holder" ,"All_Data");
			break;
			
			case 17:
			//if ((document.getElementById("Complimentary_Card").checked == false) && (document.getElementById("Selected_Option3").value == "Credit Card"))
			//Public_Validation("Expiry_Date" , "Select" ,"Expiry Date" ,"All_Data");
			break;
			
			case 18:
			//if ((document.getElementById("Complimentary_Card").checked == false) && (document.getElementById("Selected_Option3").value == "Credit Card"))
			//Public_Validation("Approval_Code" , "Select" ,"Approval Code" ,"All_Data");
			break;
			
			case 19:
			//if ((document.getElementById("Complimentary_Card").checked == false) && (document.getElementById("Selected_Option3").value == "Credit Card")) {
					/*Public_Validation("Credit_Card_No1" , "Enter" ,"Credit Card No" ,"All_Data");
					Public_Validation("Credit_Card_No2" , "Enter" ,"Credit Card No" ,"All_Data");
					Public_Validation("Credit_Card_No3" , "Enter" ,"Credit Card No" ,"All_Data");
					Public_Validation("Credit_Card_No4" , "Enter" ,"Credit Card No" ,"All_Data");*/
			//}
			break;
			
			case 20:
			//document.getElementById("Submit").type = "submit";
			submitForm(TheForm);
			break;
		}
	}
	if (i > 1000)
	return false;

}

function Validation_Manage_Renew_Card(TheForm, Start , Stop, Action, Image_Option)
{
	Start = 0;
	Stop = 20;
	for (i=Start; i <= Stop; i++)
	{
		switch (i)
		{
			case 1:
			Public_Validation("Selected_Option1" , "Select" ,"Client Name" ,"Alphanumeric");
			break;
			
			case 2:
			Public_Validation("Selected_Option2" , "Select" ,"Sale Person" ,"Alphanumeric");
			break;
			
			case 3:
			//Public_Validation("Title1" , "Enter" ,"First Name" ,"Alphanumeric");
			break;
			
			case 4:
			//Public_Validation("Title2" , "Enter" ,"Middle Name" ,"Alphanumeric");
			break;
			
			case 5:
			//Public_Validation("Title3" , "Enter" ,"Last Name" ,"Alphanumeric");
			break;
			
			case 6:
			//Public_Validation("Title4" , "Enter" ,"Company Name" ,"Alphanumeric");
			break;
			
			case 7:
			//Public_Validation("Title5" , "Enter" ,"Designation" ,"Alphanumeric");
			break;
			
			case 8:
			//Public_Validation("Title6" , "Enter" ,"Office Address" ,"Alphanumeric");
			break;
			
			case 9:
			//Public_Validation("Title9" , "Enter" ,"Home Address" ,"Alphanumeric");
			break;
			
			case 10:
			//Public_Validation("Title10" , "Enter" ,"Telephone No" ,"Phone_Number");
			break;
			
			case 11:
			//Public_Validation("Title11" , "Enter" ,"E-Mail Address" ,"Email");
			break;
			
			case 12:
			if (document.getElementById("Title11_1").checked == false)
			Public_Validation("Selected_Option3" , "Select" ,"Mode of Payments" ,"Alphanumeric");
			break;
			
			case 13:
			if ((document.getElementById("Title11_1").checked == false) && (document.getElementById("Selected_Option3").value == "Cash"))
			Public_Validation("Title15" , "Enter" ,"Receipt No" ,"Alphanumeric");
			break;
			
			case 14:
			if ((document.getElementById("Title11_1").checked == false) && (document.getElementById("Selected_Option3").value == "Cash"))
			Public_Validation("Title8" , "Select" ,"Date" ,"All_Data");
			break;
			
			case 15:
			if ((document.getElementById("Title11_1").checked == false) && (document.getElementById("Selected_Option3").value == "Credit Card"))
			Public_Validation("Selected_Option4" , "Select" ,"Credit Card" ,"Alphanumeric");
			break;
			
			case 16:
			if ((document.getElementById("Title11_1").checked == false) && (document.getElementById("Selected_Option3").value == "Credit Card"))
			Public_Validation("Title12" , "Enter" ,"Name Of Credit Card Holder" ,"All_Data");
			break;
			
			case 17:
			if ((document.getElementById("Title11_1").checked == false) && (document.getElementById("Selected_Option3").value == "Credit Card"))
			Public_Validation("Title7" , "Select" ,"Expiry Date" ,"All_Data");
			break;
			
			case 18:
			if ((document.getElementById("Title11_1").checked == false) && (document.getElementById("Selected_Option3").value == "Credit Card"))
			Public_Validation("Title13" , "Select" ,"Approval Code" ,"All_Data");
			break;
			
			case 19:
			if ((document.getElementById("Title11_1").checked == false) && (document.getElementById("Selected_Option3").value == "Credit Card")) {
					Public_Validation("Title14" , "Enter" ,"Credit Card No" ,"All_Data");
					Public_Validation("Title14_2" , "Enter" ,"Credit Card No" ,"All_Data");
					Public_Validation("Title14_3" , "Enter" ,"Credit Card No" ,"All_Data");
					Public_Validation("Title14_4" , "Enter" ,"Credit Card No" ,"All_Data");
				}
			break;
			
			case 20:
			//document.getElementById("Submit").type = "submit";
			submitForm(TheForm);
			break;
		}
	}
	if (i > 1000)
	return false;

}


function Validation_Commission_Tax(TheForm, Start , Stop, Action, Image_Option)
{
	Start = 0;
	Stop = 3;
	for (i=Start; i <= Stop; i++)
	{
		switch (i)
		{
			case 1:
			Public_Validation("Title1" , "Enter" ,"Tax %" ,"Integer");
			break;
			
			case 2:
			Public_Validation("Title2" , "Enter" ,"Sale Person Card Limit" ,"Integer");
			break;
			
			case 3:
			//document.getElementById("Submit").type = "submit";
			submitForm(TheForm);
			break;
			
		}
	}
	
	if (i > 1000)
	return false;

}

function Validation_Year (TheForm, Start , Stop, Action, Image_Option)
{
	Start = 0;
	Stop = 2;
	for (i=Start; i <= Stop; i++)
	{
		switch (i)
		{
			case 1:
			Public_Validation("Title1" , "Enter" ,"Year" ,"Integer");
			break;
			
			case 2:
			//document.getElementById("Submit").type = "submit";
			submitForm(TheForm);
			break;
		}
	}
	if (i > 1000)
	return false;
}

function Validation_Month(TheForm, Start , Stop, Action, Image_Option)
{
	Start = 0;
	Stop = 4;
	for (i=Start; i <= Stop; i++)
	{
		switch (i)
		{
			case 1:
			Public_Validation("Title1" , "Enter" ,"Month Name" ,"Alphanumeric");
			break;
			
			case 2:
			Public_Validation("Title2" , "Enter" ,"Month Number" ,"Integer");
			break;
			
			case 3:
			Public_Validation("Title3" , "Enter" ,"Number of Days" ,"Integer");
			break;
			
			case 4:
			//document.getElementById("Submit").type = "submit";
			submitForm(TheForm);
			break;
		}
	}
	if (i > 1000)
	return false;
}

function Validation_Mode_of_Payments(TheForm, Start , Stop, Action, Image_Option)
{
	Start = 0;
	Stop = 3;
	for (i=Start; i <= Stop; i++)
	{
		switch (i)
		{
			case 1:
			//Public_Validation("Title1" , "Enter" ,"Month Name" ,"Alphanumeric");
			break;
			
			case 2:
			//Public_Validation("Title2" , "Enter" ,"Month Number" ,"Integer");
			break;
			
			case 3:
			//document.getElementById("Submit").type = "submit";
			submitForm(TheForm);
			break;
		}
	}
	if (i > 1000)
	return false;
}

function Validation_Group_Type(TheForm, Start , Stop, Action, Image_Option)
{
	Start = 0;
	Stop = 3;
	for (i=Start; i <= Stop; i++)
	{
		switch (i)
		{
			case 1:
			Public_Validation("Title1" , "Enter" ,"Group Type" ,"Alphanumeric");
			break;
			
			case 2:
			//Public_Validation("Title2" , "Enter" ,"Month Number" ,"Integer");
			break;
			
			case 3:
			//document.getElementById("Submit").type = "submit";
			submitForm(TheForm);
			break;
		}
	}
	if (i > 1000)
	return false;
}

function Validation_Member_Account(TheForm, Start , Stop, Action, Image_Option)
{
	Start = 0;
	Stop = 8;
	for (i=Start; i <= Stop; i++)
	{
		switch (i)
		{
			
			case 1:
			Public_Validation("Selected_Option1" , "Select" ,"Group Type" ,"Alphanumeric");
			break;
			
			case 2:
			Public_Validation("Title1" , "Enter" ,"First Name" ,"Alphanumeric");
			break;
			
			case 3:
			Public_Validation("Title2" , "Enter" ,"Last Name" ,"Alphanumeric");
			break;
			
			case 4:
			Public_Validation("Title3" , "Enter" ,"Cell No" ,"Cell_Number");
			break;
			
			case 5:
			Public_Validation("Title4" , "Enter" ,"CNIC" ,"ID_Card");
			break;
			
			case 6:
			Public_Validation("Title5" , "Enter" ,"Email ID (User Name)" ,"Email");
			break;
			
			case 7:
			Public_Validation("Title6" , "Enter" ,"Password" ,"All_Data");
			break;
			
			case 8:
			//document.getElementById("Submit").type = "submit";
			submitForm(TheForm);
			break;
		}
	}
	if (i > 1000)
	return false;
}

function Validation_Assigning_Budget(TheForm, Start , Stop, Action, Image_Option)
{
	Start = 0;
	Stop = 4;
	for (i=Start; i <= Stop; i++)
	{
		switch (i)
		{
			
			case 1:
			Public_Validation("Selected_Option1" , "Select" ,"Year" ,"Alphanumeric");
			break;
			
			case 2:
			Public_Validation("Selected_Option2" , "Select" ,"Month" ,"Alphanumeric");
			break;
			
			case 3:
			Public_Validation("Title1" , "Enter" ,"Assigning Budget" ,"Integer");
			break;
			
			case 4:
			//document.getElementById("Submit").type = "submit";
			submitForm(TheForm);
			break;
		}
	}
	if (i > 1000)
	return false;
}

function Validation_Target_Revenue(TheForm, Start , Stop, Action, Image_Option)
{
	Start = 0;
	Stop = 4;
	for (i=Start; i <= Stop; i++)
	{
		switch (i)
		{
			
			case 1:
			Public_Validation("Selected_Option1" , "Select" ,"Year" ,"Alphanumeric");
			break;
			
			case 2:
			Public_Validation("Selected_Option2" , "Select" ,"Month" ,"Alphanumeric");
			break;
			
			case 3:
			Public_Validation("Title1" , "Enter" ,"Target Revenue" ,"Integer");
			break;
			
			case 4:
			//document.getElementById("Submit").type = "submit";
			submitForm(TheForm);
			break;
		}
	}
	if (i > 1000)
	return false;
}

function Validation_Expenses(TheForm, Start , Stop, Action, Image_Option)
{
	Start = 0;
	Stop = 4;
	for (i=Start; i <= Stop; i++)
	{
		switch (i)
		{
			case 1:
			Public_Validation("Title1" , "Enter" ,"Title" ,"All_Data");
			break;
			
			case 2:
			Public_Validation("Title2" , "Enter" ,"Expense Amount" ,"Integer");
			break;
			
			case 3:
			Public_Validation("Title7" , "Select" ,"Date" ,"All_Data");
			break;
			
			case 4:
			//document.getElementById("Submit").type = "submit";
			submitForm(TheForm);
			break;
		}
	}
	if (i > 1000)
	return false;
}

function Validation_Expenses(TheForm, Start , Stop, Action, Image_Option)
{
	Start = 0;
	Stop = 4;
	for (i=Start; i <= Stop; i++)
	{
		switch (i)
		{
			case 1:
			Public_Validation("Title1" , "Enter" ,"Title" ,"All_Data");
			break;
			
			case 2:
			Public_Validation("Title2" , "Enter" ,"Expense Amount" ,"Integer");
			break;
			
			case 3:
			Public_Validation("Title7" , "Select" ,"Date" ,"All_Data");
			break;
			
			case 4:
			//document.getElementById("Submit").type = "submit";
			submitForm(TheForm);
			break;
		}
	}
	if (i > 1000)
	return false;
}

function Validation_Card_Name_Price(TheForm, Start , Stop, Action, Image_Option)
{
	Start = 0;
	Stop = 6;
	for (i=Start; i <= Stop; i++)
	{
		switch (i)
		{
			case 1:
			Public_Validation("Title1" , "Enter" ,"Card Name" ,"All_Data");
			break;
			
			case 2:
			Public_Validation("Title2" , "Enter" ,"Price" ,"Integer");
			break;
			
			case 3:
			Public_Validation("Title3" , "Enter" ,"Commission %" ,"Integer");
			break;
			
			case 4:
			Public_Validation("Title4" , "Enter" ,"Renew Price" ,"Integer");
			break;
			
			case 5:
			Public_Validation("Title5" , "Enter" ,"Renew Commission %" ,"Integer");
			break;
			
			case 6:
			//document.getElementById("Submit").type = "submit";
			submitForm(TheForm);
			break;
		}
	}
	if (i > 1000)
	return false;
}

function Validation_BudgetReport(TheForm, Start , Stop, Action, Image_Option)
{
	Start = 0;
	Stop = 3;
	for (i=Start; i <= Stop; i++)
	{
		switch (i)
		{
			case 1:
			Public_Validation("Year" , "Select" ,"Year" ,"All_Data");
			break;
			
			case 2:
			Public_Validation("Month" , "Select" ,"Month" ,"All_Data");
			break;
			
			case 3:
			//document.getElementById("Submit").type = "submit";
			submitForm(TheForm);
			break;
		}
	}
	if (i > 1000)
	return false;
}


function trDisplayValidation(){
	Payment_Type = document.getElementById("Selected_Option3").value;
	if (Payment_Type == "Cash")	{
		document.getElementById("t_6").style.display = "";
		document.getElementById("t_7").style.display = "";
	} else {
		document.getElementById("t_6").style.display = "none";
		document.getElementById("t_7").style.display = "none";
	}
	
	if (Payment_Type == "Credit Card")	{
		document.getElementById("t_1").style.display = "";
		document.getElementById("t_2").style.display = "";
		document.getElementById("t_3").style.display = "";
		document.getElementById("t_4").style.display = "";
		document.getElementById("t_5").style.display = "";
	} else {
		document.getElementById("t_1").style.display = "none";
		document.getElementById("t_2").style.display = "none";
		document.getElementById("t_3").style.display = "none";
		document.getElementById("t_4").style.display = "none";
		document.getElementById("t_5").style.display = "none";
	}
	
}
function trDisplayValidation_Compiment_Check(){
	
	
	Payment_Type = document.getElementById("Title11_1").checked;
	
	if (Payment_Type == true)	{
		document.getElementById("T_Main").style.display = "none";
		document.getElementById("t_6").style.display = "none";
		document.getElementById("t_7").style.display = "none";
		document.getElementById("Selected_Option3").value= "";
	} else {
		document.getElementById("T_Main").style.display = "";
		document.getElementById("Selected_Option3").value= "";
		document.getElementById("t_6").style.display = "none";
		document.getElementById("t_7").style.display = "none";
	}
	
	if (Payment_Type == true)	{
		document.getElementById("t_1").style.display = "none";
		document.getElementById("t_2").style.display = "none";
		document.getElementById("t_3").style.display = "none";
		document.getElementById("t_4").style.display = "none";
		document.getElementById("t_5").style.display = "none";
	} else {
		document.getElementById("t_1").style.display = "none";
		document.getElementById("t_2").style.display = "none";
		document.getElementById("t_3").style.display = "none";
		document.getElementById("t_4").style.display = "none";
		document.getElementById("t_5").style.display = "none";
	}


}


