// #############################################################################
// lets define the browser we have instead of multiple calls throughout the file
var userAgent = navigator.userAgent.toLowerCase();
var is_opera  = (userAgent.indexOf('opera') != -1);
var is_saf    = ((userAgent.indexOf('applewebkit') != -1) || (navigator.vendor == "Apple Computer, Inc."));
var is_webtv  = (userAgent.indexOf('webtv') != -1);
var is_ie     = ((userAgent.indexOf('msie') != -1) && (!is_opera) && (!is_saf) && (!is_webtv));
var is_ie4    = ((is_ie) && (userAgent.indexOf("msie 4.") != -1));
var is_moz    = ((navigator.product == 'Gecko') && (!is_saf));
var is_kon    = (userAgent.indexOf('konqueror') != -1);
var is_ns     = ((userAgent.indexOf('compatible') == -1) && (userAgent.indexOf('mozilla') != -1) && (!is_opera) && (!is_webtv) && (!is_saf));
var is_ns4    = ((is_ns) && (parseInt(navigator.appVersion) == 4));

var _EmailSubject = 'Reagan Wireless Products';
var _PageURL = 'http://www.reaganwireless.com/';
var http_request = false;

// catch possible bugs with WebTV and other older browsers
var is_regexp = (window.RegExp) ? true : false;


// #############################################################################
// function to emulate document.getElementById
function fetch_object(idname)
{
	if (document.getElementById)
	{
		return document.getElementById(idname);
	}
	else if (document.all)
	{
		return document.all[idname];
	}
	else if (document.layers)
	{
		return document.layers[idname];
	}
	else
	{
		return null;
	}
}

// #############################################################################
// function to handle the different event models of different browsers
// and prevent event bubbling
function do_an_e(eventobj)
{
	if (!eventobj || is_ie)
	{
		window.event.returnValue = false;
		window.event.cancelBubble = true;
		return window.event;
	}
	else
	{
		eventobj.stopPropagation();
		eventobj.preventDefault();
		return eventobj;
	}
}

function isset(varname){
  return(typeof(window[varname])!='undefined');
}

function loadtarget(url, target) {
  document.getElementById(target).innerHTML = ' Fetching data...';
  if (window.XMLHttpRequest) {
    req = new XMLHttpRequest();
  } else if (window.ActiveXObject) {
    req = new ActiveXObject("Microsoft.XMLHTTP");
  }
  if (req != undefined) {
    req.onreadystatechange = function() {targetDone(url, target);};
    req.open("GET", url, true);
    req.send("");
  }
}  

function targetDone(url, target) {
  if (req.readyState == 4) { // only if req is "loaded"
    if (req.status == 200) { // only if "OK"
      document.getElementById(target).innerHTML = req.responseText;
    } else {
      document.getElementById(target).innerHTML=" Error:\n"+ req.status + "\n" +req.statusText;
    }
  }
}

function loadjscssfile(filename, filetype){
 if (filetype=="js"){ //if filename is a external JavaScript file
  var fileref=document.createElement('script')
  fileref.setAttribute("type","text/javascript")
  fileref.setAttribute("src", filename)
 }
 else if (filetype=="css"){ //if filename is an external CSS file
  var fileref=document.createElement("link")
  fileref.setAttribute("rel", "stylesheet")
  fileref.setAttribute("type", "text/css")
  fileref.setAttribute("href", filename)
 }
 if (typeof fileref!="undefined")
  document.getElementsByTagName("head")[0].appendChild(fileref)
}

function lanbar()
{
	var curl = parent.location.href;
	if (curl.match("www.google.com") != "www.google.com")
	{
		document.write ("<div align=\"right\" style=\"width:700px;\">");
		document.write ('<a href="/newsletter-signup.php" title="Newsletter Sign Up"><img style="position:absolute; TOP:1px; LEFT:350px;" src="/images/newsletter-top-btn.jpg" alt="Newsletter Sign Up" border="0" /></a>');
		document.write ("<form action=\"http://www.google.com/translate\" target=\"_blank\">");
		document.write ("<input value=\""+location.href+"\" name=\"u\" type=\"hidden\"/>");
		
		document.write ("<input value=\"en\" name=\"hl\" type=\"hidden\"/>");
		document.write ("<input value=\"UTF8\" name=\"ie\" type=\"hidden\"/>");
		document.write ("<input value=\"\" name=\"langpair\" type=\"hidden\"/>");
		document.write ("<input onClick=\"this.form.langpair.value=this.value\" title=\"&#20013;&#25991;&#65288;&#31616;&#20307;&#65289;/Chinese (Simplified)\" value=\"en|zh-CN\" type=\"image\" height=\"20\" src=\"images/gse_multipart12397.png\" width=\"30\" name=\"langpair\"/>&nbsp;");
		document.write ("<input onClick=\"this.form.langpair.value=this.value\" title=\"&#20013;&#25991;&#65288;&#32321;&#20307;&#65289;/Chinese (Traditional)\" value=\"en|zh-TW\" type=\"image\" height=\"20\" src=\"images/gse_multipart12398.png\" width=\"30\" name=\"langpair\"/>&nbsp;");
		document.write ("<input onClick=\"this.form.langpair.value=this.value\" title=\"Fran&#231;ais/French\" value=\"en|fr\" type=\"image\" height=\"20\" src=\"images/gse_multipart12413.png\" width=\"30\" name=\"langpair\"/>&nbsp;");
		document.write ("<input onClick=\"this.form.langpair.value=this.value\" title=\"Deutsch/German\" value=\"en|de\" type=\"image\" height=\"20\" src=\"images/gse_multipart12400.png\" width=\"30\" name=\"langpair\"/>&nbsp;");
		document.write ("<input onClick=\"this.form.langpair.value=this.value\" title=\"Italiano/Italian\" value=\"en|it\" type=\"image\" height=\"20\" src=\"images/gse_multipart12401.png\" width=\"30\" name=\"langpair\"/>&nbsp;");
		document.write ("<input onClick=\"this.form.langpair.value=this.value\" title=\"&#26085;&#26412;&#35486;/Japanese\" value=\"en|ja\" type=\"image\" height=\"20\" src=\"images/gse_multipart12402.png\" width=\"30\" name=\"langpair\"/>&nbsp;");
		document.write ("<input onClick=\"this.form.langpair.value=this.value\" title=\"&#54620;&#44397;&#50612;/Korean\" value=\"en|ko\" type=\"image\" height=\"20\" src=\"images/gse_multipart12403.png\" width=\"30\" name=\"langpair\"/>&nbsp;");
		document.write ("<input onClick=\"this.form.langpair.value=this.value\" title=\"Portugu&#234;s/Portuguese\" value=\"en|pt\" type=\"image\" height=\"20\" src=\"images/gse_multipart12404.png\" width=\"30\" name=\"langpair\"/>&nbsp;");
		document.write ("<input onClick=\"this.form.langpair.value=this.value\" title=\"&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081;/Russian\" value=\"en|ru\" type=\"image\" height=\"20\" src=\"images/gse_multipart12405.png\" width=\"30\" name=\"langpair\"/>&nbsp;");
		document.write ("<input onClick=\"this.form.langpair.value=this.value\" title=\"Espa&#241;ol/Spanish\" value=\"en|es\" type=\"image\" height=\"20\" src=\"images/gse_multipart12407.png\" width=\"30\" name=\"langpair\"/>&nbsp;");
		document.write ("</form>");
		document.write ("</div>");	
	} else {
		document.write ("<a href=\"#\" onclick=\"javascript:parent.location.href='http://www.reaganwireless.com/'\"><b>ENGLISH</b></a>");
	}
}	

function makePOSTRequest(url, parameters) {
  http_request = false;
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
	 http_request = new XMLHttpRequest();
	 if (http_request.overrideMimeType) {
			// set type accordingly to anticipated content type
		//http_request.overrideMimeType('text/xml');
		http_request.overrideMimeType('text/html');
	 }
  } else if (window.ActiveXObject) { // IE
	 try {
		http_request = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
		try {
		   http_request = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (e) {}
	 }
  }
  if (!http_request) {
	 alert('Cannot create XMLHTTP instance');
	 return false;
  }

  http_request.onreadystatechange = alertContents;
  http_request.open('POST', url, true);
  http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  http_request.setRequestHeader("Content-length", parameters.length);
  http_request.setRequestHeader("Connection", "close");
  http_request.send(parameters);
}

function alertContents() {
  if (http_request.readyState == 4) {
	 if (http_request.status == 200) {
		//alert(http_request.responseText);
		result = http_request.responseText;
		//document.getElementById('myspan').innerHTML = result;            
	 } else {
		alert('There was a problem with the request.');
	 }
  }
}

function openWindow(url, width, height, windowid)
{
	return window.open(
		url,
		(typeof windowid == 'undefined' ? 'RWPopup' : windowid),
		'statusbar=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes'
		+ (typeof width != 'undefined' ? (',width=' + width) : '') + (typeof height != 'undefined' ? (',height=' + height) : '')
	);
}