// JavaScript Document


//Jump menu script for product and market navbar
function openURL(nav) {
	if (nav == 'prod') {
      // grab index number of the selected option
      selInd = document.pForm.prod.selectedIndex;
      // get value of the selected option
      goURL = document.pForm.prod.options[selInd].value;
      // redirect browser to the grabbed value (here a URL)
	  }
	if (nav == 'applications') {
	 // grab index number of the selected option
      selInd = document.aForm.applications.selectedIndex;
      // get value of the selected option
      goURL = document.aForm.applications.options[selInd].value;
      // redirect browser to the grabbed value (here a URL
	  }
	  //alert(nav);
	  top.location.href = goURL;
}



/*
JSTarget function by Roger Johansson, www.456bereastreet.com
Used detect Non-HTML Links and External Links, and then open in a new window
*/
var JSTarget = {
	init: function(att,val,warning) {
		if (document.getElementById && document.createElement && document.appendChild) {
			var strAtt = ((typeof att == 'undefined') || (att == null)) ? 'class' : att;
			var strVal = ((typeof val == 'undefined') || (val == null)) ? 'non-html' : val;
			var strWarning = ((typeof warning == 'undefined') || (warning == null)) ? '' : warning;
			var oWarning;
			var arrLinks = document.getElementsByTagName('a');
			var oLink;
			var oRegExp = new RegExp("(^|\\s)" + strVal + "(\\s|$)");
			for (var i = 0; i < arrLinks.length; i++) {
				oLink = arrLinks[i];
				if ((strAtt == 'class') && (oRegExp.test(oLink.className)) || (oRegExp.test(oLink.getAttribute(strAtt)))) {
					oWarning = document.createElement("em");
					oWarning.appendChild(document.createTextNode(strWarning));
					oLink.appendChild(oWarning);
					oLink.onclick = JSTarget.openWin;
				}
			}
			oWarning = null;
		}
	},
	openWin: function(e) {
		var event = (!e) ? window.event : e;
		if (event.shiftKey || event.altKey || event.ctrlKey || event.metaKey) return true;
		else {
		    var oWin = window.open(this.getAttribute('href'), '_blank');
			if (oWin) {
				if (oWin.focus) oWin.focus();
				return false;
			}
			oWin = null;
			return true;
		}
	},
	/*
	addEvent function from http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html
	*/
	addEvent: function(obj, type, fn) {
		if (obj.addEventListener)
			obj.addEventListener(type, fn, false);
		else if (obj.attachEvent) {
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() {obj["e"+type+fn]( window.event );}
			obj.attachEvent("on"+type, obj[type+fn]);
		}
	}
};
JSTarget.addEvent(window, 'load', function(){JSTarget.init();});
JSTarget.addEvent(window, 'load', function(){JSTarget.init("rel","external","");});


//Popup window for Forward Form, Request more information form
function makePopup(url, width, height, overflow)
{
  if (width > 680) { width = 680; }
  if (height > 480) { height = 480; }

  if (overflow == '' || !/^(scroll|resize|both)$/.test(overflow))
  {
    overflow = 'both';
  }

  var win = window.open(url, '',
      'width=' + width + ',height=' + height
      + ',scrollbars=' + (/^(scroll|both)$/.test(overflow) ? 'yes' : 'no')
      + ',resizable=' + (/^(resize|both)$/.test(overflow) ? 'yes' : 'no')
      + ',status=yes,toolbar=no,menubar=no,location=no'
  );

  return win;
}

function forward(page) {
	makePopup('/form/forward.php?'+page, 680, 420, 'scroll');
}

//moving forward with JQuery... all new jQuery code below.
$(document).ready(function(){


//vars for popup windows
var profiles =	{
	sendURL: {
		height:400,
		width:500,
		status:1,
		resizable:1,
		createnew:0,
		center:1
	},

	requestInfo: {
		height:420,
		width:680,
		status:1,
		resizable:1,
		createnew:0,
		center:1
	}

};//end popup window profiles
  
//call popup window function and pass custom profile
$(".popupwindow").popupwindow(profiles);

//popup window for forward form
$("#forwardURLform").submit( function () {
	window.open("","ForwardWin","width=500,height=400,toolbar=0,status=1,resizable=1,scrollbars=1");
});



});//end document ready function