
function ShowLoading() {
    
    document.getElementById('divLoading').style.top = (windowState.getScrollY() + 200) + "px";
    document.getElementById('divLoading').style.display = "";
}

function HideLoading() {
    document.getElementById('divLoading').style.display = "none";
}

function showMessage(sMessage){
    document.getElementByID('notificationMessage').innerHTML = sMessage;
    document.getElementById('divMessage').style.display = "none";
}
var windowState = (function(){
    var readScroll = {scrollLeft:0,scrollTop:0};
    var readSize = {clientWidth:0,clientHeight:0};
    var readScrollX = 'scrollLeft';
    var readScrollY = 'scrollTop';
    var readWidth = 'clientWidth';
    var readHeight = 'clientHeight';
    function otherWindowTest(obj){
    if((document.compatMode)&&
    (document.compatMode == 'CSS1Compat')&&
    (document.documentElement)){
    return document.documentElement;
    }else if(document.body){
    return document.body;
    }else{
    return obj;
    }
    };
    if((typeof this.innerHeight == 'number')&&
    (typeof this.innerWidth == 'number')){
    readSize = this;
    readWidth = 'innerWidth';
    readHeight = 'innerHeight';
    }else{
    readSize = otherWindowTest(readSize);
    }
    if((typeof this.pageYOffset == 'number')&&
    (typeof this.pageXOffset == 'number')){
    readScroll = this;
    readScrollY = 'pageYOffset';
    readScrollX = 'pageXOffset';
    }else{
    readScroll = otherWindowTest(readScroll);
    }
    return {
    getScrollX:function(){
    return (readScroll[readScrollX]||0);
    },
    getScrollY:function(){
    return (readScroll[readScrollY]||0);
    },
    getWidth:function(){
    return (readSize[readWidth]||0);
    },
    getHeight:function(){
    return (readSize[readHeight]||0);
    }
    };
    })();


function ShowDialog(x)
    {
    //get viewport's width and height
    vpWidth = this.self.innerWidth;
    vpHeight = window.self.innerHeight;

    //get dialog's width and height
    dialogWidth=x.offsetWidth; 
    dialogHeight=x.offsetHeight;

    //calculate position
    dialogTop = (vpHeight/2) - (dialogHeight/2);
    dialogLeft = (vpWidth/2) - (dialogWidth/2);


    //Position the Dialog
    x.style.top =dialogTop+"px";
    x.style.left =dialogLeft+"px";

    a = x.style.display="block";

    }
    
function notEmpty(elem, helperMsg){
	if(elem.value.length == 0){
		alert(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
	}
	return true;
}

function notEmptyEither(elem, elem2, helperMsg){
	if(elem.value.length == 0 && elem2.value.length == 0){
		alert(helperMsg);
		elem.focus(); // set the focus to this input
		return false;
	}
	return true;
}

function isNumeric(elem, helperMsg){
	var numericExpression = /^[0-9]+$/;
	if(elem.value.match(numericExpression)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function isAlphabet(elem, helperMsg){
	var alphaExp = /^[a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function isAlphanumeric(elem, helperMsg){
	var alphaExp = /^[0-9a-zA-Z]+$/;
	if(elem.value.match(alphaExp)){
		return true;
	}else{
		alert(helperMsg);
		elem.focus();
		return false;
	}
}

function lengthRestriction(elem, min, max){
	var uInput = elem.value;
	if(uInput.length >= min && uInput.length <= max){
		return true;
	}else{
		alert("Please enter between " +min+ " and " +max+ " characters");
		elem.focus();
		return false;
	}
}

function madeSelection(elem, helperMsg){
	if(elem.value == "Please Choose"){
		alert(helperMsg);
		elem.focus();
		return false;
	}else{
		return true;
	}
}

function emailValidator(elem, helperMsg){
    if (elem.value.length != 0){
        var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
        if(elem.value.match(emailExp)){
	        return true;
        }else{
	        alert(helperMsg);
	        elem.focus();
	        return false;
        }
	}else{return true;}
	
}
   
function expandContent(elemName)
{
    
    if (this.document.getElementById(elemName).style.display == 'none'){
        this.document.getElementById(elemName).style.display = '';
        //this.document.getElementById(elemName).style.setAttribute('display','');
    }
    else
    {
        this.document.getElementById(elemName).style.display = 'none';
        //this.document.getElementById(elemName).style.setAttribute('display','none');

    }
    
}

function expandSpot(elemName)
{

    if (this.document.getElementById(elemName).style.display == 'none'){
        this.document.getElementById(elemName).style.display = '';
        //this.document.getElementById(elemName).style.setAttribute('display','');
        jQuery(function($) {
            $('#screen_spot').serialScroll({
			target:'#sections_spot',
			items:'li', // Selector to the items ( relative to the matched elements, '#sections' in this case )
			prev:'img.prev',// Selector to the 'prev' button (absolute!, meaning it's relative to the document)
			next:'img.next',// Selector to the 'next' button (absolute too)
			axis:'xy',// The default is 'y' scroll on both ways
			navigation:'#navigation_spot li a',
			duration:700,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
			force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
			onBefore:function( e, elem, $pane, $items, pos ){
				e.preventDefault();
				if( this.blur )
					this.blur();
			},
			onAfter:function( elem ){
				//'this' is the element being scrolled ($pane) not jqueryfied
			}
	        });
        });
    }
    else
    {
        this.document.getElementById(elemName).style.display = 'none';
        //this.document.getElementById(elemName).style.setAttribute('display','none');
    }

}

function expandBlog(elemName)
{

    if (this.document.getElementById(elemName).style.display == 'none'){
        this.document.getElementById(elemName).style.display = '';
        //this.document.getElementById(elemName).style.setAttribute('display','');

        jQuery(function($) {
        	$('#screen_blog').serialScroll({
				target:'#sections_blog',
				items:'li', // Selector to the items ( relative to the matched elements, '#sections' in this case )
				prev:'img.prev',// Selector to the 'prev' button (absolute!, meaning it's relative to the document)
				next:'img.next',// Selector to the 'next' button (absolute too)
				axis:'xy',// The default is 'y' scroll on both ways
				navigation:'#navigation_spot li a',
				duration:700,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
				force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
				
				onBefore:function( e, elem, $pane, $items, pos ){
					e.preventDefault();
					if( this.blur )
						this.blur();
				},
				onAfter:function( elem ){
					
				}
	        });
        });
    }
    else
    {
        this.document.getElementById(elemName).style.display = 'none';
        //this.document.getElementById(elemName).style.setAttribute('display','none');
    }

}


function expandReviews(elemName)
{

    if (this.document.getElementById(elemName).style.display == 'none'){
        this.document.getElementById(elemName).style.display = '';
        //this.document.getElementById(elemName).style.setAttribute('display','');
        jQuery(function($) {
        	var $screen_reviews = $('#screen_reviews');
	 
	        $screen_reviews.serialScroll({
		        target:'#sections_reviews',
		        items:'li', // Selector to the items ( relative to the matched elements, '#sections' in this case )
		        prev:'img.prev',// Selector to the 'prev' button (absolute!, meaning it's relative to the document)
		        next:'img.next',// Selector to the 'next' button (absolute too)
		        axis:'xy',// The default is 'y' scroll on both ways
		        navigation:'#navigation li a',
		        duration:700,// Length of the animation (if you scroll 2 axes and use queue, then each axis take half this time)
		        force:true, // Force a scroll to the element specified by 'start' (some browsers don't reset on refreshes)
		        interval:30000, // It's the number of milliseconds to automatically go to the next
        		
		        onBefore:function( e, elem, $pane, $items, pos ){
			        e.preventDefault();
			        if( this.blur )
				        this.blur();
		        },
		        onAfter:function( elem ){
			        //'this' is the element being scrolled ($pane) not jqueryfied
		        }
	        });
        });
    }
    else
    {
        this.document.getElementById(elemName).style.display = 'none';
        //this.document.getElementById(elemName).style.setAttribute('display','none');
    }

}

function validateQQ() {

	// Make quick references to our fields
	var name = document.getElementById('ctl00$txt_qq_name');
	var phone = document.getElementById('ctl00$txt_qq_phone');
	var email = document.getElementById('ctl00$txt_qq_email');
	var message = document.getElementById('ctl00$txt_qq_message');

	
	// Check each input in the order that it appears in the form!
	if(notEmpty(name, "Please enter your name")){
	    if(notEmptyEither(phone, email, "Please enter either a phone number or email address")){
			    
		    if(emailValidator(email, "Please enter a valid email address")){
		        if(notEmpty(message, "Please enter a message")){
			        return true;
			    }
		    }

		 }
	}
	
	return false;
	
}
function validateContact() {

	// Make quick references to our fields
	var name = document.getElementById('ctl00_ContentPlaceHolder1_txt_contact_name');
	var phone = document.getElementById('ctl00_ContentPlaceHolder1_txt_contact_phone');
	var email = document.getElementById('ctl00_ContentPlaceHolder1_txt_contact_email');

	
	// Check each input in the order that it appears in the form!
	if(notEmpty(name, "Please enter your name")){
	    if(notEmptyEither(phone, email, "Please enter either a phone number or email address")){
			    
		    if(emailValidator(email, "Please enter a valid email address")){
		        
			     return true;
		    }

		 }
	}
	
	return false;
	
}

