// ***************************************
// * Author: AB Allen                    *
// * Company: 360eBusiness               *
// * Contant: info@360ebusiness.co.uk    *
// * URL: http://www.360ebusiness.co.uk/ *
// ***************************************


//** Used in estimate.php **

function validate()
    {
    if (document.estimate.name.value == "")
        {
        alert('Please make sure your name has been clearly entered');
        return false;
        }
    else if (document.estimate.day_tel.value == "")
        {
        alert('Please enter a daytime telephone number');
        return false;
        }
    else if (document.estimate.mail.value == "")
        {
        alert('Please enter a contact email address');
        return false;
        } 
    else if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.estimate.mail.value))
        {
        alert('Sorry, your email address is invalid.');
        return false;
        }
    else if (document.estimate.agree_terms.checked != true)
        {
        alert('Please confirm that you understand and agree with our estimate terms');
        return false;
        }
    else
    return true;
    }
    
//** Used in addcomment.php **

function validateComments()
    {
    if (document.customer_comments.client_name.value == "")
        {
        alert('Please make sure your name has been clearly entered');
        return false;
        }
    else if (document.customer_comments.client_comment.value == "")
        {
        alert('Please enter a comment');
        return false;
        }
    else if (document.customer_comments.client_email.value == "")
        {
        alert('Please enter a contact email address');
        return false;
        } 
    else if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.customer_comments.client_email.value))
        {
        alert('Sorry, your email address is invalid.');
        return false;
        }
    else
    return true;
    }
    
/***********************************************
* AnyLink Drop Down Menu- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

//Contents for menu 1
var menu1=new Array()
menu1[0]='<a href="removals.php" title="Review our removal & storage services">Removals & Storage</a>'
menu1[1]='<a href="packing.php" title="Review our packing services">Packing</a>'
menu1[2]='<a href="packing_materials.php" title="Review our packing materials">Packing Materials</a>'
//menu1[3]='<a href="maid.php" title="Review our mail cleaning services">Maid Service</a>'
menu1[3]='<a href="checklist.php" title="See our moving checklist">Moving Checklist</a>'
menu1[4]='<a href="insurance.php" title="Review our moving insurance">Moving Insurance</a>'

//Contents for menu 2, and so on
var menu2=new Array()
menu2[0]='<a href="feedback.php" title="Review our customers feedback">View Feedback</a>'
menu2[1]='<a href="leave_feedback.php" title="Leave feedback on one of our services">Leave Feedback</a>'
		
var menuwidth='165px' //default menu width
var menubgcolor='white'  //menu bgcolor
var disappeardelay=250  //menu disappear speed onMouseout (in miliseconds)
var hidemenu_onclick="yes" //hide menu when user clicks within menu?

/////No further editting needed

var ie4=document.all
var ns6=document.getElementById&&!document.all

if (ie4||ns6)
document.write('<div id="dropmenudiv" style="visibility:hidden;width:'+menuwidth+';background-color:'+menubgcolor+'" onMouseover="clearhidemenu()" onMouseout="dynamichide(event)"></div>')

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}


function showhide(obj, e, visible, hidden, menuwidth){
if (ie4||ns6)
dropmenuobj.style.left=dropmenuobj.style.top="-500px"
if (menuwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=menuwidth
}
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover")
obj.visibility=visible
else if (e.type=="click")
obj.visibility=hidden
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=ie4 && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetWidth
}
else{
var topedge=ie4 && !window.opera? iecompattest().scrollTop : window.pageYOffset
var windowedge=ie4 && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure){ //move up?
edgeoffset=dropmenuobj.contentmeasure+obj.offsetHeight
if ((dropmenuobj.y-topedge)<dropmenuobj.contentmeasure) //up no good either?
edgeoffset=dropmenuobj.y+obj.offsetHeight-topedge
}
}
return edgeoffset
}

function populatemenu(what){
if (ie4||ns6)
dropmenuobj.innerHTML=what.join("")
}


function dropdownmenu(obj, e, menucontents, menuwidth){
if (window.event) event.cancelBubble=true
else if (e.stopPropagation) e.stopPropagation()
clearhidemenu()
dropmenuobj=document.getElementById? document.getElementById("dropmenudiv") : dropmenudiv
populatemenu(menucontents)

if (ie4||ns6){
showhide(dropmenuobj.style, e, "visible", "hidden", menuwidth)
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+"px"
}

return clickreturnvalue()
}

function clickreturnvalue(){
if (ie4||ns6) return false
else return true
}

function contains_ns6(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
}

function dynamichide(e){
if (ie4&&!dropmenuobj.contains(e.toElement))
delayhidemenu()
else if (ns6&&e.currentTarget!= e.relatedTarget&& !contains_ns6(e.currentTarget, e.relatedTarget))
delayhidemenu()
}

function hidemenu(e){
if (typeof dropmenuobj!="undefined"){
if (ie4||ns6)
dropmenuobj.style.visibility="hidden"
}
}

function delayhidemenu(){
if (ie4||ns6)
delayhide=setTimeout("hidemenu()",disappeardelay)
}

function clearhidemenu(){
if (typeof delayhide!="undefined")
clearTimeout(delayhide)
}
if (hidemenu_onclick=="yes")
document.onclick=hidemenu

// Filter

var band_words_arr=new Array("http","www","link","<","url","viagra");
var band_alert_arr=new Array;
var band_alert_count=0;

function reset_alert_count()
{
 band_alert_count=0;
}

function validate_client_comment()
{
 reset_alert_count();
 var compare_text=document.customer_comments.client_comment.value;
 for(var i=0; i<band_words_arr.length; i++)
 {
  for(var j=0; j<(compare_text.length); j++)
  {
   if(band_words_arr[i]==compare_text.substring(j,(j+band_words_arr[i].length)).toLowerCase())
   {
    band_alert_arr[band_alert_count]=compare_text.substring(j,(j+band_words_arr[i].length));
    band_alert_count++;
   }
  }
 }
 var alert_text="";
 for(var k=1; k<=band_alert_count; k++)
 {
  alert_text+="\nSmoothMoveUK prosecutes spammers!";
 }
 if(band_alert_count>0)
 {
  alert("Use of illegal characters.\n_______________________________\n" + alert_text + "\n_______________________________");
  return false;
 }
 else
 {
    if (document.customer_comments.client_name.value == "")
        {
        alert('Please make sure your name has been clearly entered');
        return false;
        }
    else if (document.customer_comments.client_comment.value == "")
        {
        alert('Please enter a comment');
        return false;
        }
    else if (document.customer_comments.client_email.value == "")
        {
        alert('Please enter a contact email address');
        return false;
        } 
    else if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.customer_comments.client_email.value))
        {
        alert('Sorry, your email address is invalid.');
        return false;
        }
    else
    return true;
 }
}

function select_area()
{
 document.customer_comments.client_comment.select();
}
window.onload=reset_alert_count;

// Filter

var band_words_arr=new Array("http","www","link","<","url","viagra");
var band_alert_arr=new Array;
var band_alert_count=0;

function reset_alert_count()
{
 band_alert_count=0;
}

function validateEstimate()
{
 reset_alert_count();
 var compare_text=document.estimate.additional_info.value;
 for(var i=0; i<band_words_arr.length; i++)
 {
  for(var j=0; j<(compare_text.length); j++)
  {
   if(band_words_arr[i]==compare_text.substring(j,(j+band_words_arr[i].length)).toLowerCase())
   {
    band_alert_arr[band_alert_count]=compare_text.substring(j,(j+band_words_arr[i].length));
    band_alert_count++;
   }
  }
 }
 var alert_text="";
 for(var k=1; k<=band_alert_count; k++)
 {
  alert_text+="\nSmoothMoveUK prosecutes spammers!";
 }
 if(band_alert_count>0)
 {
  alert("Use of illegal characters.\n_______________________________\n" + alert_text + "\n_______________________________");
  return false;
 }
 else
 {
    if (document.estimate.name.value == "")
        {
        alert('Please make sure your name has been clearly entered');
        return false;
        }
    else if (document.estimate.day_tel.value == "")
        {
        alert('Please enter a daytime telephone number');
        return false;
        }
    else if (document.estimate.mail.value == "")
        {
        alert('Please enter a contact email address');
        return false;
        } 
    else if (!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.estimate.mail.value))
        {
        alert('Sorry, your email address is invalid.');
        return false;
        }
    else if (document.estimate.agree_terms.checked != true)
        {
        alert('Please confirm that you understand and agree with our estimate terms');
        return false;
        }
    else
    return true;
 }
}

function select_area()
{
 document.estimate.additional_info.select();
}
window.onload=reset_alert_count;