// custom functions


$(document).ready(function(){
	//Examples of how to assign the ColorBox event to elements
	/*$("a[rel='example1']").colorbox();
	$("a[rel='example2']").colorbox({transition:"fade"});
	$("a[rel='example3']").colorbox({transition:"none", width:"75%", height:"75%"});
	$("a[rel='example4']").colorbox({slideshow:true});*/
	$("a.login").colorbox();
	$("li.uf2 a").colorbox();
	//$("a[rel='newsgroup']").colorbox();
	//$(".newsAndJobList li.newsitem a").each(function(){ $(this).colorbox({rel:'newsgroup'}); });
	$("#footerNavigation a[href='career_popup.htm']").colorbox();
	/*$(".example6").colorbox({iframe:true, innerWidth:425, innerHeight:344});
	$(".example7").colorbox({width:"80%", height:"80%", iframe:true});
	$(".example8").colorbox({inline:true, href:"#loginform"});
	$(".example9").colorbox({
		onOpen:function(){ alert('onOpen: colorbox is about to open'); },
		onLoad:function(){ alert('onLoad: colorbox has started to load the targeted content'); },
		onComplete:function(){ alert('onComplete: colorbox has displayed the loaded content'); },
		onCleanup:function(){ alert('onCleanup: colorbox has begun the close process'); },
		onClosed:function(){ alert('onClosed: colorbox has completely closed'); }
	});*/
	
	$(".newsAndJobList li a[rel='newsgroup']").colorbox();
	
	
	
	//Example of preserving a JavaScript event for inline calls.
	$("#click").click(function(){ 
		$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
		return false;
	});
	
	// $(".example1").colorbox({rel: true});
	/* Open the News Items */
	//$("li.newsitem").colorbox();
	
	/* Open the Tip a Friend Item */
	$('li.uf2 a').click(function(){
		$.fn.colorbox({href:this.href});
		return false;
	});
	
	/* Open the Job Application Item */
	 $('li.apply a').click(function(){
	    $.fn.colorbox({
	       href:this.href,
	       iframe:true,
	       innerWidth:500,
	       innerHeight:582,
	       scrolling:false,
	    });
	    return false;
	 });
	 
		/* Open the Tip a Friend Item */
		$('li.uf2 a').click(function(){
			$.fn.colorbox({
			     href:this.href,
			     iframe:true,
			     innerWidth:500,
			     innerHeight:368,
			     scrolling:false,
			});
			return false;
		});
	  	
	 /* Bind bulps to colorbox*/
	 $("a[rel='infoBlock']").colorbox();
	 
	 /* bind hover on flags */
		$("#summaryPages ul li a").hover(
		  function () {
		    $(this).parent().addClass('jqhover');
		  }, 
		  function () {
		    $(this).parent().removeClass('jqhover');
		  }
		);
	 	
	
});


$(document).ready(function(){
	$(".tipbox .field label").addClass("posLabel");
	$(".tipbox .field label").each(function(){
		$(this).click(function(){
			$(this).addClass("hide");				 
		});
	});						   
});

$(document).ready(function(){
	$("li.uf2 a").click(function(){
		$("#cboxOverlay").addClass("tipafriend");
		$("#colorbox").addClass("tipafriend");
	});
	$("#cboxClose").click(function(){
		$("#cboxOverlay").removeClass("tipafriend");
		$("#colorbox").removeClass("tipafriend");
	});
});


$("input[type=file]").filestyle({ 
	image: "images/choosefile.png",
	imageheight : 28,
	imagewidth : 123,
	width : 300
});

/*-- Open links with class="external" in new window --*/

$(document).ready(function(){
	$('a.external').click(function(){
		window.open(this.href);
		return false;
	});
});

$(document).ready(function(){	
	if($("#articleImgSrc img").length > 0)
	{
		if($("#articleImgSrc img").attr("src").length > 0){
			var imgSrc = $("#articleImgSrc img").attr("src");
			$("#headerPic img").attr("src", imgSrc);
			$("#header").css("background-image", "url('"+imgSrc+"')");
			$("#headerPic img").show();
		}
	}
	
	$("#utPrint").bind('click', function(){
		print();
		return false;
	});
});

// AddThis Configuration

var addthis_config = {
     username: 'xa-4bcec51b466ea2d0',
     services_compact: 'email, facebook, twitter, more',
     services_exclude: 'print, email' 
}

function insertMedia()
{
    for( var k = 0, l = arguments.length; k < l; k++ )
    {
        document.write( arguments[k] );
    }
}


//*** Our services script ***
var jsReady = false;
function isReady() {
	return jsReady;
}

$(document).ready(function(){
	jsReady = true;
	$("a[rel='infoBlock_menuitem0']").colorbox();
	$("a[rel='infoBlock_menuitem1']").colorbox();
	$("a[rel='infoBlock_menuitem2']").colorbox();
	$("a[rel='infoBlock_menuitem3']").colorbox();
	$("a[rel='infoBlock_menuitem4']").colorbox();
	$("a[rel='infoBlock_menuitem5']").colorbox();
	$("a[rel='infoBlock_menuitem6']").colorbox();
	if($(".ourservice_subpage:visible").length == 0){
		$("#ourservice_menuitem0").show();
	}
});	

function getFlashMovieObject(movieName) { 
	if(document.embeds[movieName])
		return document.embeds[movieName];
	if(window.document[movieName])
		return window.document[movieName];
	if(window[movieName])
		return window[movieName];
	if(document[movieName])
		return document[movieName];
	return null;
}

function selectSwfMenuItem(value) {
	try {
			//alert(value);
			getFlashMovieObject("flashContent").selectMenuItem(value);
			setOurServiceSubpageVisibility(value);
	} catch (err) {
			alert("Error: " + err.toString());
			error = true;
	}
	//thisMovie("gln-services-menu").selectMenuItem(value);
	//document.forms["form1"].output.value += "Selecting menu item: " + value + "\n";
	//alert(value);
}

function selectHtmlMenuItem(value) {
	//document.forms["form1"].output.value = "ActionScript says: " + value + "\n";
	//alert('hepp: '+value);
	setOurServiceSubpageVisibility(value);

}

function setOurServiceSubpageVisibility(value) {
		$(".ourservice_subpage").each(function(){ $(this).hide(); });
		$("#ourservice_"+value).show();
		//$("a[rel='infoBlock']").colorbox();
		$("ul.subNavigation li").removeClass('selected');
		$("#li_"+value).addClass('selected');
}


//*** end Our services script ***   

//*** begin flash detection script ***



//**** end flash script detection script *** 

//****** careeer page
				var current_page = 1;
				function turnPage(pages, target) {
					for (x=1; x < pages; x=x+1) {
						$('#'+x).hide();	
					}
					switch (target) {
					
						case 'previous':
							if (current_page == 1) {
								$('#'+current_page).show();
								return false;
							} else {
								var previous_page = current_page;
								$('#'+previous_page).hide();							
								current_page = current_page-1;
								$('#'+current_page).show();	
								$('#current_page_up').html(current_page);
								$('#current_page_bot').html(current_page);
								if (current_page == 1) {
									$('#previous_up').addClass('inactive');
									$('#previous_bot').addClass('inactive');
								} 
								if (current_page == 1) {
									$('#next_up').removeClass('inactive');
									$('#next_bot').removeClass('inactive');
								}
								return false;	
							}		
														
						break;					
						
						case 'next':
							if (current_page == pages) {
								return false;
							} else {
								current_page = current_page+1;
								$('#'+current_page).show();	
								$('#current_page_up').html(current_page);
								$('#current_page_bot').html(current_page);
								if (current_page == pages) {
									$('#next_up').addClass('inactive');
									$('#next_bot').addClass('inactive');
								} 
								if (current_page == 2) {
									$('#previous_up').removeClass('inactive');
									$('#previous_bot').removeClass('inactive');
								}
								return false;
							}										
						break;
					
					}
				}			

				function showCareerContent(nodeid, total, items) {		
					for (x=0; x <= total; x=x+1) {
						$('#'+x+'_js').hide();	
						$('#'+x+'_link').show();
						$('#'+x+'_unlink').hide();
					}		
					$('#'+items+'_js').show();
					$('#'+items+'_link').hide();
					$('#'+items+'_unlink').show();
					
				}
//**** end careeer page         

