var DebugMode=false; //Show Alerts

/**
 * Change opacity whene cursor is over the logo's parts.
 */ 
$JQ(document).ready(function() {
	$JQ('.jhover').each(function() {
		$JQ(this).hover(function() {
			$JQ(this.childNodes[0]).stop().animate({ opacity: 0.5 }, 500);
			$JQ(this.childNodes[1]).stop().animate({ opacity: 0.5 }, 500);
		},
		function() {
			$JQ(this.childNodes[0]).stop().animate({ opacity: 1.0 }, 500);
			$JQ(this.childNodes[1]).stop().animate({ opacity: 1.0 }, 500);
		});
	});
});

/**
 * Change opacity whene cursor is over the image in "Recent Project" section.
 */
$JQ(document).ready(function() {
	$JQ('.jhoverImg').each(function() {
		$JQ(this).hover(function() {
		
			$JQ(this).stop().animate({ opacity: 1.0 }, 1000);
		},
		function() {
			$JQ(this).stop().animate({ opacity: 0.8 }, 500);
		});
	});
});

/**
 * Lightbox configuration.
 */
 /*
$JQ(function() {
	$JQ('.lightbox').lightBox({
		fixedNavigation:true,
		imageLoading: 'javascript/images/lightbox-ico-loading.gif',
		imageBtnClose: 'javascript/images/lightbox-btn-close.gif',
		imageBtnPrev: 'javascript/images/lightbox-btn-prev.gif',
		imageBtnNext: 'javascript/images/lightbox-btn-next.gif'
	});
});
*/
/**
 * Assign the functions to moseover/moseout event for the items from the main menu.
 */ 
$JQ(function() {
    $JQ(".i")
        .mouseover(function() {
			this.childNodes[0].style.display = 'none';
			this.childNodes[1].style.display = 'block';
        })
        .mouseout(function() {
        	this.childNodes[0].style.display = 'block';
			this.childNodes[1].style.display = 'none';
        });
});

/**
 * Assign the functions to moseover/moseout event for the main page's boxes.
 */ 
$JQ(function() {
    $JQ("div.box")
        .mouseover(function() {
        	this.childNodes[0].style.backgroundImage = 'url(graph/home/main-box-header-bg-hover.png)';
        })
        .mouseout(function() {
        	this.childNodes[0].style.backgroundImage = 'url(graph/home/main-box-header-bg.png)';
        });
});

/**
 *	This function controlles apperance of the "Sydney Eletricians" slogan;
 */ 
function initSlogan()
{
	var sloganText = document.getElementById( 'sloganText' );
	sloganText.style.display = 'block';
	$JQ(sloganText).stop().animate({ opacity: 1.0 }, 6500);
}

/***** ON LOAD FUNCTION *******************************************/

/**
 * This function stops execution code for some time;
 *
 * @param int naptime in miliseconds  
 */
function sleep( naptime )
{
	var startingMSeconds = (new Date()).getTime();
	while( true )
		if((new Date()).getTime() - startingMSeconds > naptime)
			break;
}

/*
function validateEmail(email) {
	invalidChars = " /:,;"

	if (email == "") {						// cannot be empty
		return false
	}
	for (i=0; i<invalidChars.length; i++) {	// does it contain any invalid characters?
		badChar = invalidChars.charAt(i)
		if (email.indexOf(badChar,0) > -1) {
			return false
		}
	}
	atPos = email.indexOf("@",1)			// there must be one "@" symbol
	if (atPos == -1) {
		return false
	}
	if (email.indexOf("@",atPos+1) != -1) {	// and only one "@" symbol
		return false
	}
	periodPos = email.indexOf(".",atPos)
	if (periodPos == -1) {					// and at least one "." after the "@"
		return false
	}
	if (periodPos+3 > email.length)	{		// must be at least 2 characters after the "."
		return false
	}
	return true
}
*/
/*
function MM_preloadImages(){ //v3.0  
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function CheckFormContact(){
	var error = "";
	if (document.contact_formd.name.value==""){ error += "Please enter Your Name.\n"; }
	else{ if(document.contact_formd.name.value.length<=4){ error += "Please enter Your Name [min. 5 chars].\n"; } }
	if (document.contact_formd.mail.value==""){ error += "Please enter E-mail.\n";	}
	else{ if(!validateEmail(document.contact_formd.mail.value)){ error += "Incorrect E-mail address.\n"; } }
	if (document.contact_formd.msg.value==""){ error += "Please enter Message.\n"; }
	else{ if(document.contact_formd.msg.value.length<=4){ error += "Please enter Message [min. 5 chars].\n"; } }
	
	if (error!= "") { alert(error); return false;	}
	else { return true;	}
}
*/
function jSloganRun(ID,status){
	try{
		if(!ID || ID==''){ return false; }
		if(!status || status==''){  self.setTimeout("jSloganRun('"+ID+"','active')", 1000); return false; }
		
		$JQ('#sloganText').css('opacity','0');
		$JQ('#sloganText').css('display','block');
	    $JQ('#sloganText').animate({ opacity: "1" }, 3000);		
	}catch(err){ if(DebugMode==true){ alert('jSloganRun: '+err); }}
}
/*
function setBlur(){ 
	var x = document.getElementsByTagName('a');
	
	for (var i=0;i<x.length;i++){
		x[i].onfocus = function () { this.blur(); }
	}
}*/
