
  
/* TEMPLATE CONTROL COPY
-------------------------------------------------------------------------------------*/

function announce(){
	if(window.event .keyCode==0x11){
   		window.alert ("Please contact adminstrator for resource duplication. Thank you.");
		}
	}
	
function init(){
	window.alert('FLEAVE DESIGN WEBCMS DEMO\nYou are visiting the WebCMS demo website presented by Fleave Design.\nThis is not the business official website.');
}


/* EMAIL VERIFICATION
-------------------------------------------------------------------------------------*/

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("INVALID E-MAIL!\nPlease enter your valid e-mail address.")
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("INVALID E-MAIL!\nPlease enter your valid e-mail address.")
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("INVALID E-MAIL!\nPlease enter your valid e-mail address.")
		    return false
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("INVALID E-MAIL!\nPlease enter your valid e-mail address.")
		    return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("INVALID E-MAIL!\nPlease enter your valid e-mail address.")
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("INVALID E-MAIL!\nPlease enter your valid e-mail address.")
		    return false
		 }		
		 if (str.indexOf(" ")!=-1){
		    alert("INVALID E-MAIL!\nPlease enter your valid e-mail address.")
		    return false
		 }
 		 return true
 	}

function checkSubscribeForm(){
	x=document.subscribe;	
	
	if (echeck(x.subscribe_email.value) == false){
		alert("INVALID FIELD\nPlease provide valid email address.");
		x.subscribe_email.focus(); 
		return false;
	}
	return true;
}


/* SLIDE MENU EFFECT
-------------------------------------------------------------------------------------*/

var slideMenu=function(){
	var sp,st,t,m,sa,l,w,sw,ot;
	return{
		build:function(sm,sw,mt,s,sl,h){
			sp=s; st=sw; t=mt;
			m=document.getElementById(sm);
			sa=m.getElementsByTagName('li');
			l=sa.length; w=m.offsetWidth; sw=w/l;
			ot=Math.floor((w-st)/(l-1)); var i=0;
			for(i;i<l;i++){s=sa[i]; s.style.width=sw+'px'; this.timer(s)}
			if(sl!=null){m.timer=setInterval(function(){slideMenu.slide(sa[sl-1])},t)}
		},
		timer:function(s){s.onmouseover=function(){clearInterval(m.timer);m.timer=setInterval(function(){slideMenu.slide(s)},t)}},
		slide:function(s){
			var cw=parseInt(s.style.width,'10');
			if(cw<st){
				var owt=0; var i=0;
				for(i;i<l;i++){
					if(sa[i]!=s){
						var o,ow; var oi=0; o=sa[i]; ow=parseInt(o.style.width,'10');
						if(ow>ot){oi=Math.floor((ow-ot)/sp); oi=(oi>0)?oi:1; o.style.width=(ow-oi)+'px'}
						owt=owt+(ow-oi)}}
				s.style.width=(w-owt)+'px';
			}else{clearInterval(m.timer)}
		}
	};
}();


