var setmanf = null;
var settech = null;

/*
document.write('<script type=\"text/javascript\" src=\"/js/libraries/jquery/jquery.livequery.pack.js\"></script>');
document.write('<script type=\"text/javascript\" src=\"/static/js/libraries/jquery/jquery.livequery.pack.js\"></script>');
*/

$(document).ready(function(){

    /*  add skype meta tag to page*/
    $("body").append('<meta name="SKYPE_TOOLBAR" content="SKYPE_TOOLBAR_PARSER_COMPATIBLE">');
   
	/* used to add the mailto address attr to the breadcrumb mailto link or any anchor tag with the class mailto, current code in page: <a href="mailto:">Contact an Arrow Service Representative</a>, result:<a href="mailto:feedback@arrow.com">Contact an Arrow Service Representative</a>  */
	$("div#brdcrmbs p a, div.grid_6 p.rep a, div#tgln p a, .maillink").attr("href","mailto:feedback@arrow.com");
	
	/* used to write the address within any anchor tag with the class mailto, code in page: <a href="" class="maillink"></a>, result: <a href="mailto:feedback@arrow.com" class="maillink">feedback@arrow.com</a> */
	$(".maillink").append("feedback@arrow.com");
	
	
	/* used to change the value of search criteria hidden tag of the search field */
	/* should change...
	 * from... <input type="hidden" name="search_criteria" value="match_any" />
	 * to... <input type="hidden" name="search_criteria" value="match_begins_with" /> 
	$("#search input[name=search_criteria]").attr({value:"match_begins_with"});*/
	
	/* add some styling to small tabs*/
	if( $("body").is(".supplier")||$("body").is(".products") ){
		if( $("*").index( $('#dmtbs')[0] ) > -1 ){
			$("#sertoo dl:first").attr("class","col-sml");
			$("#sertoo dl:last").attr("class","col-smr");
		}
	}
	
	/* change text and links to small tabs to display constant output */
	$("#offers p.smval a").html("View all available special offers &gt;&gt;");
	$("#offers p.smval a").attr({href:"/special-offers/"});
	$("#events p.smval a").html("View all scheduled events and training &gt;&gt;");
	$("#events p.smval a").attr({href:"/events-training/events-seminars/"});
	
	//popup windows
	var profiles = {
		windowCenter:{
			height:625,
			width:825,
			toolbar:1,
			location:1,
			menubar:1,
			directories:1, 
			scrollbars:1,
			status:1,
			resizable:1,
			center:1
		}
	};
	
	// regular links
	$(".popupwindow").live('click',function(){ 
	  $(this).popupwindow(profiles);
	});
	
	// ajax links
	$('.popupajax').live('click',function(){ 
	  $(this).popupwindow(profiles);
	});
	
	// hide elements with the class jq-hide -- they will re-appear when js disabled; use css to hide all the time
  	$(".jq-hide").hide();
	
	
});
// end jquery code
// test for current environment and set correct url
function pathfinder(){
	var ARROWNAC_URL = "";
	var szCurrentURL = location.hostname;
	if(szCurrentURL != null){
		if( (szCurrentURL.indexOf("dev") >=0) || (szCurrentURL.indexOf("devapp") >=0) ){
			ARROWNAC_URL = "http://dev.arrownac.com/";
		}else if( (szCurrentURL.indexOf("qww") >=0) || (szCurrentURL.indexOf("qwwapp") >=0) || (szCurrentURL.indexOf("qwwapp") >=0) ){
			ARROWNAC_URL = "http://qww.arrownac.com/";
		}else if( (szCurrentURL.indexOf("dww") >=0) || (szCurrentURL.indexOf("dwwapp") >=0) ){
			ARROWNAC_URL = "http://dww.arrownac.com/";
		}else{
			ARROWNAC_URL = "http://www.arrownac.com/";
		}
	}
	return ARROWNAC_URL;
};
var envurl = pathfinder();

// ######################################################################


/** Flippages **/
var openPage=new Array();
function getPage(areaNo, pageNo)
{
  return document.getElementById("page:" + areaNo + ":" + (pageNo));
}

function showPage(areaNo, pageNo)
{
  if(getPage(areaNo, pageNo))
  {
    flipPage=getPage(areaNo, pageNo);
    if(flipPage != openPage[areaNo])
    {
      if(openPage[areaNo])
      { 
        openPage[areaNo].className = openPage[areaNo].className.replace(/ show/, ""); 
      }
      else
      {
        for(i=0; getPage(areaNo, i); i++)
        { 
          otherPage=getPage(areaNo, i);
          before = otherPage.className;
          otherPage.className = otherPage.className.replace(/ show/, ""); 
        }
      }
      flipPage.className += " show";
      openPage[areaNo] = flipPage;
    }
  }
}

function parseHTML(thisString)
{
  return thisString.replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/\n/g, "<br />").replace(/"/g, "&quot;");
}

// end flippages

