// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function hideAll(element,size) {
	
	for (i=1;i<=size;i=i+1) {
	   	document.getElementById(element + i).style.visibility = "hidden";
	}
}

function unhide(element,elementPosition) {
	
   	document.getElementById(element + elementPosition).style.visibility = "visible";
}

function hide(element,elementPosition) {
	
   	document.getElementById(element + elementPosition).style.visibility = "hidden";
}

function setImage(elementId){
	
document.getElementById('mainContainer').innerHTML = document.getElementById(elementId).innerHTML;
	
}


function dissappearAll(element,size) {
	
	for (i=1;i<=size;i=i+1) {
	   	document.getElementById(element + i).style.display = "none";
	}
}

function press_body_onload () {
	setImage('pressArticle1');
	setSlideWidth();
	pressArrowsdisplay();
}

function setSlideWidth(){
    d = document.getElementById('associates_info_press_article_slides');
    var elements = d.getElementsByTagName("img");
    var totalWidth = 0;
    for (var i=0 ; i<elements.length ; i++) {
        totalWidth = totalWidth + elements[i].width + 10;
    }
   d.style.width=totalWidth+'px';
	
}

function pressArrowsdisplay(){
	
	var containerDiv = document.getElementById('associates_info_press_article_slides_container');
	var slidesDiv = document.getElementById('associates_info_press_article_slides');
	var leftArrow = document.getElementById('leftArrow');
	var rightArrow = document.getElementById('rightArrow');


	leftArrow.style.visibility = "visible";
	rightArrow.style.visibility = "visible";


	if (containerDiv.scrollLeft <= 0){
			leftArrow.style.visibility = "hidden";
	}

	if (containerDiv.scrollLeft >= (parseInt(slidesDiv.style.width) - parseInt(containerDiv.style.width))){
			
			rightArrow.style.visibility = "hidden";
	}

}

function blog_body_onload () {
	$(function() {
		    // this initialises the demo scollpanes on the page.
		   $('#scrollPanelBlue').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16, height: 1000});
	    });
}

function residential_body_onload(slideCount) {
	startHorizontalSlideShow(-580, 'slideshowImage', slideCount);
}
function commercial_body_onload(slideCount) {
	startHorizontalSlideShow(-580, 'slideshowImage', slideCount);
}
function vicentes_homes_body_onload(slideCount) {
	startHorizontalSlideShow(-580, 'slideshowImage', slideCount);
}
function residential_info_body_onload () {
	$(function() {
		    // this initialises the demo scollpanes on the page.
		   $('#scrollPanelGreen').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16, height: 1000});
	    });
}
function commercial_info_body_onload () {
	$(function() {
		    // this initialises the demo scollpanes on the page.
		   $('#scrollPanelBlue').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16, height: 1000});
	    });
}
function vicentes_homes_info_body_onload () {
	$(function() {
		    // this initialises the demo scollpanes on the page.
		   $('#scrollPanelBlue').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16, height: 1000});
	    });
}

function readHideComments(elementId) {
	
    var comments = document.getElementById("comment" + elementId);
    var button = document.getElementById("readComments" + elementId);

    if(comments.style.display == "block") {
	    comments.style.display = "none";
        button.innerHTML = "Read comments";
        }
    else {
        comments.style.display = "block";
        button.innerHTML = "Hide comments";
    }
	$(function() {
		    // this initialises the demo scollpanes on the page.
		   $('#scrollPanelBlue').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16, height: 1000});
	  });	
} 

function showCommentForm(elementId){

    var commentForm = document.getElementById("addComment" + elementId);
    
    if(commentForm.style.display == "block") {
	    commentForm.style.display = "none";
    }
    else {
        commentForm.style.display = "block";
    }
	$(function() {
		    // this initialises the demo scollpanes on the page.
		   $('#scrollPanelBlue').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16, height: 1000});
    });	
}

function home_bio_body_onload () {
	$(function() {
		    // this initialises the demo scollpanes on the page.
		   $('#scrollPanelBlue').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16, height: 1000});
	    });
}

function ass_bio_body_onload () {
	$(function() {
		    // this initialises the demo scollpanes on the page.
		   $('#scrollPanelBlue').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16, height: 1000});
	    });
}
function home_about_us_body_onload() {
	$(function() {
	    // this initialises the demo scollpanes on the page.
	   $('#scrollPanelBlue').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16, height: 1000});
	});
}

function home_add_showrooms_body_onload() {
	$(function() {
	    // this initialises the demo scollpanes on the page.
	   $('#scrollPanelBlue').jScrollPane({showArrows:true, scrollbarWidth: 15, arrowSize: 16, height: 1000});
	});	
}
