// JavaScript Document

// Paths
var fullBaseUrl = 'http://www.caldrywall.com';
var workingDir  = '/'; 

/*tinyMCE.init({
	mode : "textareas",
	theme : "advanced",
	theme_advanced_buttons1 : "bold,italic,underline,separator,bullist,undo,redo,link,unlink",
	theme_advanced_buttons2 : "",
	theme_advanced_buttons3 : "",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
	plugins : 'inlinepopups',
	setup : function(ed) {
	ed.onClick.add(function(ed) {							
});*/
	
tinyMCE.init({
	mode : "textareas",
	theme : "advanced",
	plugins : "paste,iespell",
	content_css : "css/tinymce.css",
	paste_create_paragraphs : false,
	paste_create_linebreaks : false,
	paste_use_dialog : true,
	paste_auto_cleanup_on_paste : true,
	paste_convert_middot_lists : false,
	paste_unindented_list_class : "unindentedList",
	paste_convert_headers_to_strong : true,
	theme_advanced_buttons1 : "bold,italic,underline,|,bullist,numlist,link,unlink,|,pastetext,pasteword,selectall,|,cleanup,code,|,styleselect,removeformat,iespell",
	theme_advanced_buttons2 : "",
	theme_advanced_buttons3 : "",
	setup : function(ed) {
	ed.onClick.add(function(ed) {		
});

// Add a custom button
ed.addButton('h3', {
	title : 'Heading 1',
	image : 'img/example.gif',
	onclick : function() {
	ed.selection.setContent('<span class="titleA">Title</span>');
}
});
}
});

function map(loc) {
	if (loc == 'sj') {
		showElement('sj-map');
		setLinkActive('sj-link');
		
		hideElement('sf-map');
		setLinkOff('sf-link');
	} else {
		showElement('sf-map');
		setLinkActive('sf-link');
		
		hideElement('sj-map');	
		setLinkOff('sj-link');
	}
}

function showElement(elemId) {
	var elem = document.getElementById(elemId);	
	elem.style.display = 'block';	
}

function hideElement(elemId) {
	var elem = document.getElementById(elemId);	
	elem.style.display = 'none';	
}

function setLinkActive(elemId) {
	var elem = document.getElementById(elemId);	
	elem.setAttribute("class", "active");
}

function setLinkOff(elemId) {
	var elem = document.getElementById(elemId);	
	elem.setAttribute("class", "off");	
}

function checkPageName(form) {  
	var pageId   = form.item_id.value;
	var pageName = form.page_name.value;

	filter = /^[a-zA-Z0-9_\-]+$/;
	
	if (!filter.test(pageName)) {
	  alert("Page names can only contain alphanumeric characters, underscores and hyphens.\r\nPlease enter another page name.");
	  return false;
	} 
		
	var response = getAjaxResponse(workingDir + "ajax/check_pagename.php?page_id=" + pageId + "&page_name=" + pageName);
	
	if (response > 0) {
		alert("A page with this name already exists.\r\nPlease enter another page name.");
		return false;
	}
}

function scrollDetect(elemId, pageId) {
	if (pageId != 'experience') {
		var elemId = document.getElementById(elemId);
		var elemheight = elemId.clientHeight;
		
		if (elemheight > 280) {
			elemId.style.paddingTop = '19px';
		} 
	}
}



