

  $(document).ready(function()
  {


    $("div.homeon").mouseover(function () 
	{
	 $(this).addClass("homeover");
    });
	$("div.homeon").mouseout(function () 
	{
	 $(this).removeClass("homeover");
    });



    $("div.abouton").mouseover(function () 
	{
	 $(this).addClass("aboutover");
    });
	$("div.abouton").mouseout(function () 
	{
	 $(this).removeClass("aboutover");
    });



    $("div.serviceson").mouseover(function () 
	{
	 $(this).addClass("servicesover");
    });
	$("div.serviceson").mouseout(function () 
	{
	 $(this).removeClass("servicesover");
    });


    $("div.galleryon").mouseover(function () 
	{
	 $(this).addClass("galleryover");
    });
	$("div.galleryon").mouseout(function () 
	{
	 $(this).removeClass("galleryover");
    });


    $("div.contacton").mouseover(function () 
	{
	 $(this).addClass("contactover");
    });
	$("div.contacton").mouseout(function () 
	{
	 $(this).removeClass("contactover");
    });




  });
   



function notValidEmail( str ){
    mailRE = new RegExp( );
    mailRE.compile( '^[._a-z0-9-]+@[.a-z0-9-]+[.]{1}[a-z]{2,4}$', 'gi' );
    return !(mailRE.test( str.value ));
}



function validateCONTform(CONTform) {

	
	if (CONTform.name.value == "") {
	alert("Please enter your full name.") ;
	return false ;
	}

	if (CONTform.phone.value == "") {
	alert("Please enter your phone or mobile number.") ;
	return false ;
	}

	if( notValidEmail( CONTform.email ) ){
	alert( 'Please enter a valid email address.' );
	return false;
	}


	if (CONTform.message.value == "") {
	alert("Please enter your enquiry message.") ;
	return false ;
	}


	else {
	return true ;
       }
}







function trim(obj) 
{   str=obj.value
    obj.value= str.replace(/^\s+|\s+$/g,''); 
	return obj;
}    
function selectReplacement(obj) {
      // append a class to the select
      obj.className += ' replaced';
      // create list for styling
      var ul = document.createElement('ul');
      ul.className = 'selectReplacement';
      var opts = obj.options;
      for (var i=0; i<opts.length; i++) {
        var selectedOpt;
        if (opts[i].selected) {
          selectedOpt = i;
          break;
        } else {
          selectedOpt = 0;
        }
      }
      for (var i=0; i<opts.length; i++) {
        var li = document.createElement('li');
        var txt = document.createTextNode(opts[i].text);
        li.appendChild(txt);
        li.selIndex = opts[i].index;
        li.selectID = obj.id;
        li.onclick = function() {
          selectMe(this);
        }
        if (i == selectedOpt) {
          li.className = 'selected';
          li.onclick = function() {
            this.parentNode.className += ' selectOpen';
            this.onclick = function() {
              selectMe(this);
            }
          }
        }
        if (window.attachEvent) {
          li.onmouseover = function() {
            this.className += ' hover';
          }
          li.onmouseout = function() {
            this.className = 
              this.className.replace(new RegExp(" hover\\b"), '');
          }
        }
        ul.appendChild(li);
      }
      // add the input and the ul
      obj.parentNode.appendChild(ul);
    }
    function selectMe(obj) {
      var lis = obj.parentNode.getElementsByTagName('li');
      for (var i=0; i<lis.length; i++) {
        if (lis[i] != obj) { // not the selected list item
          lis[i].className='';
          lis[i].onclick = function() {
            selectMe(this);
          }
       } else {
          setVal(obj.selectID, obj.selIndex);
          obj.className='selected';
          obj.parentNode.className = 
            obj.parentNode.className.replace(new RegExp(" selectOpen\\b"), '');
          obj.onclick = function() {
            obj.parentNode.className += ' selectOpen';
            this.onclick = function() {
              selectMe(this);
            }
          }
        }
      }
    }
    function setVal(objID, selIndex) {
      var obj = document.getElementById(objID);
      obj.selectedIndex = selIndex;
    }
    function setForm() {
      var s = document.getElementsByTagName('select');
      for (var i=0; i<s.length; i++) {
        selectReplacement(s[i]);
      }
    }
    function closeSel(obj) {
      // close the ul
    }
    window.onload = function() {
      (document.all && !window.print) ? null : setForm();
    }


//Specify full URL to down and right arrow images (23 is padding-right to add to top level LIs with drop downs):
var arrowimages={down:['downarrowclass', 'images/down.gif', 0], right:['rightarrowclass', 'images/right.gif']}

var slidermenu={

animateduration: {over: 200, out: 200}, //duration of slide in/ out animation, in milliseconds

buildmenu:function(menuid, arrowsvar){
	ICPmenu(document).ready(function($){
		var $mainmenu=$("#"+menuid+">ul")
		var $headers=$mainmenu.find("ul").parent()
		$headers.each(function(i){
			var $curobj=$(this)
			var $subul=$(this).find('ul:eq(0)')
			this._dimensions={w:this.offsetWidth, h:this.offsetHeight, subulw:$subul.outerWidth(), subulh:$subul.outerHeight()}
			this.istopheader=$curobj.parents("ul").length==1? true : false
			$subul.css({top:this.istopheader? this._dimensions.h+"px" : 0})
			$curobj.children("a:eq(0)").css(this.istopheader? {paddingRight: arrowsvar.down[2]} : {}).append(
				'<img src="'+ (this.istopheader? arrowsvar.down[1] : arrowsvar.right[1])
				+'" class="' + (this.istopheader? arrowsvar.down[0] : arrowsvar.right[0])
				+ '" style="border:0;" />'
			)
			$curobj.hover(
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					this._offsets={left:$(this).offset().left, top:$(this).offset().top}
					var menuleft=this.istopheader? 0 : this._dimensions.w
					menuleft=(this._offsets.left+menuleft+this._dimensions.subulw>$(window).width())? (this.istopheader? -this._dimensions.subulw+this._dimensions.w : -this._dimensions.w) : menuleft
					if ($targetul.queue().length<=1) //if 1 or less queued animations
						$targetul.css({left:menuleft+"px", width:this._dimensions.subulw+'px'}).slideDown(slidermenu.animateduration.over)
				},
				function(e){
					var $targetul=$(this).children("ul:eq(0)")
					$targetul.slideUp(slidermenu.animateduration.out)
				}
			) //end hover
		}) //end $headers.each()
		$mainmenu.find("ul").css({display:'none', visibility:'visible'})
	}) //end document.ready
}
}

//build menu with ID="myslidemenu" on page:
slidermenu.buildmenu("navmenu", arrowimages)





	   $(document).ready(
				function(){
					$('#news').innerfade({
						animationtype: 'slide',
						speed: 900,
						timeout: 6000,
						type: 'sequence',
						containerheight: '1em'
					});
					
					$('ul#portfolio').innerfade({
						speed: 500,
						timeout: 5000,
						type: 'sequence',
						containerheight: '264px'
					});
					
					$('.fade').innerfade({
						speed: 1000,
						timeout: 6000,
						type: 'random_start',
						containerheight: '1.5em'
					});
					

 
			});







