// JavaScript Document
// Henrique Moser | hdmoser.com

/* ************** FUNCTIONS ************** */
window.onload = initAll;

function initAll(){
	txtarea_size();
}
function txtarea_size(){
	
	if (document.getElementsByTagName("textarea").length == 1){
		if (checkBrowser() && checkVersion()){
			var textarea = String((128 + 32) +"px");
			document.getElementsByTagName("textarea")[0].style.height = textarea;		
		}
	}
}

function checkBrowser (){
	var ie = new RegExp ("MSIE");
	var confirmation = new Boolean ();
	var vconfirmation = new Boolean ();
		
	if (ie.test(navigator.userAgent)){
		confirmation = true;
	} else {
		confirmation = false;
	}
	return confirmation;
}

function checkVersion (){
	if ((/MSIE (\d+\.\d+);/).test(navigator.userAgent)){ //test for MSIE x.x;
		var ieversion = new Number(RegExp.$1) // capture x.x portion and store as a number
		if (ieversion>=8)
			vconfirmation = false;
		else if (ieversion>=7){
			vconfirmation = true;
		}
		//alert (vconfirmation);
	return vconfirmation;
	}
}

// POP function
function pop_page (filename, pageHeight){
	var pageWidth = 645;
	if (checkBrowser() && checkVersion()){
		pageHeight += 25;
		pageWidth += 25;
	}
	window.open (filename, "pop","width="+ pageWidth +",height="+ pageHeight+ ", resizable=yes, scrollbars=yes");
}
// contact.php	  h575
// started.php	  h500
// white papers	  h420
// case studies	  h420
// white papers	  h505
// send profile	  h530
// open works	  h420

function txt_sending (){
	document.getElementById("alert").innerHTML = "Sending message. Please wait.";	
}

function change_button(boolean , path){
	if (boolean == true){
		document.getElementById("submit_bt").src= path.concat("img/elements/submit_en_over.png");
	} else {
		document.getElementById("submit_bt").src= path.concat("img/elements/submit_en.png");
	}
}

function change_bg (imageObj, status, filename){
	var on ="_on.png";
	var off =".png";

	if (status == true){
		imageObj.src = filename.concat(on);	
	} else {
		imageObj.src = filename.concat(off);	
	}
}
