// JavaScript Document
var sampImage;
var fontFamily1="Trebuchet MS";
var hoverDiv;
var businessText = new Array();
var pageText = new Array();
var parTxt = new Array();
var divs = new Array();
var picArr = new Array();
var objBus = new Array();

function resizeBusiness(){ //alert('busiene');
var windowWidth, windowHeight, allResized;
	
	windowWidth=getWindowWidth();	
	windowHeight=getWindowHeight();
	myMargin=Math.round(windowWidth/150);
	myBorder=Math.round(windowWidth/1000)+"px solid #BF617E";
    myBorderWidth = Math.round(windowWidth/1000);
	
	if (!myBusiness.appendChild(businessPic)) { return false; }
	if (!scaleToWidth(businessPic, mainDiv.offsetWidth)) { return false; }
	businessPic.style.position="absolute";
	businessPic.style.visibility="hidden";
	
//	greenPic.style.height=Math.round(businessPic.offsetHeight) + "px";	
	
	//for the title text
	titleFontSize = Math.round(bodyDiv.offsetWidth/70) + "px";
	if (!myBusiness.appendChild(businessTitle)) { return false; }
	businessTitle.style.top=myMargin*2.7 + "px";
	businessTitle.style.left=Math.round(mainDiv.offsetWidth/42) + "px";
	businessTitle.style.width=Math.round(mainDiv.offsetWidth*0.5) + "px";
	businessTitle.style.fontSize=titleFontSize;
	businessTitle.style.position="absolute";
	
	if (!myBusiness.appendChild(businessBg)) { return false; }
	if (!scaleToWidth(businessBg, mainDiv.offsetWidth*0.94)) { return false; }
	businessBg.style.top = myMargin*7 + "px";
	businessBg.style.left = businessTitle.offsetLeft + "px";
	businessBg.style.position="absolute";
	
	if (!myBusiness.appendChild(topImg)) { return false; }
	if (!scaleToWidth(topImg, mainDiv.offsetWidth*0.75)) { return false; }
	topImg.style.top = myMargin*12 + "px";
	topImg.style.left = businessTitle.offsetLeft*4.2 + "px";
	topImg.style.position="absolute";
	
	if (!myBusiness.appendChild(defaultPic)) { return false; }
	if (!scaleToWidth(defaultPic, mainDiv.offsetWidth*0.8)) { return false; }
	defaultPic.style.top = myMargin*15 + "px";
	defaultPic.style.left = businessTitle.offsetLeft*4.2 + "px";
	defaultPic.style.position="absolute";
	
	if (!myBusiness.appendChild(bottomImg)) { return false; }
	if (!scaleToWidth(bottomImg, mainDiv.offsetWidth*0.75)) { return false; }
	bottomImg.style.top = defaultPic.offsetHeight*1.07 + defaultPic.offsetTop + "px";
	bottomImg.style.left = businessTitle.offsetLeft*6.2 + "px";
	bottomImg.style.position="absolute";
	
	fontSizeTxt=Math.round(bodyDiv.offsetWidth/70) + "px";
	if (!myBusiness.appendChild(businessTxt)) { return false; }
	businessTxt.style.top = bottomImg.offsetHeight*5 + bottomImg.offsetTop + "px"; //myMargin*35 + "px";
	businessTxt.style.left = defaultPic.offsetLeft + "px";
	businessTxt.style.fontSize = fontSizeTxt;
	businessTxt.style.width = Math.round(mainDiv.offsetWidth*0.7) + "px";
	businessTxt.style.position = "absolute";
	
	fontSize=Math.round(bodyDiv.offsetWidth/75) + "px";
	
	for(i=0;i<businessText.length;i++) {
		if (!myBusiness.appendChild(parTxt[i])) { return false; }
		if(i==0) {
			parTxt[i].style.left=Math.round(mainDiv.offsetWidth/10) + "px";
			parTxt[i].style.top = businessBg.offsetHeight + businessBg.offsetTop*1.08 + "px"; //myMargin*50 + "px";
		}
		else if(i==4) {
			parTxt[i].style.top = businessBg.offsetHeight + businessBg.offsetTop*1.08 + "px";
			parTxt[i].style.left=Math.round(mainDiv.offsetWidth/2) + "px";
		}
		else if(i==5) {
			parTxt[i].style.top = Math.round(parTxt[i-1].offsetTop + parTxt[i-1].offsetHeight + parTxt[i-1].offsetHeight*0.4) + "px";
			parTxt[i].style.left=Math.round(mainDiv.offsetWidth/2) + "px";
		}
		else if(i==6) {
			parTxt[i].style.top = Math.round(parTxt[i-1].offsetTop + parTxt[i-1].offsetHeight + parTxt[i-1].offsetHeight*0.4) + "px";
			parTxt[i].style.left=Math.round(mainDiv.offsetWidth/2) + "px";
		}
		else {
			parTxt[i].style.left=Math.round(mainDiv.offsetWidth/10) + "px";
			parTxt[i].style.top = Math.round(parTxt[i-1].offsetTop + parTxt[i-1].offsetHeight + parTxt[i-1].offsetHeight*0.4) + "px";
		}
		//parTxt[i].onmouseover = function() { onMouseOverBus(picArr[i]) };
		parTxt[i].style.fontSize=fontSize;
		parTxt[i].style.zIndex=3;
	}
	
	// for(t=0;t<4;t++) {
		// if (!myBusiness.appendChild(divs[t])) { return false; }
		// divs[t].style.height = "200px";
	// }
	
	if (!myBusiness.appendChild(div1)) { return false; }
	if (!scaleToWidth(div1, businessBg.offsetWidth)) { return false; }
	div1.style.height = Math.round(mainDiv.offsetWidth/30) + "px";
	div1.style.top = businessBg.offsetHeight + businessBg.offsetTop + "px";// myMargin*50 + "px";
	div1.style.left = businessBg.offsetLeft + "px";
	
	if (!myBusiness.appendChild(div2)) { return false; }
	if (!scaleToWidth(div2, businessBg.offsetWidth)) { return false; }
	div2.style.height = Math.round(mainDiv.offsetWidth/30) + "px";
	div2.style.top = div1.offsetHeight + div1.offsetTop + "px";// myMargin*50 + "px";
	div2.style.left = businessBg.offsetLeft + "px";
	
	if (!myBusiness.appendChild(div3)) { return false; }
	if (!scaleToWidth(div3, businessBg.offsetWidth)) { return false; }
	div3.style.height = Math.round(mainDiv.offsetWidth/30) + "px";
	div3.style.top = div2.offsetHeight + div2.offsetTop + "px";// myMargin*50 + "px";
	div3.style.left = businessBg.offsetLeft + "px";
	
	if (!myBusiness.appendChild(div4)) { return false; }
	if (!scaleToWidth(div4, businessBg.offsetWidth)) { return false; }
	div4.style.height = Math.round(mainDiv.offsetWidth/30) + "px";
	div4.style.top = div3.offsetHeight + div3.offsetTop + "px";// myMargin*50 + "px";
	div4.style.left = businessBg.offsetLeft + "px";
	
	myBusiness.style.height = Math.round(businessPic.offsetHeight) + "px";
				
	myBusiness.style.visibility="hidden";
	
	return true;
}

function createbusinessPage(){
	//create home page
	myBusiness = createDiv();
	myBusiness.style.position="absolute";
	clearMargins(myBusiness);
	
	loading=displayText("Please wait Loading...");
	loading.style.visibility="hidden";
	loading.style.fontFamily="verdana";
	mainDiv.appendChild(loading);

	//for the detection of the browser in our main picture
	if (browserInfo().browserShortName=="Firefox") {
		
		//alert("Firefox")				
		businessPic = xImage("images/avp_bg3.jpg");
		businessPic.oncontextmenu=protectImage;
		
	} else { 
		if (browserInfo().browserShortName=="IE") {
	
		//alert("IE")
		businessPic = xImage("images/contentphotobg.png");
		businessPic.oncontextmenu=protectImage;
		businessPic.style.height="620px";		
		}
		else {
		businessPic = xImage("images/contentphotobg.png");
		businessPic.oncontextmenu=protectImage;
		businessPic.style.height="620px";
		}
	}
	
	//end of our browser detection
	
	//for the title 
	businessTitle = document.createElement("p");
	businessTitle.innerHTML="Business Lines";
	businessTitle.style.fontFamily="Trebuchet MS";
	businessTitle.style.position = "absolute";
	businessTitle.style.color = "#8E7070";
	businessTitle.style.fontWeight="bold";
	clearMargins(businessTitle);
	
	businessBg = xImage("images/businesslinesbg.png");
	businessBg.style.position = "absolute";
	clearMargins(businessBg);
	
	topImg = xImage("images/businesslines-topborderPic.jpg");
	topImg.style.position = "absolute";
	clearMargins(topImg);
	
	bottomImg = xImage("images/businesslines-bottomborderPic.jpg");
	bottomImg.style.position = "absolute";
	clearMargins(bottomImg);
	
	defaultPic = xImage("images/businessLinesDefaultPic.jpg");
	defaultPic.style.position = "absolute";
	clearMargins(defaultPic);
	
	businessTxt = document.createElement("p");
	businessTxt.innerHTML="AVP Construction provides a wide range of construction services.<br/>We are professionals in both construction and project management with long experience from various major projects we have handled.";
	businessTxt.style.fontFamily="Trebuchet MS";
	businessTxt.style.width="90%";
	businessTxt.style.fontWeight="bolder";
	businessTxt.style.position = "absolute";
	businessTxt.style.color = "#787274";
	clearMargins(businessTxt);
	
	businessText[0] = "Road, Highway pavement, Railways";
	businessText[1] = "Airport horizontal structures and Bridges";
	businessText[2] = "Hydro - electric power plant";
	businessText[3] = "Irrigation and Flood control";
	businessText[4] = "Housing construction & Site development";
	businessText[5] = "Port, Harbor & Offshore engineering";
	businessText[6] = "Construction of buildings";
	
	for(i=0;i<businessText.length;i++) {
		pageText = createP(businessText[i]);	
		pageText.style.fontFamily="Trebuchet MS";
		pageText.style.width="60%";
		pageText.style.fontWeight="bolder";
		pageText.style.position = "absolute";
		//pageText.onmouseover = function() { onMouseOverBus(picArr[i]) };
		pageText.onmouseover = function() { this.style.color = "#FFFFFF" };
		pageText.onmouseout = function() { this.style.color = "#98AEBB" };
		pageText.style.color = "#98AEBB";
		clearMargins(pageText);
		parTxt[i]=pageText;
	}
	
	div1 = createDiv();
	div1.style.position = "absolute";
	div1.style.backgroundColor = "#000000";
	clearMargins(div1);
	
	div2 = createDiv();
	div2.style.position = "absolute";
	div2.style.backgroundColor = "#323232";
	clearMargins(div2);
	
	div3 = createDiv();
	div3.style.position = "absolute";
	div3.style.backgroundColor = "#000000";
	clearMargins(div3);
	
	div4 = createDiv();
	div4.style.position = "absolute";
	div4.style.backgroundColor = "#323232";
	clearMargins(div4);
		
	myBusiness.resize=resizeBusiness;
		
return myBusiness;
}	

// function onMouseOverBus(objBus) {
	//this.style.color = "#FFFFFF"
	//obj2.style.fontWeight = "bolder";
	// alert(objBus);
	// hoverDiv = document.createElement("div"); //createDiv();
	// hoverDiv.style.position = "absolute";
	// hoverDiv.style.top = defaultPic.offsetTop + "px"; //obj2.offsetTop+obj2.offsetHeight+ "px";
	// hoverDiv.style.left =  defaultPic.offsetLeft + "px"; //obj2.offsetLeft+obj2.offsetWidth+"px";
	// hoverDiv.style.height = mainDiv.offsetHeight*0.2 + "px";
	// hoverDiv.style.width = mainDiv.offsetWidth*0.48 + "px";
	// hoverDiv.style.border = "1px solid green";
	// mainDiv.appendChild(hoverDiv);
	
	//img.style.height = hoverDiv.offsetHeight+"px";
	//hoverDiv.appendChild(img);
	
	//hoverTxt = createP(text);
	//hoverTxt.style.position="absolute";
	//hoverDiv.appendChild(hoverTxt);
// }

// function onMouseOut2(obj2) {
	// hoverDiv.style.visibility = "hidden";
	// obj2.style.fontWeight = "";
// }
