﻿/* VIDEO DEFAULTS */
AC_FL_RunContent = 0;
DetectFlashVer = 0;

/* SEARCH */
function askSearch() { 
	if( location.href.indexOf('.com/Barnett') != -1)
		window.location = "/Search/Pages/default.aspx?s=Barnett&k=" + document.getElementById('SearchTextbox').value;
	else if( location.href.indexOf('.com/Marcellus') != -1)
		window.location = "/Search/Pages/default.aspx?s=Marcellus&k=" + document.getElementById('SearchTextbox').value;
	else if( location.href.indexOf('.com/Haynesville') != -1)
		window.location = "/Search/Pages/default.aspx?s=Haynesville&k=" + document.getElementById('SearchTextbox').value;
	else if( location.href.indexOf('.com/Fayetteville') != -1)
		window.location = "/Search/Pages/default.aspx?s=Fayetteville&k=" + document.getElementById('SearchTextbox').value;
	else
		window.location = "/Search/Pages/default.aspx?s=AskChesapeake&k=" + document.getElementById('SearchTextbox').value; 
}

/* DRAGGABLE WEBPART PANE */
function loadDragElements() {
    _spBodyOnLoadWrapper();
    var theHandle = document.getElementById("MSOTlPn_ToolPaneCaption");
    var theRoot = document.getElementById("MSOTlPn_Tbl");
    if(theHandle != null && theRoot != null)
    {
        Drag.init(theHandle,theRoot,null,null,null,null,true);
    }
}

/* ONLOAD */
$(document).ready(function(){


	//Card up the silverpop form//
	var popform = $('.cards fieldset');
	popform.parent().parent().parent().addClass('card').addClass('silverpop');
	popform.parent().parent().addClass('top');
	popform.parent().addClass('bottom');
	popform.addClass('back');
	
	$('.cards fieldset .buttonRow input').addClass('signupButton');
	
	var items = $('.cards fieldset ul li');
	for ( i = 0; i <= items.size(); i++){
		switch(i){
			case 0: items.eq(i).addClass('first'); break;
			case 1: items.eq(i).addClass('second'); break;
			case 2: items.eq(i).addClass('third'); break;
			case 3: items.eq(i).addClass('fourth'); break;
			case 4: items.eq(i).addClass('fifth'); break;
			case 5: items.eq(i).addClass('sixth'); break;
			case 6: items.eq(i).addClass('seventh'); break;
			case 7: items.eq(i).addClass('eighth'); break;
			case 8: items.eq(i).addClass('ninth'); break;
			case 9: items.eq(i).addClass('tenth'); break;
		}
	}
	
	if( $('.cards span.success').length != 0 ) $('.cards fieldset input.textbox').val('');
	
	$('.cards fieldset').siblings('span.success').fadeTo(600,1,function(){
		$(this).animate({top:"0"},900).fadeTo(2200,1,function(){
			$(this).animate({top:"-26px" },600);
		}).click(function(){
			$(this).stop().animate({top:"-26px"},100);
		});
	});
	
	$('.cards fieldset').siblings('span.failed').fadeTo(600,1,function(){
		$(this).animate({top:"0"},900).fadeTo(2200,1,function(){
			$(this).animate({top:"-58px" },600);
		}).click(function(){
			$(this).stop().animate({top:"-58px"},100);
		});
	});
	
	$('.cards fieldset input.textbox').siblings('span.validationLabel').siblings('input.textbox').blur(function(){
		if( $(this).val() == '' ) $(this).siblings('span.validationLabel').fadeIn().fadeTo(1500,1,function(){
			$(this).fadeOut();
		})
		$(this).siblings('span.validationLabel').click(function(){
			$(this).stop().fadeOut(100);
		});
	});
	$('.editmode .cards fieldset ul li.third input').val('editing...');
	$('.cards fieldset').show();



	
	//Choose your location menu//
	$("#absoluteLocation").hover (
		function () { 
			$("#locationLists").fadeIn(200);
			$("#SearchTextbox").blur();
		}, 
		function () { 
			$("#locationLists").fadeOut(120);
		} 
	);


	//Search box effects//	
	$("#SearchTextbox").fadeTo(1,.7);
	
	$("#SearchTextbox").hover ( 
		function() { 
			$(this).focus();
			$(this).fadeTo(1,1);
		}, 
		function() { 
			$(this).fadeTo(1,1);
		}
	);
	
	$("#SearchTextbox").focus ( 
		function() { 
			$(this).fadeTo(1,1);
		}
	);
	
	$("#SearchTextbox").blur (  
		function() { 
			$(this).fadeTo(1,.7);
		}
	);
	
	
	if( $('div.RadTabStrip').length > 0 ){
		//Shale Tab Styles//
		$(".shale #tabular ul.rtsUL li:nth-child(1) a").css ('background-position', '-180px 0');
		$(".shale #tabular ul.rtsUL li:nth-child(2) a").css ('background-position', '-180px 0');
		$(".shale #tabular ul.rtsUL li:nth-child(3) a").css ('background-position', '-360px 0');
		$(".shale #tabular ul.rtsUL li:nth-child(4) a").css ('background-position', '-540px 0');
	
		$(".shale #tabular ul.rtsUL li a.rtsSelected").hover ( 
			function() { $(this).css('background-position', '0 0');}, function() { $(this).css('background-position', '0 0');}
		);
	
		$(".shale #tabular ul.rtsUL li:nth-child(1) a").hover ( 
			function() { $(this).css('background-position', '-180px -78px');}, function() { $(this).css('background-position', '-180px 0');}
		);
		$(".shale #tabular ul.rtsUL li:nth-child(2) a").hover ( 
			function() { $(this).css('background-position', '-180px -78px');}, function() { $(this).css('background-position', '-180px 0');}
		);
		$(".shale #tabular ul.rtsUL li:nth-child(3) a").hover ( 
			function() { $(this).css('background-position', '-360px -78px');}, function() { $(this).css('background-position', '-360px 0');}
		);
		$(".shale #tabular ul.rtsUL li:nth-child(4) a").hover ( 
			function() { $(this).css('background-position', '-540px -78px');}, function() { $(this).css('background-position', '-540px 0');}
		);
		
		$(".shale #tabular table table div div div:nth-child(2)").children("div").each(
			function(i){
				//$(this).attr({class: "copy"});
				$(this).addClass("copy");
			}
		);
	}
	
	//Card Backgrounds//
	//hide card images with the background class and copy the path to the parent's background image style
	$(".card img.background").css('display', 'none');
	$(".card img.background").parent().each(function (i) {
	    $(this).css("background-image", "url("+  $(this).find('img.background').attr("src") +")");
    });
    
    
    //BanerBox Backgrounds//
	$("#bannerBox img.background").css('display', 'none');
	$("#bannerBox img.background").parent().each(function (i) {
	    $(this).css("background-image", "url("+  $(this).find('img.background').attr("src") +")");
    });

    
    //Tabular Copy Background//
    //if the tabular section is empty give the copy section the class with the background gradient       
    //if the tabular section is not empty give the copy section the class without the background gradient
    $("#tabular").children().each(function (i) {
    	$("#copySection").removeClass('copyTop');
	    $("#copySection").addClass('copyBottom');
    });


	//empty byline//
	$(".by-line").each(function(i){
		var bytext = $(this).html();
		if (bytext == "By ") { $(this).html(""); bytext = ""; }
		if (bytext == "") { $(this).removeClass('by-line'); $(this).addClass('hidden'); }
		else $(this).html("By " + bytext);
    });



	//horizontal-rule replacement//
	$('<img class="hr" src="/Style Library/Images/arc-shale-copy-alpharule-640x12.png"/>').replaceAll("#copySection #copy hr");
	$('<img class="hr" src="/Style Library/Images/arc-shale-copy-alpharule-640x12.png"/>').replaceAll("#copySection.copyTop.crm hr");
	
	//Q. & A. style
	$("blockquote/p:contains('A. ')").addClass('AnswerBlock');
	$(".AnswerBlock").each(function (i) { $(this).html($(this).html().replace('A. ','')); });
	$("h3:contains('Q. ')").addClass('QuestionHeader');
	$("h4:contains('Q. ')").addClass('QuestionHeader');
	$("h5:contains('Q. ')").addClass('QuestionHeader');
	$(".QuestionHeader").each(function (i) { $(this).html($(this).html().replace('Q. ','')); });

	
	// Rad editor comes in with style set to display:inline; for some reason.  This kills that.  In banner divs.  With content.
	if ($("#banner div[id*='RichHtmlField']").html() != '') 
		$("#banner div[id*='RichHtmlField']").attr({style: ''}).addClass('bannerEditorWithContent');


	//makes the slider buttons transparent in IE6.  Yes this could be added in the webpart, cheese and crackers.
	$('.ie6 #slider a.prev').addClass('png');
	$('.ie6 #slider a.next').addClass('png');


	// gets rid of the one pixel white line above the flipper in the flashCardArea in ie6&7
	$('.ie6 .homelayout div#flipper table tbody tr').eq(0).addClass('sillyIeSixAndSevenPop').hide();
	$('.ie7 .homelayout div#flipper table tbody tr').eq(0).addClass('sillyIeSixAndSevenPop').hide();
	

	//ties the slider poplink to the flipper pops
	$('.popLink').click(function (i) {
		if ($('.' + $(this).attr("id")).is(':hidden')){
			
			$('.sillyIeSixAndSevenPop').show();
			
			if ($('#flipper .pop').is(':visible')){ $('#flipper .pop').slideUp("slow"); }
			
			$('.' + $(this).attr("id")).slideDown("slow");
			
			$('#hidePop').fadeIn("slow");
			
			$('.slides-nav').slideUp("fast");
			
		} else {
			$( '.' + $(this).attr("id") ).animate( { left:"-3px" }, 40 ).animate( { left:"3px" }, 80 ).animate( { left:"-3px" }, 80 ).animate( { left:"0" }, 40 );
		}
	});
	
	$('#hidePop').click(function (i) {

		if ($('#flipper .pop').is(':visible')){
			$('#flipper .pop').slideUp("slow");
		}
		$('.slides-nav').slideDown("fast");
		$('#hidePop').fadeOut("slow");
		
		$('.sillyIeSixAndSevenPop').hide("slow");
	});



	//adds zip or pdf icons to lightbox image gallery download links
	$("a.photo-image-download[href$=zip]").addClass("zipFileLink");
	$("a.photo-image-download[href$=pdf]").addClass("pdfFileLink").attr({ target: "_blank" });
	$("a[href$=pdf]").addClass("pdfFileLink").attr({ target: "_blank" });
	$("a[href$=pdf]>img").parent().removeClass("pdfFileLink").addClass("pdfImageLink").attr({ target: "_blank" }).append('<img class="iconOverlay" src="/Style Library/Images/arc-pdf-icon-26x22.png" alt="pdf" />');
	$("a.button").removeClass("pdfFileLink");

	//changes out old event list class with the new one.  Don't look at me like that! :(
	$("ul.events").removeClass("events").addClass("hoodEventList");


	//forces links ending in chk.com and cngnow.com to open in a new window.
	$("a[href*=chk.com]").attr({ target: '_blank' });
	$("a[href*=cngnow.com]").attr({ target: '_blank' });

	
	// need to add the background iframe plugin for ie6, or just wait until 2/2010 - fingers crossed!
	//$.ui.dialog.defaults.bgiframe = true;


	// creates the map dialog
	$("#mapDialog").dialog({
		autoOpen: false,
		dialogClass: 'mapDialogBox',
		hide: 'slide',
		modal: true,
		resizable: false,
		width: 720,
		zIndex:79998
	});


	// opens the map dialog on click events
	$('#map a').click(function() { $("#mapDialog").dialog('open'); });
	$('#absoluteLocation').click(function() { $("#mapDialog").dialog('open'); });


});
