var remail=/^([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+\.+[a-zA-Z0-9-]+|[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+\.+[a-zA-Z0-9-]+\.+[a-zA-Z0-9-]+)$/;
var checkIfAlphabet=/[a-zA-Z]/;
var checkifSymbol = /[^_a-zA-Z0-9]/;

var ccErrorNo = 0;
var ccErrors = new Array ()

ccErrors [0] = "Unknown card type";
ccErrors [1] = "No card number provided";
ccErrors [2] = "Credit card number is in invalid format";
ccErrors [3] = "Credit card number is invalid";
ccErrors [4] = "Credit card number has an inappropriate number of digits";

function isNumber(str) { 
	var n=/^[0-9]+$/;
	if (n.test(str))
	{
		return true;
	} else {
		return false;
	}
}
function loadSubmit() {
	document.getElementById('cmd_AddDesign').disabled=true;
ProgressImage = document.getElementById('progress_image');
document.getElementById("progress").style.visibility = "visible";
setTimeout("ProgressImage.src = ProgressImage.src",100);
return true;
}
function checkCreditCard (cardnumber, cardname) {

     
  // Array to hold the permitted card characteristics
  var cards = new Array();

  // Define the cards we support. You may add addtional card types.
  
  //  Name:      As in the selection box of the form - must be same as user's
  //  Length:    List of possible valid lengths of the card number for the card
  //  prefixes:  List of possible prefixes for the card
  //  checkdigit Boolean to say whether there is a check digit
  
  cards [0] = {name: "Visa", 
               length: "13,16", 
               prefixes: "4",
               checkdigit: true};
  cards [1] = {name: "Mastercard", 
               length: "16", 
               prefixes: "51,52,53,54,55",
               checkdigit: true};
  cards [2] = {name: "DinersClub", 
               length: "14,", 
               prefixes: "300,301,302,303,304,305,36,38",
               checkdigit: true};
  cards [3] = {name: "CarteBlanche", 
               length: "14", 
               prefixes: "300,301,302,303,304,305,36,38",
               checkdigit: true};
  cards [4] = {name: "Amex", 
               length: "15", 
               prefixes: "34,37",
               checkdigit: true};
  cards [5] = {name: "Discover", 
               length: "16", 
               prefixes: "6011",
               checkdigit: true};
  cards [6] = {name: "JCB", 
               length: "15,16", 
               prefixes: "3,1800,2131",
               checkdigit: true};
  cards [7] = {name: "Enroute", 
               length: "15", 
               prefixes: "2014,2149",
               checkdigit: true};
               
  // Establish card type
  var cardType = -1;
  for (var i=0; i<cards.length; i++) {

    // See if it is this card (ignoring the case of the string)
    if (cardname.toLowerCase () == cards[i].name.toLowerCase()) {
      cardType = i;
      break;
    }
  }
  
  // If card type not found, report an error
  if (cardType == -1) {
     ccErrorNo = 0;
     return false; 
  }
   
  // Ensure that the user has provided a credit card number
  if (cardnumber.length == 0)  {
     ccErrorNo = 1;
     return false; 
  }
  
  // Check that the number is numeric, although we do permit a space to occur  
  // every four digits. 
  var cardNo = cardnumber
  var cardexp = /^([0-9]{4})\s?([0-9]{4})\s?([0-9]{4})\s?([0-9]{1,4})$/;
  if (!cardexp.exec(cardNo))  {
     ccErrorNo = 2;
     return false; 
  }
    
  // Now remove any spaces from the credit card number
  cardexp.exec(cardNo);
  cardNo = RegExp.$1 + RegExp.$2 + RegExp.$3 + RegExp.$4;
       
  // Now check the modulus 10 check digit - if required
  if (cards[cardType].checkdigit) {
    var checksum = 0;                                  // running checksum total
    var mychar = "";                                   // next char to process
    var j = 1;                                         // takes value of 1 or 2
  
    // Process each digit one by one starting at the right
    var calc;
    for (i = cardNo.length - 1; i >= 0; i--) {
    
      // Extract the next digit and multiply by 1 or 2 on alternative digits.
      calc = Number(cardNo.charAt(i)) * j;
    
      // If the result is in two digits add 1 to the checksum total
      if (calc > 9) {
        checksum = checksum + 1;
        calc = calc - 10;
      }
    
      // Add the units element to the checksum total
      checksum = checksum + calc;
    
      // Switch the value of j
      if (j ==1) {j = 2} else {j = 1};
    } 
  
    // All done - if checksum is divisible by 10, it is a valid modulus 10.
    // If not, report an error.
    if (checksum % 10 != 0)  {
     ccErrorNo = 3;
     return false; 
    }
  }  

  // The following are the card-specific checks we undertake.
  var LengthValid = false;
  var PrefixValid = false; 
  var undefined; 

  // We use these for holding the valid lengths and prefixes of a card type
  var prefix = new Array ();
  var lengths = new Array ();
    
  // Load an array with the valid prefixes for this card
  prefix = cards[cardType].prefixes.split(",");
      
  // Now see if any of them match what we have in the card number
  for (i=0; i<prefix.length; i++) {
    var exp = new RegExp ("^" + prefix[i]);
    if (exp.test (cardNo)) PrefixValid = true;
  }
      
  // If it isn't a valid prefix there's no point at looking at the length
  if (!PrefixValid) {
     ccErrorNo = 3;
     return false; 
  }
    
  // See if the length is valid for this card
  lengths = cards[cardType].length.split(",");
  for (j=0; j<lengths.length; j++) {
    if (cardNo.length == lengths[j]) LengthValid = true;
  }
  
  // See if all is OK by seeing if the length was valid. We only check the 
  // length if all else was hunky dory.
  if (!LengthValid) {
     ccErrorNo = 4;
     return false; 
  };   
  
  // The credit card is in the required format.
  return true;
}
function checkValidDate(formNm) 
{
//formNm.cmb_Year.options[formNm.cmb_Year.selectedIndex].value;
month2 = formNm.month1.options[formNm.month1.selectedIndex].value;
year2 =  formNm.year1.options[formNm.year1.selectedIndex].value;

var today = new date();

var month1=today.getMonth();
var year1=today.getYear();



if (year2==year1)
{
	if (month2<month1)
	{
		alert("Expiry Month is invalid");
		formNm.month1.focus();
		return false;
	}
	
}

return true;
 
}


function testCreditCard(CardNumber,CardType,formNm) {
//	alert ("ccErrors");
 // myCardNo = document.getElementById('CardNumber').value;
 // myCardType = document.getElementById('CardType').value;
 myCardNo=CardNumber;
 myCardType=CardType;
 
  if (checkCreditCard (myCardNo,myCardType))
  {
  //  alert ("Credit card has a valid format")
  return true;
  } 
  else 
  {
	  alert (ccErrors[ccErrorNo]);
	  formNm.ccnumber.focus();	  
	  return false;
	  
  }
}/*============================================================================*/

function checkImageFormat(fileName) {
	var imageSrc = new String();
	imageSrc = fileName.value;
	imageFormat = imageSrc.slice(imageSrc.length-4);
	if(imageFormat != ".gif" && imageFormat != ".GIF"  && imageFormat != ".jpg"  && imageFormat != ".JPG" && imageFormat != ".jpeg" && imageFormat != ".JPEG") {
		return true;
	} else {
		return false;
	}
}

function checkEmail(fieldvalue) 
{
	if(remail.test(fieldvalue))
	{
		return false;
	} 
	else 
	{
		return true;
	}
}

function checkNumber(fieldvalue) 
{
	if(isNaN(fieldvalue)) 
	{
		return true;
	} 
	else 
	{
		return false;
	}
}

function checkIfSelected(formNm) 
{
	for (i=0;i<formNm.elements.length;i++) 
	{
		if(formNm.elements[i].type =="select-multiple")
		{
			if(formNm.elements[i].value == "") 
			{
				return true;
			}
			else 
			{
				return false;
			}
		}
	}
}

function checkIfIsChar(fieldvalue) 
{
	if(checkIfAlphabet.test(fieldvalue.charAt(0))) 
	{
		return false;
	} 
	else 
	{
		return true;
	}
}

function checkSpace(fieldvalue) 
{
	for(counter = 0;counter < fieldvalue.length;counter++) 
	{
		if(fieldvalue.charAt(counter) == " ") 
		{
			error = 1;
			break;
		} 
		else 
		{
			error = 0;
		}
	}
	if(error == 1) 
	{
		return true;
	} 
	else 
	{
		return false;
	}
}

function checkSymbol(fieldvalue) 
{
	for(counter = 0;counter < fieldvalue.length;counter++) 
	{
		if(checkifSymbol.test(fieldvalue.charAt(counter))) 
		{
			error = 1;
			break;
		} 
		else 
		{
			error = 0;
		}
	}
	
	if(error == 1) 
	{
		return true;
	} 
	else 
	{
		return false;
	}
}

function checkIfFirstLetterIsSymbol(fieldvalue) 
{
	if(checkifSymbol.test(fieldvalue.charAt(0))) 
	{
		error = 1;
	} 
	else 
	{
		error = 0;
	}

	if(error == 1) 
	{
		return true;
	} 
	else 
	{
		return false;
	}
}

function checkLength(fieldvalue) 
{
	if(fieldvalue.length < 6 ) 
	{
		return true;
	}
	else 
	{
		return false;
	}
}

function checkBlank(fieldvalue) 
{
	for(counter=0;counter < fieldvalue.length;counter++) 
	{
		if(fieldvalue.charAt(counter) == " ") 
		{
			continue;
		} 
		else 
		{
			break;
			return false;
		}
	}
	
	if(fieldvalue.length == counter) 
	{
		return true;
	}
}


function submitRegistrationForm(formNm) {
	if(formNm.txt_SignInName.value == "")
	{
		alert("Please enter your User Name");
		formNm.txt_SignInName.focus();
    	return false;

	} 
  	else if(checkIfIsChar(formNm.txt_SignInName.value)) 
	{
		alert("The first character of the User Name should be a character");
		formNm.txt_SignInName.focus();
    return false;
	} 
	
	else if(formNm.txt_Password.value == "") 
	{
		alert("Please enter your password");
		formNm.txt_Password.focus();
    return false;
	} 
	else if(checkBlank(formNm.txt_Password.value)) 
	{
		alert("Please enter your password");
		formNm.txt_Password.focus();
    return false;
	} 
	else if(checkLength(formNm.txt_Password.value)) 
	{
		alert("Password should be atleast 6 characters long");
		formNm.txt_Password.focus();
    return false;
	} 
	else if(checkSpace(formNm.txt_Password.value)) 
	{
		alert("Blank spaces are not allowed between the password");
		formNm.txt_Password.focus();
    return false;
	} 
	else if(checkSymbol(formNm.txt_Password.value)) 
	{
		alert("Only letters,numbers,or underscores are allowed");
		formNm.txt_Password.focus();
    return false;
	}
	 else if(formNm.txt_Password.value != formNm.txt_ReConfirmPassword.value)
	 {
		alert("Your passwords did not match.");
		formNm.txt_ReConfirmPassword.focus();
    return false;
	}
	else if(formNm.txt_ContactPerson.value == "")
	{
		alert("Please enter the contact person name");
		formNm.txt_ContactPerson.focus();
    return false;
	}
	else if(checkBlank(formNm.txt_ContactPerson.value))
	{
		alert("Please enter the contact person name");
		formNm.txt_ContactPerson.focus();
    return false;
	}
	
 	
  else if(formNm.txt_Email.value == "")
	{
		alert("Please enter your email");
		formNm.txt_Email.focus();
    return false;
	}
	else if(checkBlank(formNm.txt_Email.value))
	{
		alert("Please enter your email");
		formNm.txt_Email.focus();
    return false;
	}
	else if(checkEmail(formNm.txt_Email.value))
	{
		alert("Invalid email address");
		formNm.txt_Email.focus();
    return false;
	}
	
	
	
	
	

	else if(formNm.txt_Telephone.value == "") 
	{
		alert("Please enter the telephone number of your Company");
		formNm.txt_Telephone.focus();
    return false;
	} 
	else if(checkBlank(formNm.txt_Telephone.value)) 
	{
		alert("Please enter the telephone number of your Company");
		formNm.txt_Telephone.focus();
    return false;
	} 
	
	else if(formNm.how_heard.value == "Please select") 
	{
		alert("Please select 'How did you hear about us?' option.");
		formNm.how_heard.focus();
    return false;
	}
   else
   {
	   	return true;
   }
}





function submitLoginForm(formNm,Action,ActionType) {
	if(formNm.txt_SignInName.value == "") {
		alert("Please enter your sign-in name");
		formNm.txt_SignInName.focus();
	} else if(checkBlank(formNm.txt_SignInName.value)) {
		alert("Please enter your sign-in name");
		formNm.txt_SignInName.focus();
	} else if(formNm.txt_Password.value == "") {
		alert("Please enter your password");
		formNm.txt_Password.focus();
	} else if(checkBlank(formNm.txt_Password.value)) {
		alert("Please enter your password");
		formNm.txt_Password.focus();
	} else {
		formNm.action = Action;
		formNm.hid_ActionType.value = ActionType;
		formNm.submit();
	}
}

function submitCustFrm(formNm,Action,ActionType,id)	{
	if (ActionType == "view_customer")	{
		
		window.open("viewcustdetails.php?id="+id,'ViewCustDetails',"scrollbars=yes,menubar=no,width=550,height=400");

	}	else if (ActionType == "delete_customer")	{
		if (confirm("Are you sure you want to delete this record ? "))	{
			formNm.action = Action;
			formNm.customerId.value = id;
			formNm.hid_ActionType.value = ActionType;
			formNm.submit();
		}
	}	else	{
		formNm.action = Action;
		formNm.customerId.value = id;
		formNm.hid_ActionType.value = ActionType;
		formNm.submit();
	}
}


function submitForgotPasswordForm(formNm,Action,ActionType) {
	if(formNm.txt_SignInName.value == "") {
		alert("Please enter your sign-in name");
		formNm.txt_SignInName.focus();
	} else if(checkBlank(formNm.txt_SignInName.value)) {
		alert("Please enter your sign-in name");
		formNm.txt_SignInName.focus();

	} else {
		formNm.action = Action;
		formNm.hid_ActionType.value = ActionType;
		formNm.submit();
	}
}

function submitForm(formNm,Action,ActionType) {
	formNm.action = Action;
	formNm.hid_ActionType.value = ActionType;
	formNm.submit();	
}


function submitForm3(formNm,Action,Request) {
	formNm.action = Action;
	formNm.request.value = Request;
	formNm.submit();
}

function submitForm2(formNm,Action,ActionType) {
	formNm.hid_ActionType.value = ActionType;
	formNm.action = Action;
	formNm.submit();	
}

function submitNewOrderMail(formNm,Action,ActionType) {
	formNm.hid_ActionType.value = ActionType;
	formNm.action = Action;
	formNm.submit();	
}

function submitForm4(formNm,Action,ActionType,Request,OrderId,DesignId,AddDesignFlag) {
	if(ActionType == "deleteRevisedOrder" && confirm("Are you sure you want to delete this design")) {
		formNm.action = Action;
		formNm.hid_ActionType.value = ActionType;
		formNm.hid_AddDesignFlag.value = AddDesignFlag;
		formNm.orderId.value = OrderId;
		formNm.designId.value = DesignId;
		formNm.request.value = Request;
		formNm.submit();
	} else if(ActionType != "deleteRevisedOrder") {
		formNm.action = Action;
		formNm.hid_ActionType.value = ActionType;
		formNm.hid_AddDesignFlag.value = AddDesignFlag;
		formNm.orderId.value = OrderId;
		formNm.designId.value = DesignId;
		formNm.request.value = Request;
		formNm.submit();
	}
}

function submitForm6(formNm,Action,ActionType,Request,DesignId,AddDesignFlag) {
	if((ActionType == "deleteOrder" && confirm("Are you sure you want to delete this design")) || (ActionType == "deleteQuote" && confirm("Are you sure you want to delete this design"))) {
		formNm.action = Action;
		formNm.hid_ActionType.value = ActionType;
		formNm.hid_AddDesignFlag.value = AddDesignFlag;
		formNm.designId.value = DesignId;
		formNm.request.value = Request;
		formNm.submit();
	} else if(ActionType != "deleteOrder" && ActionType != "deleteQuote") {
		formNm.action = Action;
		formNm.hid_ActionType.value = ActionType;
		formNm.hid_AddDesignFlag.value = AddDesignFlag;
		formNm.designId.value = DesignId;
		formNm.request.value = Request;
		formNm.submit();
	}
}

function submitForm5(formNm,Action,OrderId) {
	formNm.action = Action;
	formNm.orderId.value = OrderId;
	formNm.submit();
}

function submitReorderForm(formNm,Action){
	formNm.action = Action;
	formNm.orderId.value = formNm.txt_order.value 
	formNm.submit();
}

function submitForm7(formNm,Action,QuoteId) {
	formNm.action = Action;
	formNm.quoteId.value = QuoteId;
	formNm.submit();
}

function submitOrdersDetails(formNm,Action,ActionType,orderId,parentId,customerId) {
	formNm.action = Action;
	formNm.hid_ActionType.value = ActionType;
	formNm.orderId.value = orderId;
	formNm.parentId.value = parentId;
	formNm.customerId.value = customerId;
	formNm.submit();
}

function submitOrderMail(formNm,orderId,ActionType,Action) {
	formNm.action = Action;
	formNm.hid_ActionType.value = ActionType;
	formNm.orderId.value = orderId;
	formNm.submit();
}

function sendQuoteMail(formNm,Action,ActionType,quoteId,customerId) {
	formNm.action = Action;
	formNm.hid_ActionType.value = ActionType;
	formNm.quoteId.value = quoteId;
	formNm.customerId.value = customerId;
	formNm.submit();	
}

function submitQuotesDetails(formNm,Action,ActionType,quoteId,parentId) {
	formNm.action = Action;
	formNm.hid_ActionType.value = ActionType;
	formNm.quoteId.value = quoteId;
	formNm.submit();
}

function submitQuotesWithCustomerDetails(formNm,Action,ActionType,quoteId,customerId) {
	formNm.action = Action;
	formNm.hid_ActionType.value = ActionType;
	formNm.quoteId.value = quoteId;
	formNm.customerId.value = customerId;
	formNm.submit();
}

function submitOrderMessageForm(formNm,Action,ActionType,orderId,parentId,customerId,request) {
	formNm.action = Action;
	formNm.hid_ActionType.value = ActionType;
	formNm.orderId.value = orderId;
	formNm.request.value = request;
	formNm.parentId.value = parentId;
	formNm.customerId.value = customerId;
	formNm.submit();
}

function submitQuoteMessageForm(formNm,Action,ActionType,quoteId,customerId,request) {
	formNm.action = Action;
	formNm.hid_ActionType.value = ActionType;
	formNm.quoteId.value = quoteId;
	formNm.request.value = request;
	formNm.customerId.value = customerId;
	formNm.submit();
}

function submitMessageDetailsForm(formNm,ActionType,Action,Id,CustId) {
	if(ActionType == "deleteMessage") {
		if(confirm("Are you sure you want to delete this message")) {
			formNm.action = Action;
			formNm.hid_ActionType.value = ActionType;
			formNm.CustId.value = CustId;
			formNm.Id.value = Id;
			
			formNm.submit();
		}
	} else {
		formNm.action = Action;
		formNm.hid_ActionType.value = ActionType;
		formNm.CustId.value = CustId;
		formNm.Id.value = Id;
		
		formNm.submit();
	}
}

function submitMessageDetailsForm3(formNm,ActionType,Action,Id,CustId) {
	
	if(ActionType == "deleteClientMessage") {
		if(confirm("Are you sure you want to delete this message")) {
			formNm.action = Action;
			formNm.hid_ActionType.value = ActionType;
			formNm.Id.value = Id;
			formNm.CustId.value = CustId;
			formNm.submit();
		}
	} else {
		formNm.action = Action;
		formNm.hid_ActionType.value = ActionType;
		formNm.Id.value = Id;
		formNm.CustId.value = CustId;
		formNm.submit();
	}
}



function submitMessageDetailsForm2(formNm,ActionType,Action,CustId) {
	
		formNm.action = Action;
		formNm.hid_ActionType.value = ActionType;

		formNm.CustId.value = CustId;
		formNm.submit();
	
}
function submitMessageForm(formNm) 
{
	if(formNm.txt_Title.value == "") 
	{
		alert("Please enter title for message");
		formNm.txt_Title.focus();
	} 
	else if(checkBlank(formNm.txt_Title.value)) 
	{
		alert("Please enter title for message");
		formNm.txt_Title.focus();
	} 
	else if(formNm.txtar_Message.value == "") 
	{
		alert("Please enter your message");
		formNm.txtar_Message.focus();
	} 
	else 
	{
		formNm.submit();
	}
}

function submitMessageListForm(formNm,Action,messageId) {
	formNm.action = Action;
	formNm.messageId.value = messageId;
	formNm.submit();
}

function submitUploadForm(formNm,Action,ActionType,orderId,designId) {
	formNm.action = Action;
	formNm.hid_ActionType.value = ActionType;
	formNm.orderId.value = orderId;
	formNm.designId.value = designId;
	formNm.submit();
}

function submitUploadForm(formNm,Action,ActionType,orderId,designId) {
	formNm.action = Action;
	formNm.hid_ActionType.value = ActionType;
	formNm.orderId.value = orderId;
	formNm.designId.value = designId;
	formNm.submit();
}

function submitUpdateForm(formNm)
{
  if(formNm.txtar_Edit.value=='')
   {
    alert("Please Enter Your Comments");
    formNm.txtar_Edit.focus();
    return false
   }
   else
   {
    return true;
   }
}

function deleteOrderForm(formNm,Action,ActionType,orderId) {
	if(confirm("Are you sure you want to delete this order")) {
		formNm.action = Action;
		formNm.hid_ActionType.value = ActionType;
		formNm.orderId.value = orderId;
		formNm.submit();
	}
}

function deleteQuoteForm(formNm,Action,ActionType,quoteId) {
	if(confirm("Are you sure you want to delete this quote")) {
		formNm.action = Action;
		formNm.hid_ActionType.value = ActionType;
		formNm.quoteId.value = quoteId;
		formNm.submit();
	}
}

function openWindow(pathName,windowName,widthNumber,heightNumber) {
	window.open(pathName,windowName,"toolbar=no,scrollbars=yes,width="+widthNumber+",height="+heightNumber+",menubar=no,status=no,resizable=no,left=200px,top=100px");
}

function submitShowList(formNm,Action,ActionType) {
	formNm.action = Action;
	formNm.hid_ActionType.value = ActionType;
	formNm.submit();	
}

function submitGenerateReport(formNm,Action,ActionType) {
	formNm.action = Action;
	formNm.hid_ActionType.value = ActionType;
	formNm.submit();
}

function submitDesignForm(frm)
{
	if(frm.txt_DesignName.value =="")
	{
		alert("Please enter Design Name");
		frm.txt_DesignName.focus();
    return false;
	}
	else if(frm.cmb_FabricType.options[frm.cmb_FabricType.selectedIndex].value == "Other"  && frm.txt_FabricOther.value =="")
	{
		alert("Please enter other fabric type");
		frm.txt_FabricOther.focus();
    return false;
	}
	else if(frm.cmb_FabricType.options[frm.cmb_FabricType.selectedIndex].value != "Other" && frm.txt_FabricOther.value !="")
	{
		alert("Either select the other option from Fabric/Garment list box or remove the value written in the other Fabric/Garment text field");
		frm.cmb_FabricType.focus();
    return false;
	}
	else if(frm.cmb_Color.options[frm.cmb_Color.selectedIndex].value == "Other"  && frm.txt_OtherColor.value =="")
	{
		alert("Please enter what type of other color you want us to use");
		frm.txt_OtherColor.focus();
    return false;
	} 
	else if(frm.cmb_Color.options[frm.cmb_Color.selectedIndex].value != "Other" && frm.txt_OtherColor.value !="")
	{
		alert("Either select the other option from the Color list box or remove the value written in the other Color text field");
		frm.cmb_Color.focus();
    return false;
	} 
	else if(frm.file_Image.value == "" && frm.file_Image_second.value == "")
	{
		alert("Please Browse which file to upload ");
		frm.file_Image.focus();
    return false;
	}
	else
	{
		loadSubmit();
    return true;
	}
}

function submitDesignFormAWS(frm)
{
	if(frm.txt_DesignName.value =="")
	{
		alert("Please enter Design Name");
		frm.txt_DesignName.focus();
    return false;
	}
	else if(frm.file_Image.value == "" && frm.file_Image_second.value == "")
	{
		alert("Please Browse which file to upload ");
		frm.file_Image.focus();
    return false;
	}
	else
	{
		loadSubmit();
    return true;
	}
}
 
function submitPrintableForm(pathName,windowName,widthNumber,heightNumber) {
	window.open(pathName,windowName,"toolbar=no,scrollbars=yes,width="+widthNumber+",height="+heightNumber+",menubar=no,status=no,resizable=no,left=200px,top=100px");
}

function printWindow() {
	if(document.all) {
		document.all["printPage"].style.visibility = "hidden";
	} else if(document.layers) {
		document.layers["printPage"].visibility = "hide";
	}
	window.print();
	window.close();
}

function manageDesignForm(ActionType,DesignID)
{
  if(ActionType=='edit')
  {
     document.editform.ActionType.value=ActionType;
     document.editform.DesignID.value=DesignID;
     document.editform.submit();
  }
  else if(ActionType=='delete')
  {
    if(confirm("Are you sure you want to delete this design?"))
    {
     document.editform.ActionType.value=ActionType;
     document.editform.DesignID.value=DesignID;
     document.editform.submit();
    }

  }

}

function PopupPic(sPicURL)
{ 
  window.open( "popup.php?"+sPicURL, "", "resizable=1,HEIGHT=200,WIDTH=200");
}

function submitUpdateCCForm(formNm)
{
  /* else if(formNm.ccnumber.value.length<16)
   {
    alert("Please Enter Proper Credit Card Number");
    formNm.ccnumber.focus();
    return false
   }*/
   if(formNm.ccnumber.value=='')
   {
    alert("Please Enter Your Credit Card Number");
    formNm.ccnumber.focus();
    return false
   }
   else
   {
	   res=testCreditCard(formNm.ccnumber.value,formNm.cctype.value,formNm);
	   //cctypeselect
	if(res==false)
	{
    	return false;
	}
   }
   
  /* res=checkValidDate(formNm);
   if(res==false)
	{
    	return false;
	}*/
   
    if(formNm.seccode.value=='')
   {
    alert("Please Enter Security Code");
    formNm.seccode.focus();
    return false;
   }
   
   if(!isNumber(formNm.seccode.value))
   {
   alert("Please Enter valid Security Code");
   formNm.seccode.focus();
   return false;
   }   
   //isNumber(str)   
}

/*
 * ADDED AT AXIS BY HEMANT
 */
/* String Functins */
function ltrim(str){
    str = this != window ? this : str;
    return str.replace(/^\s+/,'');
}

function rtrim(str){
    str = this != window ? this : str;
    return str.replace(/\s+$/,'');
}

function trim(str){
    str = this != window ? this : str;
    return str.replace(/^\s+/,'').replace(/\s+$/,'');
}

/*String Regex Functions*/

function isEmail(str){
    str = this != window ? this : str;
    var regx = /[A-Za-z0-9_\-.]+\@[A-Za-z0-9_\-.]+\.([A-Za-z_]{2,4})/;
    return regx.test(str);
}
function isNotEmail(str){
    str = this != window ? this : str;
    return !str.isEmail();
}


function is_Number(str){
    str = this != window ? this : str;
    return ! isNaN(str);
}
function is_NotNumber(str){
    str = this != window ? this : str;
    return  isNaN(str);
}

function isEmpty(str){
    str = this != window ? this : str;
    str= str.replace(/^\s+/,'').replace(/\s+$/,'');
    return (str.length == 0) ;
}
function isNotEmpty(str){
    str = this != window ? this : str;
    return !str.isEmpty();
}

function trim_form(obj){
    for(i=0; i<obj.elements.length; i++){
         ctype =  obj.elements[i].type.toLowerCase();
         if( (ctype == "text") || (ctype == "textarea") ){
              obj.elements[i].value = obj.elements[i].value.trim();
         }
    }
}


function submitShortRegistrationForm(formNm) {
	
	
	if(formNm.txtFname.value == "")
	{
		alert("Please enter your first name");
		formNm.txtFname.focus();
    return false;

	} 
  	else if(checkIfIsChar(formNm.txtFname.value)) 
	{
		alert("The first character of the First Name should be a character");
		formNm.txtFname.focus();
    return false;
	} 
	
	if(formNm.txtLname.value == "")
	{
		alert("Please enter your last name");
		formNm.txtLname.focus();
    return false;

	} 
 	else if(checkIfIsChar(formNm.txtLname.value)) 
	{
		alert("The first character of the Last Name should be a character");
		formNm.txtLname.focus();
    return false;
	} 
	
	
	if(formNm.txtComName.value == "")
	{
		alert("Please enter your company name");
		formNm.txtComName.focus();
    return false;

	} 
  
	else if(checkIfIsChar(formNm.txtComName.value)) 
	{
		alert("The first character of the Company Name should be a character");
		formNm.txtComName.focus();
    return false;
	} 
	
	else if(formNm.txtEmail1.value == "")
	{
		alert("Please enter your email");
		formNm.txtEmail1.focus();
    return false;
	}
	else if(checkBlank(formNm.txtEmail1.value))
	{
		alert("Please enter your email");
		formNm.txtEmail1.focus();
    return false;
	}
	else if(checkEmail(formNm.txtEmail1.value))
	{
		alert("Invalid email address");
		formNm.txtEmail1.focus();
    return false;
	}
	
	
	else if(formNm.txtEmail22.value == "")
	{
		alert("Please enter your confirmation email");
		formNm.txtEmail22.focus();
    return false;
	}
	else if(checkBlank(formNm.txtEmail22.value))
	{
		alert("Please enter your confirmation email");
		formNm.txtEmail22.focus();
    return false;
	}
	else if(checkEmail(formNm.txtEmail22.value))
	{
		alert("Invalid confirmation email address");
		formNm.txtEmail22.focus();
    return false;
	}
	
	else if(formNm.txtEmail1.value != formNm.txtEmail22.value)
	 {
		alert("Your email address did not match.");
		formNm.txtEmail22.focus();
    return false;
	}
	else if(formNm.txt_Telephone.value == "") 
	{
		alert("Please enter the telephone number of your Company");
		formNm.txt_Telephone.focus();
    return false;
	} 
	else if(checkBlank(formNm.txt_Telephone.value)) 
	{
		alert("Please enter the telephone number of your Company");
		formNm.txt_Telephone.focus();
    return false;
	} 
	
	else if(formNm.how_heard.value == "Please select") 
	{
		alert("Please select 'How did you hear about us?' option.");
		formNm.how_heard.focus();
    return false;
	}
 else
	{
    return true;
	}
}
String.prototype.ltrim = ltrim;
String.prototype.rtrim = rtrim;
String.prototype.trim = trim;

String.prototype.isEmpty = isEmpty;
String.prototype.isNotEmpty = isNotEmpty;

String.prototype.isEmail = isEmail;
String.prototype.isNotEmail = isNotEmail;

String.prototype.is_Number = is_Number;
String.prototype.is_NotNumber = is_NotNumber;