﻿//trim function 
function trimAll(sString) 
{
	
while (sString.substring(0,1) == ' ')
{
sString = sString.substring(1, sString.length);
}
while (sString.substring(sString.length-1, sString.length) == ' ')
{
sString = sString.substring(0,sString.length-1);
}
//alert(sString.length);

return sString;
}  

//the 'ask the experts' submission form validation 
function valForm()
{
   window.categorytype = document.form1.category;    
        
        
        if(categorytype.options[categorytype.selectedIndex].text == 'Select Category' ) 
        {
         alert("Please select a category for your question");
             return false;
        }
        else if (trimAll(document.form1.question.value).length == 0)
        {
          alert("Please enter your question"); 
           // document.form1.question.setfocus();
             return false;
                 
        } 
         else if (trimAll(document.form1.name.value).length == 0)
        {
          alert("Please enter your name"); 
           // document.form1.name.setfocus();
             return false;
                 
        }
         else if (trimAll(document.form1.email.value).length == 0)
        {
          alert("Please enter your email address"); 
           // document.form1.email.setfocus();
             return false;
                 
        }
        else
        {
          return true;
        }

}

//the 'Pink Pages' submission form validation 
function valPinkPages()
{
   window.categorytype = document.form1.lstPinkPagesCats;   
        
        if(categorytype.options[categorytype.selectedIndex].text == '**Please Choose**' )  
        {
         alert("Please select at least one Supplier Category!");
             return false;
        }
        else
        {
          return true;
        }

}

      // open the confetti Subscription page
        function open_it() 
        {
                window.open("http://www.houseandhome.ie/subscriptions_confetti.asp", "NewWindow", "width=800,height=600,left=100,top=10 toolbar=yes,location=no,resizable=no,status=no,scrollbars=yes,");
        }


        function printpreview() 
        {
        window.open("print.aspx", "NewWindow", "width=740,height=700,left=200,top=0 toolbar=no,location=no,resizable=no,status=no,scrollbars=yes,");
        }