//Estimator script file

var containerSize = 300;
var numTabs = 10;
var defaultContent = "main_site";


function showContent(tabId){

   var    imageName = "";
   var    Input_Doc = null;
  
  
   Input_Doc = getInputFrameDoc();
   
 
   for(counter = 1;counter <= numTabs ;counter ++){
      
	  
      Input_Doc.all["Content" + counter].style.display = "none";
      
   
   }
   
   //display requested tab
   Input_Doc.all[tabId].style.display = "block";
   
   //determine the appropriate image for the requested tab
   
   if(tabId == "Content1"){
   		imageName = "images/living.gif";
		imageName2 = "images/title_living.jpg";}
   else if(tabId == "Content2"){
   		imageName = "images/dining.jpg";
		imageName2 = "images/title_dining.jpg";}
   else if(tabId == "Content3"){
   		imageName = "images/bedroom.jpg";
		imageName2 = "images/title_bedroom.jpg";}
   else if(tabId == "Content4"){
   		imageName = "images/kids.jpg";
		imageName2 = "images/title_nursery.jpg";}
   else if(tabId == "Content5"){
   		imageName = "images/kitchen.jpg";
		imageName2 = "images/title_kitchen.jpg";}
   else if(tabId == "Content6"){
   		imageName = "images/appliances.jpg";
		imageName2 = "images/title_appliances.jpg";}
   else if(tabId == "Content7"){
   		imageName = "images/outside.jpg";
		imageName2 = "images/title_outside.jpg";}
   else if(tabId == "Content8"){
   		imageName = "images/misc.jpg";
		imageName2 = "images/title_misc.jpg";}
   else if(tabId == "Content9"){
   		imageName = "images/box.gif";
		imageName2 = "images/title_boxes.jpg";}
   else if(tabId == "Content10"){
   		imageName = "images/custom.jpg";
		imageName2 = "images/title_custom.jpg";}
   
   //set proper images for requested tab
   top.frames["mid_frame"].document.images["image_content"].src = imageName;
   top.frames["mid_frame"].document.images["image_title"].src = imageName2;
   
}

function setDefaultCalculations(){
	
	if(typeof(top.frames["mid_frame"]) != "object")
		return;
	
	top.frames["mid_frame"].document.all["text_cubic_feet"].innerText = "0";
	top.frames["mid_frame"].document.all["text_num_containers"].innerText = "0";
	top.frames["mid_frame"].document.all["text_percent_full"].innerText = "0%";
	
	top.frames["mid_frame"].document.images["image_percentage"].src = "images/box0.jpg";
	
	top.totalFeet = 0;
	top.currentItemTotalFeet = 0;
	top.customItemTotalFeet = 0;
	
}


function itemOnFocus(item_name, value){
	
	var total = 0;
	
	total = getFeetFromName(item_name) * parseInt(value);
	
	if(isNaN(total))
		total = 0;
	
	top.currentItemTotalFeet = total;
	
}

function itemOutOfFocus(item_name, value){
	
	var total = 0;
	
	total = getFeetFromName(item_name) * parseInt(value);
	
	if(isNaN(total))
		total = 0;
	
	top.totalFeet = top.totalFeet - top.currentItemTotalFeet + total;
	top.currentItemTotalFeet = 0;
	
	//alert (top.frames["mid_frame"]);
	
	displayCalculations(top.totalFeet + top.customItemTotalFeet);
	
}

function customItemOutOfFocus(){
	top.customItemTotalFeet = calculateCustomTotals();
	displayCalculations(top.totalFeet + top.customItemTotalFeet);
}

function getFeetFromName(item_name){
	
	var dimensions = "";
	var commaIndex = -1;
	
	//get a string value of dimensions 
	dimensions = item_name
	commaIndex = dimensions.lastIndexOf(",");
	dimensions = dimensions.substring(commaIndex + 1, dimensions.length );
	
	return dimensions;
	
}

//function calculates cubic feet for specified items and determines the number of
//containers that would be needed and how full is the last container (in percentage terms)
//function then sets proper images and prints to html
function recalculateFeet() {
	
	var input_doc;
	var total = 0;
	var dimensions = 0;
	var commaIndex = -1;
	var itemCount = 0;
	var percentage = 0;
	var numContainers = 0;
	var totalLastContainer = 0;
	var remainder = 0;
	var percentageText = "";
	var height = 0;
	var width = 0;
	var length = 0;
	
	
	input_doc = getInputFrameDoc();

	
	if(typeof(input_doc) != "object" || input_doc == null)
		return;
	
	for(counter = 0;counter < input_doc.forms.length; counter ++ ){
		
		//if(input_doc.forms[counter].name.indexOf("ItemInput") == -1)
		//	continue;
			
		//alert(document.forms[counter].elements[0].name);
		
		//get a string value of dimensions 
		dimensions = input_doc.forms[counter].elements[0].name
		commaIndex = dimensions.lastIndexOf(",");
		dimensions = dimensions.substring(commaIndex + 1, dimensions.length );
		
		
	    if(isNaN(dimensions) || dimensions == "" )
			continue;
			//alert(input_doc.forms[counter].elements[0].name);
			
		dimensions = parseInt(dimensions);
		
		itemCount = parseInt(input_doc.forms[counter].elements[0].value);
		
		
		if(isNaN(itemCount))
			itemCount = 0;

		
		total = total + (dimensions * itemCount) ;
		
	}
	
	top.totalFeet = total;
	top.currentItemTotalFeet = 0;
	top.customItemTotalFeet = calculateCustomTotals();
	
	//total = total + calculateCustomTotals();

	displayCalculations(top.totalFeet + top.customItemTotalFeet);
	
}

function calculateCustomTotals(){
	
	var input_doc;
	var total = 0;
	var height = 0;
	var width = 0;
	var length = 0;
	
	
	input_doc = getInputFrameDoc();

	
	if(typeof(input_doc) != "object" || input_doc == null)
		return;
	
	//calculate custom items (there are 5 of them)
	for(counter = 1; counter < 32; counter = counter + 4){
		
		height = input_doc.forms["Content10_Form_" + (counter + 1)].elements[0].value;
		height = (typeof(height) == "undefined" || isNaN(height) || height == "") ? 0 : parseFloat(height);
		
		//alert(height);
		
		width = input_doc.forms["Content10_Form_" + (counter+2)].elements[0].value;
		width = (typeof(width) == "undefined" || isNaN(width) || width == "") ? 0 : parseFloat(width);
		
		//alert(width);
		
		length = input_doc.forms["Content10_Form_" + (counter+3)].elements[0].value;
		length = (typeof(length) == "undefined" || isNaN(length) || length == "") ? 0 : parseFloat(length);
		
		//alert(height + width + length);
		
		total = total + (height * width * length) ;
	
	}
	
	return total;
	
}

function displayCalculations(total){

	var dimensions = 0;
	var commaIndex = -1;
	var itemCount = 0;
	var percentage = 0;
	var numContainers = 0;
	var totalLastContainer = 0;
	var remainder = 0;
	var percentageText = "";
	var height = 0;
	var width = 0;
	var length = 0;
	var input_doc = null;
	var imageName = "";
	

	
	if(top.ignoreDisplay == true)
		return;
	
	remainder = (total % containerSize);
	numContainers = (parseInt(total / containerSize)) + ( remainder > 0 ? 1 : 0); 
	
	//alert(remainder);
	//alert(numcontainers);
	
	if(numContainers == 0)
		percentage = 0;
	else {
		 if(remainder == 0){
			percentage = 100;
		 }
		 else{
			percentage = remainder / containerSize * 100;
		 }
		 
	}
	
	if(percentage < 1 && percentage > 0)
		percentageText = "0.5%";
	else
		percentageText = parseInt(percentage) + "%";
		
	
	if(percentage <=0 )
		imageName = "box0.jpg";
	else if(percentage < 8)
		imageName = "box1.jpg";
	else if(percentage < 14.5)
		imageName = "box2.jpg";
	else if(percentage < 21)
		imageName = "box3.jpg";
	else if(percentage < 27.5)
		imageName = "box4.jpg";
	else if(percentage < 33)
		imageName = "box5.jpg";
	else if(percentage < 38.5)
		imageName = "box6.jpg";
	else if(percentage < 44)
		imageName = "box7.jpg";
	else if(percentage < 49.5)
		imageName = "box8.jpg";
	else if(percentage < 55)
		imageName = "box9.jpg";
	else if(percentage < 60.5)
		imageName = "box10.jpg";
	else if(percentage < 66)
		imageName = "box11.jpg";
	else if(percentage < 71.5)
		imageName = "box12.jpg";
	else if(percentage < 77)
		imageName = "box13.jpg";
	else if(percentage < 82.5)
		imageName = "box14.jpg";
	else if(percentage < 88)
		imageName = "box15.jpg";
	else if(percentage < 93.5)
		imageName = "box16.jpg";
	else if(percentage < 100)
		imageName = "box17.jpg";
	else if(percentage == 100)
		imageName = "box18.jpg";
	
	imageName = "images/" + imageName;

	top.frames["mid_frame"].document.all["text_cubic_feet"].innerText = total;
	top.frames["mid_frame"].document.all["text_num_containers"].innerText = numContainers;
	top.frames["mid_frame"].document.all["text_percent_full"].innerText = percentageText;
	
	top.frames["mid_frame"].document.images["image_percentage"].src = imageName;
	
}

function clearCurrentTab(){
	
	var input_doc;
	var tabName;
	var formName;
	var formCounter;
	
	input_doc = getInputFrameDoc();

	
	for(counter = 1;counter <= numTabs ;counter ++){
		
		if(input_doc.all["Content" + counter].style.display != "none"){
			
			
			tabName = "Content" + counter;
			
			formName = tabName + "_Form_1";
			formCounter = 1;

			while(typeof (input_doc.forms[formName]) != "undefined"){

				input_doc.forms[formName].elements[0].value = "";
				formCounter = formCounter + 1;
				formName = tabName + "_Form_" + formCounter;
			}
			
			return;
			
		}
		
	}
	


}

function clearAllTabs(){

	var input_doc;
	var tabName;
	var formName;
	var formCounter;
	
	input_doc = getInputFrameDoc();
	
	for(counter = 1;counter <= numTabs ;counter ++){

			
		tabName = "Content" + counter;
			
		formName = tabName + "_Form_1";
		formCounter = 1;
		
		
		while(typeof (input_doc.forms[formName]) == "object"){
			
			input_doc.forms[formName].elements[0].value = "";
			formCounter = formCounter + 1;
			formName = tabName + "_Form_" + formCounter;
		}
	}

}

function collectFormData(){
	
	var input_doc;
	var total = 0;
	var dimensions = 0;
	var commaIndex = -1;
	var itemCount = 0;
	var percentage = 0;
	var numContainers = 0;
	var totalLastContainer = 0;
	var remainder = 0;
	var dataString = "";
	var itemName = "";
	var length  = 0;
	var width = 0;
	var height = 0;
	
	
	input_doc = getInputFrameDoc();
	

	
	for(counter = 0;counter < input_doc.forms.length; counter ++ ){
		
		//get a string value of dimensions 
		dimensions = input_doc.forms[counter].elements[0].name
		commaIndex = dimensions.lastIndexOf(",");
		dimensions = dimensions.substring(commaIndex + 1, dimensions.length );
		
		itemName = input_doc.forms[counter].elements[0].name.substring(input_doc.forms[counter].elements[0].name.indexOf(",") + 1, commaIndex  );
		
	    if(isNaN(dimensions) || dimensions == "" )
			continue;
			//alert(input_doc.forms[counter].elements[0].name);
			
		//dimensions = parseInt(dimensions);
		
		itemCount = parseInt(input_doc.forms[counter].elements[0].value);
		
		
		if(isNaN(itemCount))
			itemCount = 0;
		
		total = total + (dimensions * itemCount) ;
		
		if(itemCount > 0){
			//dataString = dataString + "\n" + itemName + " (" + itemCount + ")" ;
			dataString = dataString + "\n" + itemCount + " " + itemName ;
		}
		
		
		
	}
	
	//calculate custom items (there are 8 of them)
	for(counter = 1; counter < 32; counter = counter + 4){
		
		height = input_doc.forms["Content10_Form_" + (counter + 1)].elements[0].value;
		height = (typeof(height) == "undefined" || isNaN(height) || height == "") ? 0 : parseFloat(height);
		
		//alert(height);
		
		width = input_doc.forms["Content10_Form_" + (counter+2)].elements[0].value;
		width = (typeof(width) == "undefined" || isNaN(width) || width == "") ? 0 : parseFloat(width);
		
		//alert(width);
		
		length = input_doc.forms["Content10_Form_" + (counter+3)].elements[0].value;
		length = (typeof(length) == "undefined" || isNaN(length) || length == "") ? 0 : parseFloat(length);
		
		//alert(height + width + length);
		
		dimensions = (height * width * length) ;
		
		if(dimensions > 0){
			
			itemName = input_doc.forms["Content10_Form_" + (counter)].elements[0].value
			if(itemName == "")
				itemName = "[item name not provided]";
				
			//dataString = dataString + "\n" + "Custom item. Item name:" +  itemName + ", dimensions (" + dimensions + ")";
		    dataString = dataString + "\n" + "Custom item. Item name:" +  itemName + ", dimensions (" + dimensions + ")"; 
		}
		
	}
	
	return dataString;
	 
}

function getInputFrameDoc(){
	
	
	//alert(top.frames[1].frames.length);
	
	if(typeof(top.frames["mid_frame"]) != "object")
		return null;
	
	//alert(typeof(top.frames["mid_frame"]));
	
	//if(typeof(top.frames["mid_frame"].frames["frame_MainContent"])!= "object")
	//	return null;
		
	//if(typeof(top.frames["mid_frame"].frames["frame_Input"])!= "object")
	//	return null;
	
	return top.frames["mid_frame"].document;
	
}

function HtwMoveNext(){
	
	var pos = -1;
	var imageNum = "";
	var imageSrc = "";
	
	
	
	imageSrc = top.frames["mid_frame"].document.images["how_it_works_image_content"].src;
	
	imageNum = imageSrc.substr(imageSrc.lastIndexOf(".") - 1,1);
	
	imageNum = parseInt(imageNum);
	
	if(imageNum > 7 || imageNum == 7)
		return;
	
	imageNum++;
	imageSrc = "images/htw_" + imageNum + ".gif";
	
	top.frames["mid_frame"].document.images["how_it_works_image_content"].src = imageSrc;
	
	//if last step then disable 'next' button
	if(imageNum == 7){
		top.frames["mid_frame"].document.images["how_it_works_right_arrow"].src = "images/flat_grey_right_arrow.jpg";
	}
	//set 'back' button to enabled
	if(imageNum == 2){
		top.frames["mid_frame"].document.images["how_it_works_left_arrow"].src = "images/flat_left_arrow.jpg";
	}
	
	top.frames["mid_frame"].document.all["how_it_works_top_rect_main_text"].innerText = "                            Step " + imageNum;
	top.frames["mid_frame"].document.all["how_it_works_top_rect_step_text"].innerText = imageNum + "-7";
	
	
}

function HtwMoveBack(){
	
	var pos = -1;
	var imageNum = "";
	var imageSrc = "";
	
	
	
	imageSrc = top.frames["mid_frame"].document.images["how_it_works_image_content"].src;
	
	imageNum = imageSrc.substr(imageSrc.lastIndexOf(".") - 1,1);
	
	imageNum = parseInt(imageNum);
	
	if(imageNum < 1 || imageNum == 1)
		return;
	
	imageNum--;
	imageSrc = "images/htw_" + imageNum + ".gif";
	
	top.frames["mid_frame"].document.images["how_it_works_image_content"].src = imageSrc;
	
	//if last step then disable 'back' button
	if(imageNum == 1){
		top.frames["mid_frame"].document.images["how_it_works_left_arrow"].src = "images/flat_grey_left_arrow.jpg";
	}
	//set 'next' button to enabled
	if(imageNum == 6){
		top.frames["mid_frame"].document.images["how_it_works_right_arrow"].src = "images/flat_right_arrow.jpg";
	}
	
	top.frames["mid_frame"].document.all["how_it_works_top_rect_main_text"].innerText = "                            Step " + imageNum;
	top.frames["mid_frame"].document.all["how_it_works_top_rect_step_text"].innerText = imageNum + "-7";
	
}

function mouseOverRightArrow(){

	var pos = -1;
	var imageNum = "";
	var imageSrc = "";
	
	
	
	if(top.frames["mid_frame"].document.all["how_it_works_image_area"].style.display == "none")
	   return;
		
	imageSrc = top.frames["mid_frame"].document.images["how_it_works_image_content"].src;
	
	imageNum = imageSrc.substr(imageSrc.lastIndexOf(".") - 1,1);
	
	imageNum = parseInt(imageNum);
	
	if(imageNum == 7)
		return;

	imageSrc = "images/right_arrow.jpg";
	
	top.frames["mid_frame"].document.images["how_it_works_right_arrow"].src = imageSrc;
	top.frames["mid_frame"].document.all["how_it_works_button_text"].innerText = "     next";
	
	
}

function mouseOverLeftArrow(){

	var pos = -1;
	var imageNum = "";
	var imageSrc = "";
	
	if(top.frames["mid_frame"].document.all["how_it_works_image_area"].style.display == "none")
	    return;
	
	imageSrc = top.frames["mid_frame"].document.images["how_it_works_image_content"].src;
	
	imageNum = imageSrc.substr(imageSrc.lastIndexOf(".") - 1,1);
	
	imageNum = parseInt(imageNum);
	
	if(imageNum == 1)
		return;

	imageSrc = "images/left_arrow.jpg";
	
	top.frames["mid_frame"].document.images["how_it_works_left_arrow"].src = imageSrc;
	top.frames["mid_frame"].document.all["how_it_works_button_text"].innerText = "     back";

}

function mouseOutRightArrow(){

	var pos = -1;
	var imageNum = "";
	var imageSrc = "";
	
	if(top.frames["mid_frame"].document.all["how_it_works_image_area"].style.display == "none")
	    return;
	
	imageSrc = top.frames["mid_frame"].document.images["how_it_works_image_content"].src;
	
	imageNum = imageSrc.substr(imageSrc.lastIndexOf(".") - 1,1);
	
	imageNum = parseInt(imageNum);
	
	if(imageNum == 7)
		return;
	
	
	
	imageSrc = "images/flat_right_arrow.jpg";
	
	top.frames["mid_frame"].document.images["how_it_works_right_arrow"].src = imageSrc;
	top.frames["mid_frame"].document.all["how_it_works_button_text"].innerText = "";
	
}

function mouseOutLeftArrow(){

	var pos = -1;
	var imageNum = "";
	var imageSrc = "";
	
	if(top.frames["mid_frame"].document.all["how_it_works_image_area"].style.display == "none")
	    return;
	
	imageSrc = top.frames["mid_frame"].document.images["how_it_works_image_content"].src;
	
	imageNum = imageSrc.substr(imageSrc.lastIndexOf(".") - 1,1);
	
	imageNum = parseInt(imageNum);
	
	if(imageNum == 1)
		return;
	
	
	
	imageSrc = "images/flat_left_arrow.jpg";
	
	top.frames["mid_frame"].document.images["how_it_works_left_arrow"].src = imageSrc;
	top.frames["mid_frame"].document.all["how_it_works_button_text"].innerText = "";
	
	
}

function mouseOverStepButton(){

	var imageSrc = "";

	
	imageSrc = "images/boxes3D.jpg";
	
	top.frames["mid_frame"].document.images["how_it_works_button_steps"].src = imageSrc;
	top.frames["mid_frame"].document.all["how_it_works_button_text"].innerText = "     view";
}

function mouseOutStepButton(){

	var imageSrc = "";
	
	
	
	imageSrc = "images/boxes.jpg";
	
	top.frames["mid_frame"].document.images["how_it_works_button_steps"].src = imageSrc;
	top.frames["mid_frame"].document.all["how_it_works_button_text"].innerText = "";
	
}



function showStepChoicesClick(){
	
	var stepNum;
	var imageSrc;
	
	if(top.frames["mid_frame"].document.all["how_it_works_step_choices"].style.display == "none"){
		top.frames["mid_frame"].document.all["how_it_works_image_area"].style.display = "none";
		top.frames["mid_frame"].document.all["how_it_works_step_choices"].style.display = "block";
	
		top.frames["mid_frame"].document.all["how_it_works_top_rect_main_text"].innerText = "                click on item to view";
	
		top.frames["mid_frame"].document.images["how_it_works_left_arrow"].src = "images/flat_grey_left_arrow.jpg";
		top.frames["mid_frame"].document.images["how_it_works_right_arrow"].src = "images/flat_grey_right_arrow.jpg";
	}
	else {
		 
		top.frames["mid_frame"].document.all["how_it_works_image_area"].style.display = "block";
		top.frames["mid_frame"].document.all["how_it_works_step_choices"].style.display = "none";
		
		stepNum = String(top.frames["mid_frame"].document.all["how_it_works_top_rect_step_text"].innerText);
		
		stepNum = stepNum.charAt(stepNum.indexOf("-") - 1);
				
		top.frames["mid_frame"].document.all["how_it_works_top_rect_main_text"].innerText = "                            Step " + stepNum;
	
		imageSrc = "images/htw_" + stepNum + ".gif";
		
		top.frames["mid_frame"].document.images["how_it_works_image_content"].src = imageSrc;
	
		//if last step then disable 'back' button
		if(stepNum == "1"){
			top.frames["mid_frame"].document.images["how_it_works_left_arrow"].src = "images/flat_grey_left_arrow.jpg";
		}
		else {
		    top.frames["mid_frame"].document.images["how_it_works_left_arrow"].src = "images/flat_left_arrow.jpg";
		}
		//set 'next' button to enabled
		if(stepNum == "7"){
			top.frames["mid_frame"].document.images["how_it_works_right_arrow"].src = "images/flat_grey_right_arrow.jpg";
		}
		else {
			 top.frames["mid_frame"].document.images["how_it_works_right_arrow"].src = "images/flat_right_arrow.jpg";
		}

	
	}
	
}

function stepSelected(stepId){
	
	//alert(show_props(top.document.all[stepId].style,"Style"));
	top.frames["mid_frame"].document.all[stepId].style["backgroundColor"] = "6699CC";
	top.frames["mid_frame"].document.all[stepId].style["color"] = "white";

}

function stepDeselected(stepId){
	
	//alert(show_props(top.document.all[stepId].style,"Style"));
	top.frames["mid_frame"].document.all[stepId].style["backgroundColor"] = "white";
	top.frames["mid_frame"].document.all[stepId].style["color"] = "6699CC";

}

function show_props(obj, obj_name) {   
		 var result = "";
		 var counter = 0;
		 
		 for (var i in obj){
		     result += obj_name + "." + i + " = " + obj[i] + "\n";
			 counter++;
			 if(counter % 20 == 0){
			 	//alert(result);
				result = "";
			 }
		 }
	
	  return result;
}

function selectStep(step){
	
	top.frames["mid_frame"].document.all["how_it_works_top_rect_step_text"].innerText = step + "-7";
	top.frames["mid_frame"].document.images["how_it_works_image_content"].src = "images/htw_" + step + ".gif";
	showStepChoicesClick();
	
}

function initLeftFrame(){
	
	var tabName = top.currentMenu;
	
	if(tabName == "main site"){
		
		top.frames["mid_frame"].document.all["left_frame_image_content"].style.display = "block";
		top.frames["mid_frame"].document.all["how_it_works_tool"].style.display = "none";
		top.frames["mid_frame"].document.images["left_frame_content_image"].src = "images/mainSite_pic.gif";

	}
	else if(tabName == "about us"){
		
		
		top.document.frames["mid_frame"].document.all["left_frame_image_content"].style.display = "block";
		top.document.frames["mid_frame"].document.all["how_it_works_tool"].style.display = "none";
		top.document.frames["mid_frame"].document.images["left_frame_content_image"].src = "images/aboutUs_pic.gif";
		
	}
	else if(tabName == "contact us"){
		
		
		top.document.frames["mid_frame"].document.all["left_frame_image_content"].style.display = "block";
		top.document.frames["mid_frame"].document.all["how_it_works_tool"].style.display = "none";
		top.document.frames["mid_frame"].document.images["left_frame_content_image"].src = "images/contactUs_pic.gif";
		
	}
	else if(tabName == "how this works"){
		
		
		top.document.frames["mid_frame"].document.all["left_frame_image_content"].style.display = "none";
		top.document.frames["mid_frame"].document.all["how_it_works_tool"].style.display = "block";
		
		top.document.frames["mid_frame"].document.all["left_frame_image_content"].style.display = "none";
		top.document.frames["mid_frame"].document.all["how_it_works_tool"].style.display = "block";
		top.document.frames["mid_frame"].document.all["how_it_works_step_choices"].style.display = "none";
		top.document.frames["mid_frame"].document.all["how_it_works_image_area"].style.display = "block";
		top.document.frames["mid_frame"].document.images["how_it_works_image_content"].src = "images/htw_1.gif";
		
		top.document.frames["mid_frame"].document.images["how_it_works_left_arrow"].src = "images/flat_grey_left_arrow.jpg";
		top.document.frames["mid_frame"].document.images["how_it_works_right_arrow"].src = "images/flat_right_arrow.jpg";
		top.document.frames["mid_frame"].document.all["how_it_works_button_text"].innerText = "";
		
		top.document.frames["mid_frame"].document.all["how_it_works_top_rect_main_text"].innerText = "                           Step 1";
		top.document.frames["mid_frame"].document.all["how_it_works_top_rect_step_text"].innerText = "1-7";
		
	}
	else if(tabName == "order storage"){
		
		
		top.document.frames["mid_frame"].document.all["left_frame_image_content"].style.display = "block";
		top.document.frames["mid_frame"].document.all["how_it_works_tool"].style.display = "none";
		top.document.frames["mid_frame"].document.images["left_frame_content_image"].src = "images/contactUs_pic.gif";
		
		
	}
	else if(tabName == "tips on packing"){
		
		
		top.document.frames["mid_frame"].document.all["left_frame_image_content"].style.display = "block";
		top.document.frames["mid_frame"].document.all["how_it_works_tool"].style.display = "none";
		top.document.frames["mid_frame"].document.images["left_frame_content_image"].src = "images/tips_pic.gif";
		
		
	}
	
	
}

function initRightFrame(){
	
	var tabName = top.currentMenu;
	
	if(tabName == "main site"){
		
		//set right frame to proper content
		hideAllMidFrameContent();
		window.top.document.frames["mid_frame"].document.all["right_frame_main_site"].style.display = "block";
	
	}
	else if(tabName == "about us"){
		
		
		//set right frame to proper content
		hideAllMidFrameContent();
		top.document.frames["mid_frame"].document.all["right_frame_about"].style.display = "block";
		 
	}
	else if(tabName == "contact us"){
		
		
		//set right frame to proper content
		hideAllMidFrameContent();
		top.document.frames["mid_frame"].document.all["right_frame_contact"].style.display = "block";
		 
	}
	else if(tabName == "how this works"){
		
		//set right frame to proper content
		hideAllMidFrameContent();
		top.document.frames["mid_frame"].document.all["right_frame_how_it_works"].style.display = "block";
		
		
	}
	else if(tabName == "order storage"){
		
		//set right frame to proper content
		hideAllMidFrameContent();
		top.document.frames["mid_frame"].document.all["right_frame_order_storage"].style.display = "block";
		
		top.document.frames["mid_frame"].document.forms["order_form"].elements["itemlist"].value = top.formData;
		top.document.frames["mid_frame"].document.forms["order_form"].elements["containers"].value = top.numContainers;
		
		top.formData = "";
		top.numContainers = "0";
		
	}
	else if(tabName == "tips on packing"){

		//set right frame to proper content
		hideAllMidFrameContent();
		top.document.frames["mid_frame"].document.all["right_frame_tips"].style.display = "block";
		 
	}

}

function initMidFrame(){
	
	var tabName = top.currentMenu;
	
	if(tabName == "main site"){
		
		top.frames["mid_frame"].document.all["left_frame_image_content"].style.display = "block";
		top.frames["mid_frame"].document.all["how_it_works_tool"].style.display = "none";
		top.frames["mid_frame"].document.images["left_frame_content_image"].src = "images/mainSite_pic.gif";


		//set right frame to proper content
		hideAllMidFrameContent();
		window.top.document.frames["mid_frame"].document.all["right_frame_main_site"].style.display = "block";
	
	}
	else if(tabName == "about us"){
		
		
		top.document.frames["mid_frame"].document.all["left_frame_image_content"].style.display = "block";
		top.document.frames["mid_frame"].document.all["how_it_works_tool"].style.display = "none";
		top.document.frames["mid_frame"].document.images["left_frame_content_image"].src = "images/aboutUs_pic.gif";
		
		
		//set right frame to proper content
		hideAllMidFrameContent();
		top.document.frames["mid_frame"].document.all["right_frame_about"].style.display = "block";
		 
	}
	else if(tabName == "contact us"){
		
		
		top.document.frames["mid_frame"].document.all["left_frame_image_content"].style.display = "block";
		top.document.frames["mid_frame"].document.all["how_it_works_tool"].style.display = "none";
		top.document.frames["mid_frame"].document.images["left_frame_content_image"].src = "images/contactUs_pic.gif";
		
		
		//set right frame to proper content
		hideAllMidFrameContent();
		top.document.frames["mid_frame"].document.all["right_frame_contact"].style.display = "block";
		 
	}
	else if(tabName == "how this works"){
		
		
		top.document.frames["mid_frame"].document.all["left_frame_image_content"].style.display = "none";
		top.document.frames["mid_frame"].document.all["how_it_works_tool"].style.display = "block";
		
		
		
		//set right frame to proper content
		hideAllMidFrameContent();
		top.document.frames["mid_frame"].document.all["right_frame_how_it_works"].style.display = "block";
		 
	}
	else if(tabName == "order storage"){
		
		
		top.document.frames["mid_frame"].document.all["left_frame_image_content"].style.display = "block";
		top.document.frames["mid_frame"].document.all["how_it_works_tool"].style.display = "none";
		top.document.frames["mid_frame"].document.images["left_frame_content_image"].src = "images/contactUs_pic.gif";
		
		
		//set right frame to proper content
		hideAllMidFrameContent();
		top.document.frames["mid_frame"].document.all["right_frame_order_storage"].style.display = "block";
		
		top.document.frames["mid_frame"].document.forms["order_form"].elements["itemlist"].value = top.formData;
		top.formData = "";
		
	}
	else if(tabName == "tips on packing"){
		
		
		top.document.frames["mid_frame"].document.all["left_frame_image_content"].style.display = "block";
		top.document.frames["mid_frame"].document.all["how_it_works_tool"].style.display = "none";
		top.document.frames["mid_frame"].document.images["left_frame_content_image"].src = "images/tips_pic.gif";
		
		
		//set right frame to proper content
		hideAllMidFrameContent();
		top.document.frames["mid_frame"].document.all["right_frame_tips"].style.display = "block";
		 
	}
	else if(tabName == "moving services"){
		
		top.location.href = "http://www.generalrelocation.com";
		
	}
	
	else if(tabName == "estimator"){
	
		 //set top frame images 
		top.document.frames["top_frame"].document.all["no_map_secondary_menu"].style.display = "none";
		top.document.frames["top_frame"].document.all["with_map_secondary_menu"].style.display = "block";
		//top.document.frames["top_frame"].document.images["top_frame_menu_image"].src = "images/estimator.jpg";
		
		//set mid frame to regular (non estimator) frame;
		top.document.frames["mid_frame"].location.href = "frame_mainContent.html";
	
	}

}

function mainSiteNavigate(tabName){
	
	var interval = 2000;
	
	top.currentMenu = tabName;
	
	if(tabName == "main site"){
		
		//set top frame images 
		top.document.frames["top_frame"].document.all["no_map_secondary_menu"].style.display = "block";
		top.document.frames["top_frame"].document.all["with_map_secondary_menu"].style.display = "none";
		top.document.frames["top_frame"].document.images["top_frame_menu_image"].src = "images/mainSite.jpg";
		
		//set mid frame to regular (non estimator) frame;
		if(typeof(top.document.frames["mid_frame"]) == "undefined"){
			//alert("ewew");
			top.document.frames["mid_frame"].location.href = "mid_frame.html";
			return;
		}
		
		initLeftFrame();
		initRightFrame();
		
	}
	else if(tabName == "about us"){
		
		//set top frame images 
		top.document.frames["top_frame"].document.all["no_map_secondary_menu"].style.display = "block";
		top.document.frames["top_frame"].document.all["with_map_secondary_menu"].style.display = "none";
		top.document.frames["top_frame"].document.images["top_frame_menu_image"].src = "images/aboutUs.jpg";
		
		//set mid frame to regular (non estimator) frame;
		
		if(typeof(top.document.frames["mid_frame"].frames["frame_Input"]) != "undefined"){
			top.document.frames["mid_frame"].location.href = "mid_frame.html";
			return;
		}
			
		initLeftFrame();
		initRightFrame();
		
	}
	else if(tabName == "contact us"){
		
		//set top frame images 
		top.document.frames["top_frame"].document.all["no_map_secondary_menu"].style.display = "block";
		top.document.frames["top_frame"].document.all["with_map_secondary_menu"].style.display = "none";
		top.document.frames["top_frame"].document.images["top_frame_menu_image"].src = "images/contactUs.jpg";
		
		//set mid frame to regular (non estimator) frame;
		
		if(typeof(top.document.frames["mid_frame"].frames["frame_Input"]) != "undefined"){
			top.document.frames["mid_frame"].location.href = "mid_frame.html";
			return;
		}
			
		initLeftFrame();
		initRightFrame();
		
	}
	else if(tabName == "how this works"){
		
		//set top frame images 
		top.document.frames["top_frame"].document.all["no_map_secondary_menu"].style.display = "block";
		top.document.frames["top_frame"].document.all["with_map_secondary_menu"].style.display = "none";
		top.document.frames["top_frame"].document.images["top_frame_menu_image"].src = "images/howthisworks.jpg";
		
		//set mid frame to regular (non estimator) frame;
		
		if(typeof(top.document.frames["mid_frame"].frames["frame_Input"]) != "undefined"){
			top.document.frames["mid_frame"].location.href = "mid_frame.html";
			return;
		}
		
		initLeftFrame();
		initRightFrame();
		
		 
	}
	else if(tabName == "order storage"){
		
		//set top frame images 
		top.document.frames["top_frame"].document.all["no_map_secondary_menu"].style.display = "block";
		top.document.frames["top_frame"].document.all["with_map_secondary_menu"].style.display = "none";
		top.document.frames["top_frame"].document.images["top_frame_menu_image"].src = "images/orderstorage.jpg";
		
		//set mid frame to regular (non estimator) frame;
		
		if(typeof(top.document.frames["mid_frame"].frames["frame_Input"]) != "undefined"){
			top.document.frames["mid_frame"].location.href = "mid_frame.html";
			return;
		}
		
		initLeftFrame();
		initRightFrame();
		
	}
	else if(tabName == "tips on packing"){
		
		//set top frame images 
		top.document.frames["top_frame"].document.all["no_map_secondary_menu"].style.display = "block";
		top.document.frames["top_frame"].document.all["with_map_secondary_menu"].style.display = "none";
		top.document.frames["top_frame"].document.images["top_frame_menu_image"].src = "images/tipsonpacking.jpg";
		
		//set mid frame to regular (non estimator) frame;
		
		if(typeof(top.document.frames["mid_frame"].frames["frame_Input"]) != "undefined"){
			top.document.frames["mid_frame"].location.href = "mid_frame.html";
			return;
		}
		
		initLeftFrame();
		initRightFrame();
		
	}
	else if(tabName == "moving services"){
		
		top.location.href = "http://www.generalrelocation.com";
		
	}
	
	else if(tabName == "estimator"){
	
		 //set top frame images 
		top.document.frames["top_frame"].document.all["no_map_secondary_menu"].style.display = "none";
		top.document.frames["top_frame"].document.all["with_map_secondary_menu"].style.display = "block";
		//top.document.frames["top_frame"].document.images["top_frame_menu_image"].src = "images/estimator.jpg";
		
		//set mid frame to regular (non estimator) frame;
		top.document.frames["mid_frame"].location.href = "frame_mainContent.html";
	
	}
	
}


function hideAllMidFrameContent(){
	
	top.document.frames["mid_frame"].document.all["right_frame_main_site"].style.display = "none";
	top.document.frames["mid_frame"].document.all["right_frame_about"].style.display = "none";
	top.document.frames["mid_frame"].document.all["right_frame_contact"].style.display = "none";
	top.document.frames["mid_frame"].document.all["right_frame_how_it_works"].style.display = "none";
	top.document.frames["mid_frame"].document.all["right_frame_order_storage"].style.display = "none";
	top.document.frames["mid_frame"].document.all["right_frame_tips"].style.display = "none";
	

}

function carryOverOrder(){
	
	var formData = "";
	
	top.formData = collectFormData();
	top.numContainers = top.frames["mid_frame"].document.all["text_num_containers"].innerText;
	//mainSiteNavigate("order storage");
	top.frames["mid_frame"].location.href = "http://nymobilestorage.com/orderstorage.php";

}

function initOrderForm(){
		
	top.document.frames["mid_frame"].document.forms["order_form"].elements["itemlist"].value = top.formData;
	top.document.frames["mid_frame"].document.forms["order_form"].elements["containers"].value = top.numContainers;

	top.formData = "";
	top.numContainers = "0";
	
	var curDate = new Date(Date());
	top.document.frames["mid_frame"].document.forms["order_form"].elements["date_day"].selectedIndex = curDate.getDate() - 1;
	top.document.frames["mid_frame"].document.forms["order_form"].elements["date_month"].selectedIndex = curDate.getMonth();
	top.document.frames["mid_frame"].document.forms["order_form"].elements["date_year"].selectedIndex = curDate.getYear() - 2002;


}

function showFormData(){

	alert(top.document.frames["mid_frame"].document.forms["order_form"].elements["itemlist"].value);
	
}

function validateOrderForm(){

	if(top.frames["mid_frame"].document.forms["order_form"].elements["E-Mail"].value.length < 1){
		alert("Please provide e-mail address");
		return false;
	}
	
}