  function ShareReviewPopup(currObj,ReviewId)
  {    var width = 480;
       var height = 480;

       objPosX =  findPosX(currObj);
       objPosY =  findPosY(currObj);

       currShareReviewLinkObj = currObj;
       currReviewId = ReviewId;

       //posTop =  (screen.width / 2) - (height / 2);
       posTop =  (screen.availHeight / 2) - (height / 2) - 80;
       posLeft = (screen.availWidth / 2) - (width / 2) - 70;

       eBox = $j('#ShareReviewPopupBox');
       eBox.css({"top" : objPosY, "left" : objPosX, "z-index:" : 1000, 'width' : 10, height: 10});
       //eBox.show();
       eBox.animate(  {"height": height, "width" : width, "top" : posTop, "left" : posLeft, "opacity" : "toggle"},                      {duration: "slow" });

  }

  function LoginPopup(currObj,reviewlink)
  {    var width = 480;
       var height = 490;

       objPosX =  findPosX(currObj);
       objPosY =  findPosY(currObj);

       currLoginLinkObj = currObj;
       currreviewlink = reviewlink;

       //posTop =  (screen.width / 2) - (height / 2);
       posTop =  (screen.availHeight / 2) - (height / 2) - 80;
       posLeft = (screen.availWidth / 2) - (width / 2) - 70;

       eBox = $j('#LoginPopupBox');
       eBox.css({"top" : objPosY, "left" : objPosX, "z-index:" : 1000, 'width' : 10, height: 10});
       //eBox.show();
       eBox.animate(  {"height": height, "width" : width, "top" : posTop, "left" : posLeft, "opacity" : "toggle"},                      {duration: "slow" });

  }
 function closeLoginPopup()
 {
    currObj = currLoginLinkObj; //document.getElementById('emailUsLink');

    objPosX =  findPosX(currObj);
    objPosY =  findPosY(currObj);

    eBox = $j('#LoginPopupBox');
    eBox.animate(  {"height": 1, "width" : 1, "top" : objPosY, "left" : objPosX, 'opacity' : "toggle"},
                      {duration: "slow" }
                    );
    if (LoginFormContentHtml != '')
       $('#LoginformContent').html(LoginContentHtml);
 }

 function closeShareReviewPopup()
 {
    currObj = currShareReviewLinkObj; //document.getElementById('emailUsLink');

    objPosX =  findPosX(currObj);
    objPosY =  findPosY(currObj);

    eBox = $j('#ShareReviewPopupBox');
    eBox.animate(  {"height": 1, "width" : 1, "top" : objPosY, "left" : objPosX, 'opacity' : "toggle"},
                      {duration: "slow" }
                    );
    if (ShareReviewFormContentHtml != '')
       $j('#ShareReviewformContent').html(ShareReviewContentHtml);
 }

function formShareReviewValidate(frmObj)
    {
        reqFields = { 'Recipient\' email address' : 'recipients_email',
                      'Your e-mail address' : 'your_email',
                      'Your name' : 'your_name',
                      'Personal message' : 'message'
                    }
        for (var fld in reqFields)
        {
           if (frmObj[reqFields[fld]].value == '')
           {
               alert(fld + ' is required field.');
               frmObj[reqFields[fld]].focus();
               return false;
           }
        }

        if (!re.test(frmObj.your_email.value))
        {
            alert('Invalid email address');
            frmObj.your_email.focus();
            return false;
        }
        urlValue = location.href;

        postParams = "recipients_email=" + frmObj.recipients_email.value;
        postParams += "&your_email=" + frmObj.your_email.value;
        postParams += "&your_name=" + frmObj.your_name.value;
        postParams += "&message=" + frmObj.message.value;
        postParams += "&review_id="+currReviewId;
        postParams += "&action=send";

        ShareReviewFormContentHtml = $j("#ShareReviewformContent").html();

        $j.ajax({ url : urlValue,
                 type : "POST",
                 data : postParams,
                 success : function (message) {
                              $j("#ShareReviewformContent").html(message)
                              $j("#ShareReviewPopupBox").animate({"height": 200}, {duration: "slow" });
                        },

                 error : function(){
                    alert('Your mesasge cannot be send this time. Please try to send your message again.');
                 }
                });

        return false;
    }


function formLoginValidate(frmObj)
    {
        reqFields = { 'Email address' : 'email',
                      'Password' : 'password'
                    }
        for (var fld in reqFields)
        {
           if (frmObj[reqFields[fld]].value == '')
           {
               alert(fld + ' is required field.');
               frmObj[reqFields[fld]].focus();
               return false;
           }
        }

        if (!re.test(frmObj.email.value))
        {
            alert('Invalid email address');
            frmObj.email.focus();
            return false;
        }

        /*subscribeMailingListValue = (frmObj.subscribe_mailing_list.checked)?"Y":"N";*/
        urlValue = currreviewlink;
        postParams = "&email=" + frmObj.email.value;
        postParams += "&password=" + frmObj.password.value;
        postParams += "&action=login";

        LoginFormContentHtml = $j("#LoginformContent").html();

        $j.ajax({ url : urlValue,
                 type : "POST",
                 data : postParams,
                 success : function (message) {
                            if(message=='Yes')
                            {
	                            document.location=urlValue;
                            }
                            else
                            {
                                alert('Sorry, there is no match for that e-mail address and/or password.');
                            }
                        },

                 error : function(){
                    alert('Your mesasge cannot be send this time. Please try to send your message again.');
                 }
                });

        return false;
    }

function formCreateAccountValidate(frmObj)
    {
        reqFields = { 'Firstname' : 'firstname',
                      'Lastname' : 'lastname',
                      'Email Address' : 'email',
                      'Password' : 'password',
                      'Confirm Password' : 'confirm_password',
                      'ZIPCODE' : 'zipcode'
                    }
        for (var fld in reqFields)
        {
            if (frmObj[reqFields[fld]].value == '')
           {   if (fld == 'Confirm Password')
                  alert('Please confirm your password.');
               else
                  alert(fld + ' is required field.');

               frmObj[reqFields[fld]].focus();
               return false;
           }
        }

        if (frmObj.password.value != frmObj.confirm_password.value)
        {   alert('Your password did not match with the confirm password.');
            frmObj.email.focus();
            return false;
        }

        if (!re.test(frmObj.email.value))
        {
            alert('Invalid email address');
            frmObj.email.focus();
            return false;
        }


        subscribeMailingListValue = (frmObj.subscribe_mailing_list.checked)?"1":"0";
        urlValue = currreviewlink;
        postParams = "&email=" + frmObj.email.value;
        postParams += "&firstname=" + frmObj.firstname.value;
        postParams += "&lastname=" + frmObj.lastname.value;
        postParams += "&password=" + frmObj.password.value;
        postParams += "&confirm_password=" + frmObj.confirm_password.value;
        postParams += "&zipcode=" + frmObj.zipcode.value;
        postParams += "&mailing_list=" + subscribeMailingListValue;
        postParams += "&action=create_account";

        LoginFormContentHtml = $j("#LoginformContent").html();

        $j.ajax({ url : urlValue,
                 type : "POST",
                 data : postParams,
                 success : function (message) {
                            if(message=='')
                            {
	                            document.location=urlValue;
                            }
                            else
                            {
                                alert(message);
                            }
                        },

                 error : function(){
                    alert('Your request cannot be process at this time. Please try again.');
                 }
                });

        return false;
    }

function checkLogin(frmObj,urlValue)
{
        postParams = "&action=reviewLogin";
        objPosX =  findPosX(frmObj);
        objPosY =  findPosY(frmObj);
        //urlValue = location.href;
   		//remove all the class add the messagebox classes and start fading
        $j("#msgbox").css({"top" : objPosY, "left" : objPosX, "z-index:" : 1000});

		$j("#msgbox").removeClass().addClass('messagebox').text('Checking.....').fadeIn(1000);
        //alert(urlValue+postParams);
        $j.ajax({ url : urlValue,
                 type : "POST",
                 data : postParams,
                 success : function (message) {
                            if(message=='Yes')
                            {
                       		  	$j("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
			                    {
			                        //add message and change the class of the box and start fading
			                        $j(this).html('Loading...').addClass('messageboxok').fadeTo(900,1,
                                    function()
			                        {
			  	                        //redirect to secure page
                                        LoginPopup(frmObj,urlValue);
                                        $j(this).hide();
			                        });

                    			});
                            }
                            else
                            {
	                            document.location=urlValue;
                            }
                        },

                 error : function(){
                    alert('Your request cannot be send this time. Please try to send your request again.');
                 }
                });

    return false;
}

function checkLoginOnLoad(frmObj,urlValue,emailsend)
{
    if(emailsend=='1')
    {
    	checkLogin(frmObj,urlValue);
        return false;
    }
}

function checkReviewHelpful(frmObj,flag,review_id)
{
        postParams = "&action=reviewHelpful";
        postParams += "&flag="+flag;
        postParams += "&review_id="+review_id;
    objPosX =  findPosX(frmObj);
    objPosY =  findPosY(frmObj);

   		//remove all the class add the messagebox classes and start fading
          $j("#msgbox").css({"top" : objPosY, "left" : objPosX, "z-index:" : 1000});

		$j("#msgbox").removeClass().addClass('messagebox').text('Checking.....').fadeIn(1000);
        urlValue=location.href;
        //alert(urlValue+postParams);
        $j.ajax({ url : urlValue,
                 type : "POST",
                 data : postParams,
                 success : function (message) {
                            if(message=='Yes')
                            {

                       		  	$j("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
			                    {
			                        //add message and change the class of the box and start fading
			                        $j(this).html('Loading...').addClass('messageboxok').fadeTo(900,1,
                                    function()
			                        {
			  	                        //redirect to secure page
                                        $j(this).hide();
                                        alert('Please Login to comment.');
			                        });

                    			});




                            }
                            else
                            {
                       		  	$j("#msgbox").fadeTo(200,0.1,function()  //start fading the messagebox
			                    {
			                        //add message and change the class of the box and start fading
			                        $j(this).html('Loading...').addClass('messageboxok').fadeTo(900,1,
                                    function()
			                        {
			  	                        //redirect to secure page
                                        $j(this).hide();
                                        alert('Thank you for your comment.');
			                        });

                    			});
                            }
                        },

                 error : function(){
                    alert('Your mesasge cannot be send this time. Please try to send your message again.');
                 }
                });

    return false;

}

function formCheckZipcode(frmObj,fwhere)
    {
        urlValue = location.href;

        if( fwhere=='zipop' )
        {
            postParams = "matt_zipcode=" + frmObj.matt_zipcode.value;
        }

        if( fwhere=='zipage' )
        {
            postParams = "matt_zipcode=" + frmObj.product_zipcode.value;
        }

        if( fwhere=='zipmat' )
        {
            postParams = "matt_zipcode=" + frmObj.matt_zipcode.value;
        }

        postParams += "&process=check_zip&zipcheck="+fwhere;

        //FormContentHtml = $j("#zip_msg").html();

        $j.ajax({ url : urlValue,
                 type : "POST",
                 data : postParams,
                 success : function (message) {
			    if(message == "1")
                            {
                              $j("#" + fwhere + "1").show();
                              $j("#" + fwhere + "0").hide();
                            }
			    if(message=="0")
                            {
                              $j("#" + fwhere + "0").show();
                              $j("#" + fwhere + "1").hide();
                            }
                        },

                 error : function(){
                    alert('Your request cannot be process at this time. Please try again.');
                 }
                });

        return false;
    }
