function KeyEnter_DoAction(fldName,evt,strLayerPostVal,strModalTypeCondition,frmObj) {
		evt = (evt) ? evt : window.event;
		if (evt.keyCode == 13 ) {
			if(strLayerPostVal=="" || strLayerPostVal=="undefined" || strLayerPostVal==null)
				strLayerPostVal = "";
			
			if(fldName=="LoginForm")
				CheckLogin(frmObj,strModalTypeCondition,'SubmitLogin',500,250,strLayerPostVal,'modalwindow/modalwindow.php');
				return false;
		} else {
			return true;
		}
	
	
	}
//////////////Common Variables

var LoadingStatus="<img src='"+SiteImagePath+"ajaxloaders/ajax_loader_small.gif'/>"; 
var ModalStaticContent='';
var ModalStaticContentTitle='';

////////////////////////////////////////////////////////Modal Window Related Functions ////////////////////////////////////////////
	messageObj = new DHTML_modalMessage();	
	messageObj.setShadowOffset(5);	
	
	function ShowModalWindow(ModalType,width,height,PostValues,AjaxFilename,AjaxCheckFormData,strValue) {
		
		if(ModalStaticContent!='') {
			messageObj.setModalStaticContentTitle(ModalStaticContentTitle);
			messageObj.setModalStaticContent(ModalStaticContent);
			ModalStaticContent='';
			ModalStaticContentTitle='';
			messageObj.setAjaxFileNames(AjaxFilename,AjaxCheckFormData);
			messageObj.setSource(ModalType);
			messageObj.setPostValues(PostValues,strValue);
			messageObj.setCssClassMessageBox(false);
			messageObj.setSize(width,height);
			messageObj.setShadowDivVisible(false);	// Enable shadow for these boxes
			messageObj.display();
		}
		else {
			ModalStaticContent='';
			ModalStaticContentTitle='';
			messageObj.setModalStaticContentTitle(ModalStaticContentTitle);
			messageObj.setModalStaticContent(ModalStaticContent);
			messageObj.setAjaxFileNames(AjaxFilename,AjaxCheckFormData);
			messageObj.setSource(ModalType);
			messageObj.setPostValues(PostValues,strValue);
			messageObj.setCssClassMessageBox(false);
			messageObj.setSize(width,height);
			messageObj.setShadowDivVisible(false);	// Enable shadow for these boxes
			messageObj.display();
		}
	}
	function AddCartLayer(objForm,strSubmitValue,id,Layer) {
		if(chkMinQuantity(objForm,'') == false){
			return false;
		}else
		{
			if(validate_form(objForm) == false) {
			   return false;
			}else {
				if(!AddtoCart(objForm,id,Layer))
				return false;
			}
		}
		
	}
	function ShowModalWindowContent(ModalMasterID,ModalType,PostValues,AjaxFilename,AjaxCheckFormData)
	{
		var Filename=AjaxFilename;
		ModalMasterID_public=ModalMasterID;
		document.getElementById(ModalMasterID).innerHTML = '<table align="center" height="100%"><tr><td colspan="2" valign="middle"  height=30 >'+LoadingStatus+'</td></tr></table>';
		var success = function(t){ShowModalWindowContent_Complete(t,ModalMasterID,ModalType,PostValues,AjaxFilename,AjaxCheckFormData);}
		var failure = function(t){ShowOnFailure(t);}
		var url = Filename;
		var pars = '&ModalTypeCondition='+ModalType+'&PostValues='+PostValues;
		var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
	}
	function ShowModalWindowContent_Complete(t,ModalMasterID,ModalType,PostValues,AjaxFilename,AjaxCheckFormData)
	{
		var strValue = t.responseText;
		var strDisplay = strValue.split("|");
		if(strDisplay[1]=="LoginLayer")	{
			ShowModalWindow('ShowLogin',450,270,PostValues,'modalwindow/modalwindow.php');
			var flag = 1;
		} else {
			document.getElementById(ModalMasterID).innerHTML =strDisplay[0];
		}
	}
	
	function closeMessage(RedirectCondition)
	{
		messageObj.close();	
	}
	
	function ShowOnFailure(t) { alert(t); };
	
	//////////////////////////////////////////////////////// Ajax Form Validation ////////////////////////////////////////////

	function CheckFormData(value,BasicID,obj,fieldName,Condition,SubCondition,ErrorImgIdPostfix,ErrorTxtIdPostfix,FilenameFormCheck,FormName)
	{
		var FilenameFormCheck=SiteAjaxFolder+FilenameFormCheck;
		var success = function(t){CheckFormData_Complete(t,value,BasicID,obj,fieldName,Condition,SubCondition,ErrorImgIdPostfix,ErrorTxtIdPostfix,FilenameFormCheck,FormName);}
		var failure = function(t){ShowOnFailure(t);}
		var url = FilenameFormCheck;
		var pars = '&Condition='+Condition+'&Value='+value+'&fieldName='+fieldName+'&FormName='+FormName;
		var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
	}
	function CheckFormData_Complete(t,value,BasicID,obj,fieldName,Condition,SubCondition,ErrorImgIdPostfix,ErrorTxtIdPostfix,FilenameFormCheck,FormName)
	{
		var strLabelText = "";
		var strValue = t.responseText;
		var SpanID=BasicID+ErrorTxtIdPostfix; 
		var LabelImgID=BasicID+ErrorImgIdPostfix;
		if(strValue!=1) {
				var response=strValue.split("||");
				document.getElementById(LabelImgID).innerHTML	=ErrorInfoImg;
				document.getElementById(LabelImgID).className	='InValidClass';
				document.getElementById(SpanID).className		='LayerTdClassError';
				document.getElementById(SpanID).innerHTML		= response[1]+strLabelText;
		}
		else if(strValue==1) {
				var response=strValue.split("||");
				document.getElementById(LabelImgID).innerHTML	=SuccessInfoImg;
				document.getElementById(LabelImgID).className	='ValidClass';
				document.getElementById(SpanID).className		='LayerTdClass';
				document.getElementById(SpanID).innerHTML		= '&nbsp;';
		}
	}
	function fieldEnter(fldName,evt,strChkLabel,strChkLabelValue) {
		evt = (evt) ? evt : window.event;
		if (evt.keyCode == 13 ) {
			if(fldName=="username") {
			 return ForgotPasswordMail(document.forgotpass,'Layer')
			}
			if(fldName=="promcode") {
			 return Discount_Validate(document.c_form1)
			}
		}
	}
	function ForgotPasswordMail(objForm,Layer) {
		if(!forgopass(objForm,Layer))
		return false;
		else
		return true;
	}
	function Mailtofriend(objForm,id,Layer) {
	if(!validatetellafriend(objForm,id,Layer))
		return false;
		else
		return true;
	}
	function AddWishListCart(objForm,id,Layer) {
		if(!AddtoCart(objForm,id,Layer))
				return false;
				else
				return true;
	}
	function SendFeedBack(objForm,Layer) {
	if(!validatesendfeedback(objForm,Layer))
				return false;
				else
				return true;
    }
	function ShowLogin(formObj,Layer,ModalType,width,height,PostValues,AjaxFilename,AjaxCheckFormData,strValue) {
		var Filename= SiteAjaxFolder+AjaxFilename;
		var success = function(t){ShowModalWindowLoginContent_Complete(t,width,height,PostValues,AjaxFilename,AjaxCheckFormData,strValue);}
		var failure = function(t){ShowOnLoginFailure(t);}
		var url = Filename;
		var pars = '&ModalTypeCondition='+ModalType+'&PostValues='+PostValues+strValue;
		var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
	}
  function ShowModalWindowLoginContent_Complete(t,width,height,PostValues,AjaxFilename,AjaxCheckFormData,strValue) {
	var strValue = t.responseText;
	var strDisplay = strValue.split("|");
	if(strDisplay[0] =="Relogin")
	{
		alert("Invalid Login Please check your Email and password")
//	document.getElementById('CustomerLogin').innerHTML = strDisplay[2];
	
	}else
	{
	document.getElementById('CustomerLogin').innerHTML = strDisplay[1];
	ShowModalWindow('AddToWishlist',500,250,PostValues,AjaxFilename)
 	}
  }
  function ShowOnLoginFailure() {
  }
  
  function CheckforQuantity(objForm,strSubmitValue,id) {
	if(!IsNumber(objForm.c_quantity.value,"Quantity"))
	{	
		document.getElementById("Quantity").focus()
		return false;
	 }else	{
			var strValue='';
			for(i=0;i<objForm.elements.length;i++)
			{
				if(objForm.elements[i].name == "Addtocart")
					strValue += "&"+objForm.elements[i].name+"=Add to Cart";
				else
					strValue += "&"+objForm.elements[i].name+"="+objForm.elements[i].value;
			}
			var AjaxFilename = "AddCartAjax.php";
			var strFilename= SiteAjaxFolder+AjaxFilename;
			var success = function(t){CheckforQuantity_Complete(t);}
			var failure = function(t){CheckforQuantityFailure(t);}
			var url = strFilename;
			var pars = '&ModalTypeCondition=AddToCart&strSubmitValue='+strSubmitValue+'&PostValues='+id+strValue;
			var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
	  }
  }
  function CheckforQuantity_Complete(t) {
	document.getElementById('CartDisplay').innerHTML = t.responseText;
	document.getElementById('CartDisplayHide').innerHTML = '';
	document.getElementById('Quantity').value="";
	document.getElementById('Quantity').focus();
  }
  function CheckforQuantityFailure(t)
  {
	  alert(t.responseText)
  }
 function ShowViewCart()
 {
  window.location='viewcart.php'
 }
 
