﻿/* Telerik Rad Editor */
var fullScreen = false;

function OnClientCommandExecuted(editor, commandName, tool)
{        
    if (commandName == "ToggleScreenMode") {
        fullScreen = !fullScreen;
        if (fullScreen) {
            $('.sidebar').css('display', 'none');
        }
        else {
            $('.sidebar').css('display', '');
        }
    }
}

/* Related Information */
function ToggleRelatedInfo(element) {
	$(element).toggleClass('open');
	$(element).parent('.ps-uc-relatedinformation-header').siblings('.ps-uc-relatedinformation-body').slideToggle(100);
}

/* Vignettes */
function ShowVignette(vignetteId) {
    // hide all vignettes
    $('.ps-wp-vignettes-content').css('display', 'none');
    $('.ps-wp-vignettes-thumbnails div').removeClass('ps-wp-vignettes-selectedthumb');
    
    // show selected vignette
    // select thumb
    $('#ps-wp-vignettes-v' + vignetteId).css('display', 'block');
    $('#ps-wp-vignettes-thumb' + vignetteId).addClass('ps-wp-vignettes-selectedthumb');     
}

/* Bio Detail */
function ToggleLongExperience() {  
    if ($('#ps-bio-exp-long').css('display') == 'none')
		$('#ps-bio-exp-toggle').text('read short representative experience');
    else
        $('#ps-bio-exp-toggle').text('read all representative experience');
    
    $('#ps-bio-exp-long').toggle();
}

/* Email Confirmation Popup Dialog */
_spBodyOnLoadFunctionNames.push("EmailInit");
function EmailInit() {
	$('.email').click(function() {
		var email = this.href.substring(7); // trim off the mailto:
		EmailConfirmation(email);
		this.blur();
		return false;
	});
}

function EmailConfirmation(email) {
	$('#ps-commagreement-ok').unbind('click');
	$('#ps-commagreement-ok').click(function() { EmailConfirmationOK('mailto:' + email ); return false; });
	var dialog = $('#ps-commagreement-dialog');
	var dialogmask = $('#ps-commagreement-dialog-mask');

	var topposition = TopPosition() + (PageHeight()/ 3) - (134/ 2);
	var leftposition = LeftPosition() + (PageWidth()/ 2) - (350/ 2);

	dialog.css('top', topposition + 'px');
	dialog.css('left', leftposition + 'px');

	var content = document.getElementById('ps-content');
	dialogmask.css('height', content.offsetHeight + 'px');	
	dialogmask.css('display', 'block');
	dialog.fadeIn("fast");
}

function EmailConfirmationCancel() {
	$('#ps-commagreement-dialog').fadeOut('fast');
	$('#ps-commagreement-dialog-mask').css('display', 'none');
}

function EmailConfirmationOK(url) {
	var checkbox = $('#ps-commagreement-dialog-confirm');
	if (checkbox.attr('checked')) {
		checkbox.removeAttr('checked');
		EmailConfirmationCancel();
		document.location = url;
		return;
	}
	else {
		alert('You must agree to the communication agreement to continue.');
		return;
	}
}

function PageWidth() {
	return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}

function PageHeight() {
	return window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null;
}

function TopPosition() {
	return typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0;
}

function LeftPosition() {
	return typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0;
}