// Sets the page for iPhone
// Landscape - no title and scroll down one line
// Portrait - show title and scroll down one line

function setOrientation() {

    //alert("setOrientation2");

    var orient = Math.abs(window.orientation) === 90 ? 'landscape' : 'portrait';
    var cl = document.body.className;
    cl = cl.replace(/portrait|landscape/, orient);
    document.body.className = cl;
    if (orient == 'portrait') {
        document.getElementById('portraitOnly').style.display = '';
        document.getElementById('landscapeOnly').style.display = 'none';
        setTimeout(scrollTo, 0, 0, 1);
    } else {
        document.getElementById('portraitOnly').style.display = 'none';
		
		document.getElementById('landscapeOnly').style.display = '';
		
		document.getElementById('websiteframe').location = 'index.html';
		
        setTimeout(scrollTo, 0, 0, 1);
    }
}

function scrollDownBy (lines) {
    alert("scrollDown" + lines);
    setTimeout(window.scrollByLines(lines));
}
		


 function mouseOver(theButton , theClass){
				addClass(document.getElementById(theButton) , theClass + 'Hover');
                }
		
 function mouseOut(theButton , theClass){
				removeClass(document.getElementById(theButton) , theClass + 'Hover');
                }		
				
 function showMenu(theButton , myArray , theClass){
	
	for (var i=0; i< myArray.length; i++) {
		var eachButton = myArray[i];
		// document.getElementById(eachButton).style.backgroundColor = '#FFFF64';
		document.getElementById(eachButton).className = theClass;
	}

		//document.getElementById(theButton).style.backgroundColor = '#FFFFCC';
		
		document.getElementById(theButton).className = theClass + 'Up';
                }



var theOutput = 'outputText' ;

var httpObject = null;

function callURL(page,args){    

httpObject = getHTTPObject();
    if (httpObject != null) {
        httpObject.open("GET", page + args , true);
        httpObject.send(null); 
        httpObject.onreadystatechange = setOutput();
    }
}

// Change the value of the outputText field
function setOutput(){

    if(httpObject.readyState == 4){
        document.getElementById('outputText').value 
            = httpObject.responseText;
    }
 
}

// Get the HTTP Object
function getHTTPObject(){
   if (window.ActiveXObject) 
       return new ActiveXObject("Microsoft.XMLHTTP");
   else if (window.XMLHttpRequest) 
       return new XMLHttpRequest();
   else {
      alert("Your browser does not support AJAX.");
      return null;
   }
}

function hasClass(ele,cls) {
	return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
}
function addClass(ele,cls) {
	if (!this.hasClass(ele,cls)) ele.className += " "+cls;
}
function removeClass(ele,cls) {
	if (hasClass(ele,cls)) {
		var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
		ele.className=ele.className.replace(reg,' ');
	}
}

function openMapWindow(url) {
	openCenteredWindow(url,1000,800,'GoogleMap')
}
    

function openCenteredWindow(url,width,height,name) {
	var myWindow;
    var left = parseInt((screen.availWidth/2) - (width/2));
    var top = parseInt((screen.availHeight/2) - (height/2));
    var windowFeatures = "width=" + width + ",height=" + height + ",status, scrollbars=yes,resizable,left=" + left + ",top=" + top + "screenX=" + left + ",screenY=" + top;
    myWindow = window.open(url, name, windowFeatures);
}


		
function generate_address(username ) {
          generate_address_sub(username, "nbh3.com" ,"NBH3_Web_Enquiry" );
        }

 
        function generate_address_sub(username, hostname ,subject ) {
	      var name = "<img src='images/email-icon.gif'/>" ;
		  
          var atsign = "&#64;";
          var addr = username + atsign + hostname;
          document.write( 
            "<" + "a" + " " + "href=" + "mail" + "to:" + addr + "?subject=" + subject +">" +
            name +
            "<\/a>");
        }
		
		
		
