var closeTimer //used for mouseover close events
var loc = document.location + ""
var hasInvestorView = 0
var slideDelay = 8000
var slideTimer
var homeSlidePos = 0
var jsNothing = "javascript://"
var dialogCache
var dialogSource


$(document).ready(function() { init() })

//main event initilization
function init() {
    if (loc.indexOf('localhost')>0) {
         $('img').each(function() {
            $(this).attr('src',$(this).attr('src').replace("/Assets","/NorthlandPower/NorthlandPower/Assets"))
         } )  
    }

    //set dialog for investor pages
    if (loc.indexOf('WhyownNPI') > 0) {
        var hasAccess = getCookie('npi')
        if (hasAccess != 'ok') {
            openDialog('#forwardLookingResponse')
        }
    }

//remove the Conversion notice as client required on Feb 10, 2011
//    var hasAccess = getCookie('npiName')
//    if (hasAccess != 'ok') {
//    	$('#dialog').click(function() { confirmName() })
//    	openDialog('#nameResponse')
//    }

    //clean up empty urls
    $('a').each(function() {
    if ($(this).attr('href') == "#" || $(this).attr('href') == "") {
            $(this).attr('href',jsNothing)
        }
    })
    
	if ($(".sortable")) {
		$(".sortable").tablesorter();
	}

	$('#menu a').click(function() { subNav(this) })

	$('#search').value = ""
	$('#searchWrapper').click(function() { initSearch() })
	$('#searchWrapperFR').click(function() { initSearch() })
	$('#search').click(function() { initSearch() })
	/* $('#doSearch').click(function() { doSearch('text') }) */
	$('#overlayGreen').click(function() { confirmName(); closeDialog(); })
	$('#openWindDiagram').click(function() { openDialog('#windDiagramResponseEN') })
	$('#openWindDiagramFR').click(function() { openDialog('#windDiagramResponseFR') })
	mousePanel('#moreHeadlinesLink', '#moreHeadlines', 'moreHeadlines')
	mousePanel('#publicAccessLink', '#publicAccess', 'publicAccess')
		
    //activate sub-nav panels
	$('.subnav ul li h3 a').each(function() {
		mousePanel($(this), $(this).parent().next('ul'), 'showSub')
		//prevent roll-over on sub-nav with no children
		if (!$(this).parent().next('ul').length) {
			$(this).addClass('staticArrow')
		}
		if ($(this).text().indexOf('FINANCIAL REPORTS')>-1) {
			$(this).html("FINANCIAL<br />REPORTS")
		}
		if ($(this).text().indexOf('OPERATING ASSETS') > -1) {
			$(this).html("OPERATING<br />ASSETS")
		}

	})

	//handle URL hash
	$('ul.green').hide()
    
    $('.middle .print').click(function(){window.print()})
		
	if (loc.indexOf("#") > 0) {
	    incomingHash()
	}
	else {
        $('#mainLeftNav').css('margin-top','0')
	}

	//hide second-level left nav
	
	$('.greenArrow').each(function() {
	    if($(this).attr('href')=='') {
	        $(this).attr('href',"javascript:;//")
	    }
	})
	$('.greenArrow').click(function() {
	    $('#leftNav ul li a.greenArrow').removeClass('active')
	    if (!$(this).siblings().is(':visible')) {
	        $(this).addClass('active')
	    }
	    $(this).siblings().slideToggle()
	})

	//start homepage slideshow
	if ($('#homeImg img').length>0) {
	    var slideNav = "<div id='slideNav'><a onclick='slidePrev()' href='javascript:;//previous'>&lt;&lt;</a>&nbsp;<span id='slidePos'>1</span>&nbsp;<a onclick='slideNext()' href='javascript:;//next'>&gt;&gt;</a></div>"
	    $('#homeImg').append(slideNav)
	    window.setTimeout(function() {
	        $('#caption').fadeIn('slow')
	    }, 2000)
	        
	    slideTimer = window.setTimeout(function() {	        
	        runSlideshow()	        
	    }, 10000)
	}

	//osc filing image shadows
	if ($('#oscFilings img').length>0) {
	    window.setTimeout(function(){addShadows('#oscFilings')},150)
	}

	//careers page
	if ($('.cPeople').length) {
	    $('.cPeople ul li a').mouseover(function() {
	        $('.cPeople ul').css('background-image', 'url(/images/careers/' + $(this).parent().attr('class') + '.png)')
	        
	    })
	    $('.cPeople ul li a').hover(function() {
	        $(this).next('label').children('a').css('color', '#006A51');
	    }, function() {
	        $(this).next('label').children('a').css('color', '');
	    });
		$('.cPeople ul li a').click(function() {
			showCareer($(this).parent().attr('class'))
		})
		$('.cPeople ul li label').mouseover(function() {
			$('.cPeople ul').css('background-image', 'url(/images/careers/' + $(this).parent().attr('class') + '.png)')
		})
		$('.cPeople ul li label').click(function() {
			showCareer($(this).parent().attr('class'))
		})
		$('.cPeople ul').mouseout(function() {
			$('.cPeople ul').css('background-image','none')
		})
	}

	if ($('#pText')) {
		$('#pText').css('border', "1px solid #ffffff")
	}

	
}



//utility functions - common library
function findPos(obj) {
	//returns x,y coordinates of an element
	var curleft = 0;
	var curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft, curtop];
}

function closeInit(element) {

	//timer for mouseout on panels
	clearTimeout(closeTimer)
	closeTimer = window.setTimeout(function() { closePanel(element) }, 400)
}

function closePanel(element) {
    if ($(element).hasClass('dropMenu')) {
	    $(element).siblings().find('a').removeClass('active')
	}
	$(element).fadeOut('fast', function() { $(element).parent().find('.menuGradient').remove() });
}

function mousePanel(src, panel, initFunction) {
	$(src).mouseover(function() { window[initFunction](src) })
	$(src).mouseout(function() { closeInit(panel) })
	$(panel).mouseover(function() { clearTimeout(closeTimer) })
	$(panel).mouseout(function() { closeInit(panel) })
}

function openDialog(element) {
	//this is the general dialog handler.
	//pass the element name and this will copy
	//the contents of the element to the dialog box

	$('#overlayGreen').css('height', $(document.body).height()*2 + 'px')
	$('#overlayGreen').show()
	$('#dialog').html($(element).html())
	dialogCache = $(element).html()
	dialogSource = element
	$(element).html("")
	    

	centerMe('#dialog')
	$('#dialog .close').attr('href', 'javascript:closeDialog()')
	$('#dialog .print').attr('href','javascript:;//')
	$('#dialog .print').click(function() { printDialog() })

	$('#dialog a').each(function() {
	    if ($(this).attr('href') == "#" || $(this).attr('href') == "") {
	        $(this).attr('href', jsNothing)
	    }
	})


	$('#dialog').show();
	checkScroll()
    clearScroll()

}

function closeDialog() {
    $('.handle').css('top','0px')
	$('#overlayGreen').hide()
	$(dialogSource).html(dialogCache)
	$('#dialog').hide()
	$('#dialog').html('')
}

function centerMe(element) {
	//pass element name to be centered on screen
	var pWidth = $(window).width();
	var pTop = $(window).scrollTop()
	var eWidth = $(element).width()
	var height = $(element).height()
	$(element).css('top', '130px')
	//$(element).css('top',pTop+100+'px')
	$(element).css('left', parseInt((pWidth / 2) - (eWidth / 2)) + 'px')
}

function setCookie(c_name, value, expiredays) {
    var exdate = new Date()
    exdate.setDate(exdate.getDate() + expiredays)
    document.cookie = c_name + "=" + escape(value) +
	((expiredays == null) ? "" : ";expires=" + exdate.toGMTString())
}

function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=")
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1
            c_end = document.cookie.indexOf(";", c_start)
            if (c_end == -1) c_end = document.cookie.length
            return unescape(document.cookie.substring(c_start, c_end))
        }
    }
    return ""
}


// site-specific code
function subNav(element) {
    if (!$(element).hasClass('mnuMain')) {
        return
    }

    $('#menu h2').removeClass('active')
    $(element).parent().addClass('active')
    
    var visibleAlready = 0
    if($('.subnav').is(':visible')) {
        visibleAlready = 1
    }
    
    
    $('.subnav').hide()
    var buttonClass = $(element).attr('class').split(' ').slice(-1) + ""
    buttonClass = buttonClass.replace("main_", "")


    if (visibleAlready) {
        $('.subNav' + buttonClass).show()       
    }
    else {
        $('.subNav' + buttonClass).fadeIn('slow', function() {
           // $('#mainGradient').show()
            //$('#mainLeftNav').css('margin-top', '48px')
        })
        $('#mainGradient').fadeIn('slow')
        $('#mainLeftNav').css('margin-top', '48px')
    }
}


function showPage(pageName) {
	//DEMO MODE
	$('.middle').hide()
	$('#' + pageName).show()
}

function showSub(element) {
    $('.dropMenu').hide()
    $(element).addClass('active')
    var target = $(element).parent().next('ul')
    
    //ie hack
    if (target.css('z-index') == 3) {
        $('.menuGradient').remove()
        $(target).before("<div class='menuGradient'></div>")
        $(target).show()
    }
    else {
        $(target).fadeIn('fast')
    }
}

function initSearch() {
	$('#searchWrapper').unbind('click');
	$('#searchWrapper').addClass('active')
	$('#searchWrapperFR').unbind('click');
	$('#searchWrapperFR').addClass('active')
	$('#search').show()
	$('#search').focus()
	
}

function doSearch(searchTerm) {
	document.location = '/Search.aspx?st=' + searchTerm;
	return false;
}

function showSpotlight() {
	openDialog('#spotLightResponse')
}


function moreHeadlines() {
    clearTimeout(closeTimer)
	myPos = findPos(document.getElementById('moreHeadlinesLink'))
	$('#moreHeadlines').css('left', '-9999')
	$('#moreHeadlines').show()
	var dialogHeight = $('#moreHeadlines').height()
	$('#moreHeadlines').hide()
	$('#moreHeadlines').css('top', myPos[1] - dialogHeight + 7 + 'px')
	$('#moreHeadlines').css('left', myPos[0] - 9 + 'px')
	$('#moreHeadlines').fadeIn('medium');
}

function publicAccess() {
    clearTimeout(closeTimer)
    myPos = findPos(document.getElementById('publicAccessLink'))
    $('#publicAccess').css('left', '-9999')
    $('#publicAccess').show()
    var dialogHeight = $('#publicAccess').height()
    $('#publicAccess').hide()
    
    //$('#publicAccess').css('top', myPos[1] - 93 + 'px')
    var browser = navigator.userAgent;
    //alert(navigator.userAgent);
    if (browser.indexOf('MSIE 7.0') > -1)
        $('#publicAccess').css('top', myPos[1] - 133 + 'px')
    else if (browser.indexOf('MSIE') > -1)
        $('#publicAccess').css('top', myPos[1] - 127 + 'px')
    else
        $('#publicAccess').css('top', myPos[1] - 123 + 'px')
    
    $('#publicAccess').css('left', myPos[0] - 27 + 'px')
    $('#publicAccess').fadeIn('medium');
}

function dynamicLayout() {
    var browser = navigator.userAgent;
    var numberOfChildren = $('#bottomMenu ul li').size();
    
    switch(numberOfChildren)
    {
        case 2:
            $('#bottomMenu ul li a').css('padding-top', '9px');
            $('#bottomMenu ul li a').css('padding-bottom', '10px');
            break;
        case 3:
            $('#bottomMenu ul li a').css('padding-top', '4px');
            $('#bottomMenu ul li a').css('padding-bottom', '5px');
            break;
        case 4:
            $('#bottomMenu ul li a').css('padding-top', '1px');
            $('#bottomMenu ul li a').css('padding-bottom', '2px');
            break;
    }
}


function insideNorthland() {
	openDialog('#insideNorthlandResponse')
}

function infoPanel(section) {
    openDialog('#infoPanelResponse')
	$("#dialog .handle").draggable({ axis: 'y', containment: 'parent', drag: function(event, ui) { setScroll() } });
}

function showLookingForward() {
	openDialog('#forwardLookingResponse')
}

function showMoreLikeThis() {
	openDialog('#moreLikeThisResponse')
	checkScroll()
}


function printDialog() {
	if ($('#printFrame').length) {
		$('#printFrame').remove()
	}
	//$('#root').after('<iframe src="Print.htm" name="printFrame" id="printFrame" style="border:none;display:block;height:1px;width:1px;margin-left:-5000"></iframe>')
	$('#root').after('<iframe src="http://' + location.host + '/Print.htm" name="printFrame" id="printFrame" style="border:none;display:block;height:1px;width:1px;margin-left:-5000"></iframe>')
}

function printContent() {  	
	if ($('#printContent').length) {
		$('#printContent').remove()
	}
	var filepath ="<iframe src=http://" + location.host + "/PrintContent.htm" +" name='printFrame'  id='printContent' style='border:none;display:block;height:1px;width:1px;margin-left:-5000'></iframe>" ;
	$('#root').after(filepath)

}

function initPrint() {
	$('#content').html(parent.$('#Content').html())
	document.printFrame.window.focus()
	document.printFrame.window.print()
}


function incomingHash() {
    // menu and diaglog state handler

    var hash = "" + loc.split('#').slice(-1)
    var thisHash
    var main
    var sub
    var lightBox 
    hash = hash.split("&")
    for (var x = 0; x < hash.length; x++) {
        //process pair
        thisHash = hash[x].split("=")
        if (thisHash[0] == "m") {
            main = thisHash[1]
        }
        if (thisHash[0] == "s") {
            sub = parseInt(thisHash[1])
        }
        if (thisHash[0] == "l") {
            lightBox = thisHash[1]
        }
    }

    //show menu
    subNav($("#menu a:eq(" + main + ")"))    

    //set subnav active
    $('.subNav' + main).show()
    $('.subNav' + main + " h3 a:eq(" + sub + ")").addClass('active')
    
    //set left nav active
    $('#leftNav ul.green li.active').parent().show()
    $('#leftNav li.active ul.green').show(); // Added as per FX
    
    //FX:  fixed this issue by modify Leftnav code when create HTML
	//	$('#leftNav ul.green li.active').parent().siblings().addClass('active')
	//    if (sub != '' && main == 1) {
	//        $("#leftNav ul a.greenArrow:eq(" + (sub - 1) + ")").addClass('active')
	//        $("#leftNav ul a.greenArrow:eq(" + (sub - 1) + ")").next().show()
	//    }
    
    
    //ie fix 
    if ($('#root').css('azimuth') == 'behind') {
        $('#mainLeftNav .gradient').css('position', 'absolute')
        $('#mainLeftNav .gradient').css('top', '48px')
        $('#mainLeftNav').css('padding-top','48px')
    }
    
    if (lightBox != '') {       
        $("#"+lightBox).trigger('click')
    }
    
    
}

function confirmInvestor() {
	setCookie('npi', 'ok', 1)
	if ($('#cookieContent').length == 0) {
		var filepath = "<iframe src=http://" + location.host + "/Cookie.htm" + " name='cookieFrame'  id='cookieContent' style='border:none;display:block;height:10px;width:10px;margin-left:50'></iframe>";
		$('#root').after(filepath)
	}
  
    closeDialog()
}


function confirmName() {
	setCookie('npiName', 'ok', 1)
	if ($('#cookieContent').length == 0) {
		var filepath = "<iframe src=http://" + location.host + "/Cookie.htm" + " name='cookieFrame'  id='cookieContent' style='border:none;display:block;height:10px;width:10px;margin-left:50'></iframe>";
		$('#root').after(filepath)
	}

	closeDialog()
}

function runSlideshow() {
    if (typeof homeSlides == 'undefined') {
        return
    }
    clearTimeout(slideTimer)
    $('#homeImg').css('background-image', 'url(' + $('#homeImg img').attr('src') + ')')
    
    homeSlidePos++
    if(homeSlidePos==homeSlides.slides.length) {
        homeSlidePos = 0
    }
    $('#slidePos').html(homeSlidePos + 1)
    flipSlide(homeSlidePos)    
    slideTimer = window.setTimeout(function() { runSlideshow() }, slideDelay)

}

function flipSlide(pos) {
    $('#homeImg img').hide()
    $('#caption').hide()
    $('#homeImg img').attr('src', homeSlides.slides[homeSlidePos].img)
    //$('#homeImg img').attr('src', homeSlides.slides[homeSlidePos].img.replace("/Assets", "Assets"))
    posPlus = pos + 1;
    $('#captionText').html(homeSlides.slides[homeSlidePos].txt + '&nbsp;<a class="more" onclick="_gaq.push([&apos;_trackPageview&apos;,  document.location.pathname + &apos;/Widget-Link' + posPlus + '&apos;]);slideDialog();" href="javascript://">' + txtMore + '</a>')
    $('#homeImg img').fadeIn('slow')
    window.setTimeout(function() { $('#caption').fadeIn('slow') }, 500)
}

function slidePrev() { 
    clearTimeout(slideTimer)
    if (homeSlidePos == 0) {
        homeSlidePos = homeSlides.slides.length-1
    }
    else {
        homeSlidePos--
    }
    $('#slidePos').html(homeSlidePos+1)
    $('#homeImg').css('background-image', 'url(' + $('#homeImg img').attr('src') + ')')
    flipSlide(homeSlidePos)
    slideTimer = window.setTimeout(function() { runSlideshow() }, slideDelay)
}

function slideNext() {
    clearTimeout(slideTimer)
    homeSlidePos++
    if (homeSlidePos>homeSlides.slides.length-1) {
        homeSlidePos = 0
    }
    $('#slidePos').html(homeSlidePos + 1)
    $('#homeImg').css('background-image', 'url(' + $('#homeImg img').attr('src') + ')')
    flipSlide(homeSlidePos) 
    slideTimer = window.setTimeout(function() {runSlideshow()}, slideDelay)
}

function slideDialog() {
    clearTimeout(slideTimer)
    // JS 20110707 getting rid of sliderTrack
    //$('#general').html("<div class='insideNorthland'><div class='greenLine'></div><div class='imageHolder'><img width='220' src='" + homeSlides.slides[homeSlidePos].thumb + "'></div><h3>Northland Power</h3><div class='scrollPanel' style='width: 380px; margin-top: 10px; margin-bottom: 30px;'><div class='insideTextImage scrollable scrollTarget' style='width: 370px; border: medium none;'>" + homeSlides.slides[homeSlidePos].detail + "</div></div><div id='sliderTrack'><div class='handle ui-draggable'></div></div><div class='clear'></div><div class='insideControls'><a class='print left' href='javascript:;//' onclick='_gaq.push([&apos;_trackPageview&apos;, document.location.pathname+&apos;/Print-button&apos;]);'></a><a class='email' onclick='_gaq.push([&apos;_trackPageview&apos;, document.location.pathname+&apos;/Email-button&apos;]);openEmail()' href='javascript://'></a></div><a onclick='closeDialog()' class='close right padR25 green size10' href='javascript:closeDialog()'>" + txtClose + " X</a><div class='clear'></div></div>");
    $('#general').html("<div class='insideNorthland'><div class='greenLine'></div><div class='imageHolder'><img width='220' src='" + homeSlides.slides[homeSlidePos].thumb + "'></div><h3>Northland Power</h3><div class='scrollPanel' style='width: 380px; margin-top: 10px; margin-bottom: 30px;'><div class='insideTextImage scrollable scrollTarget' style='width: 370px; border: medium none;'>" + homeSlides.slides[homeSlidePos].detail + "</div></div><div class='clear'></div><div class='insideControls'><a class='print left' href='javascript:;//' onclick='_gaq.push([&apos;_trackPageview&apos;, document.location.pathname+&apos;/Print-button&apos;]);'></a><a class='email' onclick='_gaq.push([&apos;_trackPageview&apos;, document.location.pathname+&apos;/Email-button&apos;]);openEmail()' href='javascript://'></a></div><a onclick='closeDialog()' class='close right padR25 green size10' href='javascript:closeDialog()'>" + txtClose + " X</a><div class='clear'></div></div>");
    
    openDialog('#general')
    if ($("#dialog .scrollTarget").height() > $("#dialog .scrollPanel").height()) {
        // JS 20110707
        /*$("#dialog .handle").draggable({ axis: 'y', containment: 'parent', drag: function(event, ui) { setScroll() } });*/
        $('.scrollTarget').jScrollPane({
            horizontalDragMinWidth: 20,
            horizontalDragMaxWidth: 20,
            verticalDragMinHeight: 40,
            verticalDragMaxHeight: 40
        });
    }
    else {
        $("#dialog #sliderTrack").hide()
    }
}

function openEmail() {
	openDialog('#emailFriendResponse')
}

function setScroll() {

    //scrollbar handler for notes
    var myTop = parseInt($('#dialog .handle').css('top').replace('px', ''))
    var trackHeight = $('#dialog #sliderTrack').height()
    var sliderPos = myTop / trackHeight * 1.1

    var contentHeight = $('#dialog .scrollTarget').height()
    $('#search').val(contentHeight + ", " + $('#dialog .scrollPanel').height())
    if (contentHeight < $('#dialog .scrollPanel').height()) {
        return;
    }
    newTop = parseInt(sliderPos * (trackHeight - contentHeight)) + 'px'    
    $('#dialog .scrollTarget').css("top", newTop)
    
}

function clearScroll() {
    if ($('#dialog .infoText').height()) {
        if ($('#dialog .scrollPanel').height() > $('#dialog .infoText').height()) {
            $('#dialog #sliderTrack').hide()
        }
    }
    if ($('#dialog .scrollable').height()) {      
        if ($('#dialog .scrollPanel').height() >= $('#dialog .scrollable').height()) {
            $('#dialog #sliderTrack').hide()
        }
    }   
}

function checkScroll() {

    if($('#dialog .scrollPanel').length) {
        $("#dialog .handle").draggable({ axis: 'y', containment: 'parent', drag: function(event, ui) { setScroll() } });
        return
    }
 
    if ($('#dialog .scrollable').length!=1) {
        return
    }

    $('.scrollable').addClass('scrollTarget')
    if ($('.scrollable').hasClass('spotlightText')) {
        $('.scrollable').css('width', $('.scrollable').width() - 10 + 'px')
    }
    else {
        $('.scrollable').css('width', $('.scrollable').width() - 30 + 'px')
    }
    if ($('#dialog .insideNorthland')) {
        if ($('#dialog .insideNorthland ul').length) {
            window.setTimeout(function() {
            $('#dialog .scrollPanel').css('height', '280px')
            },200)
        }
        else {
            $('.insideNorthland').prepend("<div class='greenLine'></div>")
            $('.insideTextImage').css('border', 'none')
        }
    }
    $('.scrollable').wrap('<div class="scrollPanel">')
    $('.scrollPanel').css('width', $('.scrollable').width() + 10 + 'px')
    $('.scrollPanel').css('margin-top', '10px')
    $('.scrollPanel').css('margin-bottom', '30px')
    // JS: 20110707 remove old bar
    /*$('.scrollPanel').after('<div id="sliderTrack"><div class="handle"></div></div>')
    $("#dialog .handle").draggable({ axis: 'y', containment: 'parent', drag: function(event, ui) { setScroll() } });*/
    $('.scrollPanel').jScrollPane({ 
        horizontalDragMinWidth: 20,
        horizontalDragMaxWidth: 20,
        verticalDragMinHeight: 40,
		verticalDragMaxHeight: 40
    });
}

function addShadows(target) {
    //add drop-shadow in images
    var myWidth
    var myHeight
    $(target+" img").each(function() {
        myWidth = $(this).width()
        myHeight = $(this).height()
        $(this).wrap("<div style='position:relative;z-index:1'></div>")
        $(this).css('z-index', '20')
        $(this).before("<div class='shadowTopRight' style='left:" + myWidth + "px'></div>")
        $(this).before("<div class='shadowRight' style='width:" + myWidth + "px;height:" + (myHeight - 13) + "px'></div>")
        $(this).before("<div class='shadowBottomRight' style='top:" + myHeight + "px;left:" + myWidth + "px'></div>")
        $(this).before("<div class='shadowBottom' style='width:" + (myWidth - 12) + "px;top:" + (myHeight) + "px'></div>")
        $(this).before("<div class='shadowBottomLeft' style='top:" + (myHeight) + "px'></div>")
    })
}

function fixPath() {
    $('img').each(function() {
        $(this).attr('src', $(this).attr('src').replace("/Assets", "Assets"))
    })
}

function showCareer(id) {
	var id = id.replace('p', '')
	var element = '#uniqueCareer' + id
	if ($(element).length) {
		var desc = $('#desc' + id).html();
		var name = $('#name' + id).html();
		var image = $('#image' + id).html();
		var output = '<div class="insideNorthland"><div class="greenLine"></div><div class="imageHolder"></div><div class="cPhoto"><img src="' + image + '" /></div>';
		output = output +'<h3>' + txtCareerPopupTitle +'</h3>'
		output = output +'<div class="scrollPanel" style="width: 380px; margin-top: 10px; margin-bottom: 30px;"><div class="insideTextImage scrollable scrollTarget" style="width: 370px; border: medium none;">'
		output = output + '<strong>' + name + '</strong><br />'
		output = output + desc 
		output = output + '</div></div><div id="sliderTrack" style="display: block;"><div class="handle ui-draggable"></div></div><div class="clear"></div><div class="insideControls"><a class="print left" href="javascript:;//"></a><a class="email" onclick="openDialog(\'#emailFriendResponse\');" href="javascript://"></a></div><a onclick="closeDialog()" class="close right padR25 green size10" href="javascript:closeDialog()">' + txtClose + ' X</a><div class="clear"></div></div>'
		$('#general').html(output)
		openDialog($('#general'))
		$('.cPhoto').css('width', '186px')
		window.setTimeout(function() { $('.cPhoto').css('width', '186px')}, 1000)
	}
}

function openVideoDialog(videoID) {
    WebService.GetVideoCode(videoID, GetVideoCode_Success, GetVideoCode_Fail);
}

function GetVideoCode_Success(result) {
    $('.VideoPlayerInner').html(result);
    openDialog(document.getElementById('VideoPlayer'));
}

function GetVideoCode_Fail() {
    // waah
}
