
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

function shiftOpacity(id, sectionName) {
    checkSection = parseInt(parent.document.getElementById(sectionName).style.width);
    if (checkSection > 25) {
      if(document.getElementById(id).style.opacity == 0) {
          HomePics = new Array("images/image01.jpg","images/image02.jpg","images/image03.jpg","images/image04.jpg","images/image05.jpg","images/image06.jpg","images/image07.jpg","images/image08.jpg","images/image09.jpg","images/image10.jpg","images/image11.jpg","images/image12.jpg","images/image13.jpg","images/image14.jpg","images/image15.jpg","images/image16.jpg","images/image17.jpg","images/image18.jpg","images/image19.jpg","images/image20.jpg","images/image21.jpg","images/image22.jpg","images/image23.jpg","images/image24.jpg","images/image25.jpg");
          imgCt = HomePics.length;
          var randomNum = Math.floor((Math.random() * imgCt));
          imagefile = HomePics[randomNum];
          document.getElementById(id).src = imagefile;
          opacity(id, 0, 100, 700);
      } else {
          HomePics = new Array("images/image01.jpg","images/image02.jpg","images/image03.jpg","images/image04.jpg","images/image05.jpg","images/image06.jpg","images/image07.jpg","images/image08.jpg","images/image09.jpg","images/image10.jpg","images/image11.jpg","images/image12.jpg","images/image13.jpg","images/image14.jpg","images/image15.jpg","images/image16.jpg","images/image17.jpg","images/image18.jpg","images/image19.jpg","images/image20.jpg","images/image21.jpg","images/image22.jpg","images/image23.jpg","images/image24.jpg","images/image25.jpg");
          imgCt = HomePics.length;
          var randomNum = Math.floor((Math.random() * imgCt));
          imagefile = HomePics[randomNum];
          document.getElementById('imageLayer').style.backgroundImage = "url(" + document.getElementById(id).src + ")";
          opacity(id, 100, 0, 700);
     }
          setTimeout("shiftOpacity('"+id+"','"+sectionName+"');",5000);
   }
}

function getContent(selection,contentHeight) {
    if (navigator.appName=="Netscape") {
	  winFinalHeight = parent.window.innerHeight;
    }
    if (navigator.appName.indexOf("Microsoft")!=-1) {
      winFinalHeight = parent.document.body.offsetHeight;
    }
	if (winFinalHeight > contentHeight) {
		contentHeight = winFinalHeight;
	}
   document.getElementById('ifrmContent').src=selection;
   parent.document.getElementById('ifrmVCI').style.height=contentHeight;
   parent.document.getElementById('ifrmProducts').style.height=contentHeight;
   parent.document.getElementById('ifrmPlanning').style.height=contentHeight;
   parent.document.getElementById('ifrmPhoto').style.height=contentHeight;
   parent.document.getElementById('ifrmDealers').style.height=contentHeight;
   parent.document.getElementById('ifrmNews').style.height=contentHeight;
   parent.document.getElementById('ifrmTable').style.height=contenttHeight;
}

function menuChange(ifrmName) {
    menuWidth = parseInt(document.getElementById(ifrmName).style.width);
     reveal('blockLayer');
    if (menuWidth == 625) {
        document.getElementById(ifrmName).style.width=650;
        hide('blockLayer');
        if (ifrmName != 'ifrmDealers') {
          document.getElementById('ifrmDealers').style.width=25;
        }
        if (ifrmName != 'ifrmProducts') {
          document.getElementById('ifrmProducts').style.width=25;
        }
        if (ifrmName != 'ifrmPhoto') {
          document.getElementById('ifrmPhoto').style.width=25;
        }
        if (ifrmName != 'ifrmVCI') {
          document.getElementById('ifrmVCI').style.width=25;
        }
        if (ifrmName != 'ifrmPlanning') {
          document.getElementById('ifrmPlanning').style.width=25;
        }
        if (ifrmName != 'ifrmNews') {
          document.getElementById('ifrmNews').style.width=25;
        }  
    }
    else if (menuWidth != 650) {
        checkMenu = document.getElementById(ifrmName);
        checkMenu.style.width=menuWidth+50;  
        checkProducts = parseInt(document.getElementById('ifrmProducts').style.width);
        checkDealers =  parseInt(document.getElementById('ifrmDealers').style.width);
        checkPhoto =  parseInt(document.getElementById('ifrmPhoto').style.width);
        checkVCI =  parseInt(document.getElementById('ifrmVCI').style.width);
        checkNews =  parseInt(document.getElementById('ifrmNews').style.width);
        checkPlanning =  parseInt(document.getElementById('ifrmPlanning').style.width);
        if (ifrmName != 'ifrmProducts' && checkProducts != 25) {
          document.getElementById('ifrmProducts').style.width=checkProducts-50;
        }
        if (ifrmName != 'ifrmDealers' && checkDealers != 25) {
          document.getElementById('ifrmDealers').style.width=checkDealers-50;
        }
        if (ifrmName != 'ifrmPhoto' && checkPhoto != 25) {
          document.getElementById('ifrmPhoto').style.width=checkPhoto-50;
        }
        if (ifrmName != 'ifrmVCI' && checkVCI != 25) {
          document.getElementById('ifrmVCI').style.width=checkVCI-50;
        }
        if (ifrmName != 'ifrmNews' && checkNews != 25) {
          document.getElementById('ifrmNews').style.width=checkNews-50;
        }
        if (ifrmName != 'ifrmPlanning' && checkPlanning != 25) {
          document.getElementById('ifrmPlanning').style.width=checkPlanning-50;
        }
        setTimeout("menuChange('"+ifrmName+"');",0);            
    }
}

if (document.getElementById) {
	visible = 'visible';
	hidden = 'hidden';
} else if (document.layers) {
	visible = 'show';
	hidden = 'hide';
} else if (document.all) {
	visible = 'visible';
	hidden = 'hidden';
}
function reveal(menu) {
	if (document.getElementById) {
		theMenu = document.getElementById(menu).style;	 
 } else if (document.layers) {
		var theMenu = document.layers[menu];		
	} else if (document.all) {
		var theMenu = document.all[menu].style;	 
}
	if (theMenu.visibility == visible) {
		theMenu.visibility = visible;
	} else {
		theMenu.visibility = visible;
	}
}

function hide(menu) {
	if (document.getElementById) {
		theMenu = document.getElementById(menu).style;
		
	} else if (document.layers) {
		theMenu = document.layers[menu];
		
	} else if (document.all) {
		theMenu = document.all(menu).style;
}
	if (theMenu.visibility == hidden) {
		theMenu.visibility = hidden;
	} else {
		theMenu.visibility = hidden;
	}
}

function newsHeight() {
    var newsNewHeight = parseInt(parent.ifrmNews.ifrmContent.document.getElementById('newsContent').scrollHeight);
    newsNewHeight /= 100
    newsNewHeight = Math.round(newsNewHeight);
    newsNewHeight *= 100
    if (newsNewHeight < 300) {
          newsNewHeight = 300;
    }
    var newsNewHeight2 = newsNewHeight+550;
    ifrmHeight(newsNewHeight2);            
}

function checkPosition(imageName,imageWidth,imageHeight,imageDesc,video) {
  if (parseInt(navigator.appVersion)>3) {
    if (navigator.appName=="Netscape") {
      winW = window.innerWidth/2-imageWidth/2;
      winH = window.innerHeight/2-imageHeight/2;
      winPosW = window.pageXOffset;
      winPosH = window.pageYOffset;
	  winWblack = window.innerWidth;
      winHblack = parent.ifrmVCI.window.innerHeight;
	    }
    if (navigator.appName.indexOf("Microsoft")!=-1) {
      winW = document.body.offsetWidth/2-imageWidth/2;
      winH = document.body.offsetHeight/2-imageHeight/2;
      winPosW = document.body.scrollLeft;
      winPosH = document.body.scrollTop;
	  winWblack = document.body.offsetWidth;
	  winHblack = parent.ifrmVCI.document.body.offsetHeight;
    }
  }
  document.getElementById('imageLayer').style.top=winH+winPosH-20+"px";
  document.getElementById('imageLayer').style.left=winW+"px";
  document.getElementById('imageLayer').style.height=imageHeight+30+"px";
  document.getElementById('imageLayer').style.width=imageWidth+"px";
  document.getElementById('blackLayer').style.width=winWblack+"px";
  document.getElementById('blackLayer').style.height=winHblack+70+"px";
  reveal('imageLayer');
  reveal('blackLayer');
  opacity('blackLayer', 0, 50, 500);
  setTimeout("opacity('imageLayer',0, 100, 1000);",500);
  if (video == 'yes') {
    writeContentVideo(imageName,imageWidth,imageHeight,imageDesc);            
  }
  else {
    writeContent(imageName,imageWidth,imageHeight,imageDesc);            
  }
}

function hideImgs() {
  var ie4 = (document.all) ? true : false;
  var ns4 = (document.layers) ? true : false;
  var ns6 = (document.getElementById && !document.all) ? true : false;
  if (ie4) {
    document.all['imageLayer'].innerHTML = "";
  }
  if (ns4) {
    document['imageLayer'].document.write("");
    document['imageLayer'].document.close();
  }
  if (ns6) {
    over = document.getElementById(['imageLayer']);
    range = document.createRange();
    range.setStartBefore(over);
    domfrag = range.createContextualFragment("");
  while (over.hasChildNodes()) {
    over.removeChild(over.lastChild);
  }
  over.appendChild(domfrag);
  }
  opacity('blackLayer', 50, 0, 500);
  opacity('imageLayer', 100, 0, 500);
  hide('blackLayer');
  hide('imageLayer');
}

function writeContent(imageName,imageWidth,imageHeight,imageDesc) {
  var ie4 = (document.all) ? true : false;
  var ns4 = (document.layers) ? true : false;
  var ns6 = (document.getElementById && !document.all) ? true : false;
  if (ie4) {
    document.all['imageLayer'].innerHTML = "<img src='"+imageName+"' width='"+imageWidth+"' height='"+imageHeight+"' /><p class='photoCopy'><a href='javascript:hideImgs()'><img src='images/closelabel.gif' width='66' height='22' border='0' align='right' /></a>"+imageDesc+"</p>";
  }
  if (ns4) {
    document['imageLayer'].document.write("<img src='"+imageName+"' width='"+imageWidth+"' height='"+imageHeight+"' /><p class='photoCopy'><a href='javascript:hideImgs()'><img src='images/closelabel.gif' width='66' height='22' border='0' align='right' /></a>"+imageDesc+"</p>");
    document['imageLayer'].document.close();
  }
  if (ns6) {
    over = document.getElementById(['imageLayer']);
    range = document.createRange();
    range.setStartBefore(over);
    domfrag = range.createContextualFragment("<img src='"+imageName+"' width='"+imageWidth+"' height='"+imageHeight+"' /><p class='photoCopy'><a href='javascript:hideImgs()'><img src='images/closelabel.gif' width='66' height='22' border='0' align='right' /></a>"+imageDesc+"</p>");
  while (over.hasChildNodes()) {
    over.removeChild(over.lastChild);
  }
  over.appendChild(domfrag);
  }
}

function writeContentVideo(imageName,imageWidth,imageHeight,imageDesc) {
  var ie4 = (document.all) ? true : false;
  var ns4 = (document.layers) ? true : false;
  var ns6 = (document.getElementById && !document.all) ? true : false;
  if (ie4) {
    document.all['imageLayer'].innerHTML = "<iframe id='videoFrame' width='"+imageWidth+"' height='"+imageHeight+"' frameborder='0' scrolling='No' marginheight='0' marginwidth='0' src='"+imageName+"'></iframe><p class='photoCopy'><a href='javascript:hideImgs()'><img src='images/closelabel.gif' width='66' height='22' border='0' align='right' /></a></p>";
  }
  if (ns4) {
    document['imageLayer'].document.write("<iframe  id='videoFrame' width='"+imageWidth+"' height='"+imageHeight+"' frameborder='0' scrolling='No' marginheight='0' marginwidth='0' src='"+imageName+"'></iframe><p class='photoCopy'><a href='javascript:hideImgs()'><img src='images/closelabel.gif' width='66' height='22' border='0' align='right' /></a></p>");
    document['imageLayer'].document.close();
  }
  if (ns6) {
    over = document.getElementById(['imageLayer']);
    range = document.createRange();
    range.setStartBefore(over);
    domfrag = range.createContextualFragment("<iframe width='"+imageWidth+"' height='"+imageHeight+"' frameborder='0' scrolling='No' marginheight='0' marginwidth='0' src='"+imageName+"'></iframe><p class='photoCopy'><a href='javascript:hideImgs()'><img src='images/closelabel.gif' width='66' height='22' border='0' align='right' /></a></p>");
  while (over.hasChildNodes()) {
    over.removeChild(over.lastChild);
  }
  over.appendChild(domfrag);
  }
}

function newWindow(VCI) {

    VCIWindow = window.open(VCI, 'VCI', 'width=650,height=475,scrollbars=yes,status=no,menubar=no,marginwidth=0,marginheight=0,leftmargin=0,topmargin=0,rightmargin=0')
    VCIWindow.focus()

}

