

/// STOP IE6 BACKGROUND IMAGE FLICKER
try {
  document.execCommand("BackgroundImageCache", false, true);
}
catch(err) {}


//Check Form
function checkForm(fName) {
	var userForm = document.forms[fName];
  if (userForm.website) {
		if (userForm.website.value.length < 1) {
			userForm.website.focus ();
			return false;
	  }
  }
  if (userForm.total_employees) {
		if (userForm.total_employees.value.length < 1) {
			userForm.total_employees.focus ();
			return false;
	  }
  }
  if (userForm.inhouse_repair) {
		if (userForm.inhouse_repair.value == "") {
			userForm.inhouse_repair.focus ();
			return false;
	  }
  }
  if (userForm.annual_sales) {
		if (userForm.annual_sales.value.length < 1) {
			userForm.annual_sales.focus ();
			return false;
	  }
  }
  if (userForm.sales_associates) {
		if (userForm.sales_associates.value.length < 1) {
			userForm.sales_associates.focus ();
			return false;
	  }
  }
  if (userForm.inside_sales) {
		if (userForm.inside_sales.value.length < 1) {
			userForm.inside_sales.focus ();
			return false;
	  }
  }
  if (userForm.outside_sales) {
		if (userForm.outside_sales.value.length < 1) {
			userForm.outside_sales.focus ();
			return false;
	  }
  }
  if (userForm.sales_territory) {
		if (userForm.sales_territory.value.length < 1) {
			userForm.sales_territory.focus ();
			return false;
	  }
  }
  if (userForm.foc_1) {
		if (userForm.foc_1.value.length < 1) {
			userForm.foc_1.focus ();
			return false;
	  }
  }
  if (userForm.foc_1_percent) {
		if (userForm.foc_1_percent.value.length < 1) {
			userForm.foc_1_percent.focus ();
			return false;
	  }
  }
  if (userForm.foc_2) {
		if (userForm.foc_2.value.length < 1) {
			userForm.foc_2.focus ();
			return false;
	  }
  }
  if (userForm.foc_2_percent) {
		if (userForm.foc_2_percent.value.length < 1) {
			userForm.foc_2_percent.focus ();
			return false;
	  }
  }
  if (userForm.foc_3) {
		if (userForm.foc_3.value.length < 1) {
			userForm.foc_3.focus ();
			return false;
	  }
  }
  if (userForm.foc_3_percent) {
		if (userForm.foc_3_percent.value.length < 1) {
			userForm.foc_3_percent.focus ();
			return false;
	  }
  }
  if (userForm.prod_1) {
		if (userForm.prod_1.value.length < 1) {
			userForm.prod_1.focus ();
			return false;
	  }
  }
  if (userForm.prod_1_percent) {
		if (userForm.prod_1_percent.value.length < 1) {
			userForm.prod_1_percent.focus ();
			return false;
	  }
  }
  if (userForm.prod_1_trend) {
		if (userForm.prod_1_trend.value.length < 1) {
			userForm.prod_1_trend.focus ();
			return false;
	  }
  }
  if (userForm.prod_2) {
		if (userForm.prod_2.value.length < 1) {
			userForm.prod_2.focus ();
			return false;
	  }
  }
  if (userForm.prod_2_percent) {
		if (userForm.prod_2_percent.value.length < 1) {
			userForm.prod_2_percent.focus ();
			return false;
	  }
  }
  if (userForm.prod_2_trend) {
		if (userForm.prod_2_trend.value.length < 1) {
			userForm.prod_2_trend.focus ();
			return false;
	  }
  }
  if (userForm.prod_3) {
		if (userForm.prod_3.value.length < 1) {
			userForm.prod_3.focus ();
			return false;
	  }
  }
  if (userForm.prod_3_percent) {
		if (userForm.prod_3_percent.value.length < 1) {
			userForm.prod_3_percent.focus ();
			return false;
	  }
  }
  if (userForm.prod_3_trend) {
		if (userForm.prod_3_trend.value.length < 1) {
			userForm.prod_3_trend.focus ();
			return false;
	  }
  }
  if (userForm.prod_4) {
		if (userForm.prod_4.value.length < 1) {
			userForm.prod_4.focus ();
			return false;
	  }
  }
  if (userForm.prod_4_percent) {
		if (userForm.prod_4_percent.value.length < 1) {
			userForm.prod_4_percent.focus ();
			return false;
	  }
  }
  if (userForm.prod_4_trend) {
		if (userForm.prod_4_trend.value.length < 1) {
			userForm.prod_4_trend.focus ();
			return false;
	  }
  }
  if (userForm.prod_5) {
		if (userForm.prod_5.value.length < 1) {
			userForm.prod_5.focus ();
			return false;
	  }
  }
  if (userForm.prod_5_percent) {
		if (userForm.prod_5_percent.value.length < 1) {
			userForm.prod_5_percent.focus ();
			return false;
	  }
  }
  if (userForm.prod_5_trend) {
		if (userForm.prod_5_trend.value.length < 1) {
			userForm.prod_5_trend.focus ();
			return false;
	  }
  }
  if (userForm.primary_interest) {
		if (userForm.primary_interest.value.length < 1) {
			userForm.primary_interest.focus ();
			return false;
	  }
  }
  if (userForm.year_1_sales) {
		if (userForm.year_1_sales.value.length < 1) {
			userForm.year_1_sales.focus ();
			return false;
	  }
  }
  if (userForm.year_2_sales) {
		if (userForm.year_2_sales.value.length < 1) {
			userForm.year_2_sales.focus ();
			return false;
	  }
  }
  if (userForm.year_3_sales) {
		if (userForm.year_3_sales.value.length < 1) {
			userForm.year_3_sales.focus ();
			return false;
	  }
  }
  if (userForm.dept_position) {
		if (userForm.dept_position.value.length < 1) {
			userForm.dept_position.focus ();
			return false;
	  }
  }
  if (userForm.why_me_as_dis) {
		if (userForm.why_me_as_dis.value.length < 1) {
			userForm.why_me_as_dis.focus ();
			return false;
	  }
  }
  if (userForm.name) {
		if (userForm.name.value == "") {
			userForm.name.focus ();
			return false;
	  }
  }
	if (userForm.firstname) {
		if (userForm.firstname.value.length < 1) {
	  	userForm.firstname.focus ();
			return false;
	  }
	}
	if (userForm.lastname) {
		if (userForm.lastname.value.length < 1) {
	  	userForm.lastname.focus ();
			return false;
	  }
	}
	if (userForm.email) {
		if (userForm.email.value == "" ||
	     userForm.email.value.indexOf ('@', 0) == -1 ||
	     userForm.email.value.indexOf ('.', 0) == -1) {
			alert ("Please enter a valid email address in the form 'name@domain.com.'");	
	  	userForm.email.focus ();	
			return false;
	  }
		if (userForm.email.value.indexOf (' ', 0) !== -1 ||
	     userForm.email.value.indexOf ('"', 0) !== -1 ||
	     userForm.email.value.indexOf (',', 0) !== -1) {
			alert ("Spaces, commas and quotes are not allowed in email addresses");
	  	userForm.email.focus ();	
			return false;
	  }
	}
  if (userForm.company) {
		if (userForm.company.value.length <= 2) {
	  	userForm.company.focus ();
			return false;
	  }
  }
  if (userForm.phone) {
		if (userForm.phone.value.length <= 2) {
	  	userForm.phone.focus ();
			return false;
	  }
  }
	if (userForm.address) {
		if (userForm.address.value.length <= 2) {
	  	userForm.address.focus ();	
			return false;
	  }
	}
	if (userForm.city) {
		if (userForm.city.value.length <= 1) {
	  	userForm.city.focus ();	
			return false;
	  }
	}
	if (userForm.state) {
		if (userForm.state.value.length < 2) {
	  	userForm.state.focus ();	
			return false;
	  }
	}
	if (userForm.zip) {
		if (userForm.zip.value.length <= 2) {
	  	userForm.zip.focus ();	
			return false;
	  }
	}
	if (userForm.country) {
		if (userForm.country.value.length < 2) {
	  	userForm.state.focus ();	
			return false;
	  }
	}
	if (userForm.customervoice) {
		if (userForm.customervoice.value.length <= 2) {
			alert ("Please enter your comments");
	  	userForm.customervoice.focus ();	
			return false;
	  }
	}
	if (userForm.application) {
		if (userForm.application.value.length <= 2) {
			alert ("Please describe your application");
	  	userForm.application.focus ();	
			return false;
	  }
	}
  if (userForm.purchaseorder) {
		if (userForm.purchaseorder.value.length < 2) {
			userForm.purchaseorder.focus ();
			return false;
	  }
  }
  if (userForm.pnmodel) {
		if (userForm.pnmodel.value.length < 3) {
			userForm.pnmodel.focus ();
			return false;
	  }
  }
  if (userForm.problem) {
		if (userForm.problem.value.length < 5) {
			userForm.problem.focus ();
			return false;
	  }
  }
	if (userForm.feedback) {
		if (userForm.feedback.value.length <= 2) {
	  	userForm.feedback.focus ();
			return false;
	  }
  }
  if (userForm.cust_condition) {
		if (userForm.cust_condition.value == "") {
			userForm.cust_condition.focus ();
			return false;
	  }
  }
  if (userForm.author) {
		if (userForm.author.value.length <= 2) {
	  	userForm.author.focus ();
			return false;
	  }
  }
	if (userForm.uword) {
		if (jcap() == false) {
			userForm.uword.focus ();
			return false;
		}
	}
  return true;
}


//DISABLE ELEMENT

function disableSelection(element) {
    element.onselectstart = function() {
        return false;
    };
    element.unselectable = "on";
    element.style.MozUserSelect = "none";
    element.style.cursor = "default";
}

function insertDateFile () {
	var today = new Date();
	var day = today.getDate();
	var month = today.getMonth() + 1;
	var year = today.getYear();
	if (year < 2000)    // Y2K Fix, Isaac Powell
	year = year + 1900; // http://onyx.idbsu.edu/~ipowell
	var offset = today.getDay();
	var week;
	if(offset != 0) {
	day = day - offset;
	if ( day < 1) {
	if ( month == 1) day = 31 + day;
	if (month == 2) day = 31 + day;
	if (month == 3) {
	if (( year == 00) || ( year == 04)) {
	day = 29 + day;
	}
	else {
	day = 28 + day;
	   }
	}
	if (month == 4) day = 31 + day;
	if (month == 5) day = 30 + day;
	if (month == 6) day = 31 + day;
	if (month == 7) day = 30 + day;
	if (month == 8) day = 31 + day;
	if (month == 9) day = 31 + day;
	if (month == 10) day = 30 + day;
	if (month == 11) day = 31 + day;
	if (month == 12) day = 30 + day;
	if (month == 1) {
	month = 12;
	year = year - 1;
	}
	else {
	month = month - 1;
	      }
	   }
	}
	if (month == 1) month = "January";
	if (month == 2) month = "February";
	if (month == 3) month = "March";
	if (month == 4) month = "April";
	if (month == 5) month = "May";
	if (month == 6) month = "June";
	if (month == 7) month = "July";
	if (month == 8) month = "August";
	if (month == 9) month = "September";
	if (month == 10) month = "October";
	if (month == 11) month = "November";
	if (month == 12) month = "December";
	week = month + " " + day + ", " + year; // i.e. 10-31-99
	page = week + page_extension;          // i.e. 10-31.99.html
	link = "<a href='" + page + "'>Page of the Week<\/a>"; // link to 10-31-99.html
}

function getRepInfo(obj,sel){
	theform = document.forms[obj];
	// grab index number of the selected option
	selInd = theform[sel].selectedIndex;
	// get value of the selected option
	repReg = theform[sel].options[selInd].value;
	// redirect browser to the grabbed value (hopefully a URL)
	if (repReg == "") {
		return false;
	} else {
		objID = obj+"_results";
		theTarget = "#"+objID;
		theFile = obj+"/"+repReg+".html"
		// JQuery Calls
		$(theTarget).load(theFile);
		$(theTarget).slideDown("fast");
		$(theTarget).next().show();
		$(theTarget).next().next().hide();
		$(theTarget+"/a").attr("target","_blank");
		// disable selection of results box
		disableSelection(document.getElementById(objID));
		sel = "#"+sel;
		//$(sel).selectOptions("");
	}
}

// Returns the width and height of viewport (browser window)
function holeSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  var myWH = new Array(myWidth,myHeight)
	return (myWH);
}	

function openTour(){
	if (document.getElementById('item2104')) {
		tb_show('Product Tour: EOTec 2104 Industrial Ethernet Ring Switch', '/product_groups/fiber/ethernet/2104/2104_product_tour/index.php?keepThis=true&TB_iframe=true&height=520&width=720', '');
	}
	else if (document.getElementById('item2C3X') || document.getElementById('itemG408M')) {
		var tourW = 960;
		var tourH = 600;
		if (holeSize()[1] < tourH) {
			var tourH = Math.floor((holeSize()[1])-50);
			var tourW = Math.round(tourH*1.6);
		}
		if (holeSize()[0] < tourW) {
			var tourW = Math.floor((holeSize()[0])-100);
			var tourH = Math.round(tourW*.625);
		}
		if (tourW > 960 || tourH > 600) {
			var tourW = 960;
			var tourH = 600;
		}
		if (document.getElementById('item2C3X')) {
		tb_show('Product Tour: ControlNet Fiber Optic Self-Healing Ring Communication Module', '/product_groups/fiber/controlnet/selfhealing/product_tour/index.php?keepThis=true&tourH='+tourH+'&tourW='+tourW+'&TB_iframe=true&height='+tourH+'&width='+tourW, '');
		}
		else if (document.getElementById('itemG408M')) {
		tb_show('Product Tour: EOTec G408M Managed Industrial Gigabit Ethernet Switch', '/product_groups/fiber/ethernet/G408M-Gigabit-Switch/product-tour/index.php?keepThis=true&tourH='+tourH+'&tourW='+tourW+'&TB_iframe=true&height='+tourH+'&width='+tourW, '');
		}
	}
}

function cookieBake() {
	var visitStat = Number($.cookie('visitStat'));
	var dateStr = new Date();
	var d_month = Number(dateStr.getMonth());
	var d_year = Number(dateStr.getYear());
	if (!visitStat) {
		if (d_year <= 2009 && d_month <= 6) {
			$.cookie('visitStat', d_month, { expires: 58, path: '/' });
			$('#UltraMsg').slideDown('slow');
		}
		else {
			$.cookie('visitStat', null, { expires: -1 });
		}
	}
	$("#UltraMsg").click(function()
		{
			$(this).slideUp("fast");
		}
	);
}

function doSubMenu(obj) {
	if (window.timer) {
		clearTimeout(window.timer);
	}
	var objOS = $(obj).position();
	window.subMenu = $("#subMenuHolder");
	subMenu.hide();
	var objW = Number($(obj).width());
	var wFactor = objW+10;
	var tFactor = String(objOS.top)+"px";
	var subMenuContents = $(obj).parent().next().html();
	subMenu.html("<ul>"+subMenuContents+"</ul>");
	subMenu.css('left',wFactor);
	subMenu.css('top',tFactor);
	subMenu.show("fast");
}

function showSub() {
	if (window.timer) {
		clearTimeout(window.timer);
	}
	subMenu.show();
	window.timer = setTimeout("hideSub()", 4500);
}

function hideSub() {
	subMenu.hide();
	clearTimeout(window.timer);
}


// JQUERY
$(document).ready(function() {

$(".standardMatrix tbody tr:odd").addClass("altRow");

$(".hideIt").click(function()
	{
		$(this).hide();
		$(this).prev().prev().children("select").selectOptions("");;
		$(this).prev().slideUp("fast");
		$(this).next().show();
		return false;
	}
);
$(".showIt").click(function()
	{
		$(this).hide();
		$(this).prev().prev().slideDown("fast");
		$(this).prev().show();
		return false;
	}
);
if ($('#map')) {
	var map_data ='<iframe width="100%" height="550" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps?f=d&amp;source=s_d&amp;saddr=Presidential+Blvd+%4030.211384,+-97.659959&amp;daddr=30.194315,-97.623535+to:707+Jeffrey+Way,+round+rock,+tx+78680&amp;hl=en&amp;geocode=FTj9zAEdydMt-g%3BFYu6zAEdEWIu-g%3B&amp;mra=ls&amp;sll=30.380576,-97.676697&amp;sspn=0.190147,0.351906&amp;ie=UTF8&amp;s=AARTsJov4_O6MLpe0KyaQppQLyw75W0mVA&amp;ll=30.366951,-97.630005&amp;spn=0.284372,0.439453&amp;z=10&amp;output=embed"></iframe>';
	$('#map').html(map_data);
}
$('a.external').attr("target","_blank");
$('.newsList a').attr("target","_blank");
//$('.contact_us p a,.news p a,.info_central p a,.about_us p a').mouseover(function() {
	//doSubMenu(this);
	//$('#subMenuHolder').mouseover(function() {
	//	showSub();
	//});
	//$('#subMenuHolder').mouseout(function() {
	//	hideSub();
	//});
	//$('.ultra1 p a').mouseout(function() {
	//	hideSub();
	//});
	//$('#mainZone').click(function() {
	//	hideSub();
	//});
//});
openTour();
cookieBake();
var gallery = $('#gallery').galleriffic('#thumbs', {
    delay:                  3000, // in milliseconds
    numThumbs:              20, // The number of thumbnails to show page
    preloadAhead:           -1, // Set to -1 to preload all images
    enableTopPager:         false,
    enableBottomPager:      false,
    imageContainerSel:      '#slideshow', // The CSS selector for the element within which the main slideshow image should be rendered
    controlsContainerSel:   '#controls', // The CSS selector for the element within which the slideshow controls should be rendered
    captionContainerSel:    '', // The CSS selector for the element within which the captions should be rendered
    loadingContainerSel:    '', // The CSS selector for the element within which should be shown when an image is loading
    renderSSControls:       true, // Specifies whether the slideshow's Play and Pause links should be rendered
    renderNavControls:      true, // Specifies whether the slideshow's Next and Previous links should be rendered
    playLinkText:           'Play',
    pauseLinkText:          'Pause',
    prevLinkText:           '&lt;',
    nextLinkText:           '&gt;',
    nextPageLinkText:       'Next &rsaquo;',
    prevPageLinkText:       '&lsaquo; Prev',
    enableHistory:          false, // Specifies whether the url's hash and the browser's history cache should update when the current slideshow image changes 
    autoStart:              false, // Specifies whether the slideshow should be playing or paused when the page first loads 
    onChange:               undefined, // accepts a delegate like such: function(prevIndex, nextIndex) { ... }
    onTransitionOut:        undefined, // accepts a delegate like such: function(callback) { ... }
    onTransitionIn:         undefined, // accepts a delegate like such: function() { ... }
    onPageTransitionOut:    undefined, // accepts a delegate like such: function(callback) { ... }
    onPageTransitionIn:     undefined  // accepts a delegate like such: function() { ... }
});


});


