

//input default function
function inputDefault(input, value) {
	
	if (typeof(input) == 'string') {
		input = jQuery('#' + input);
	}
	
	var currentValue = input.val();
	
	if (currentValue == '') {
		input.val(value);
		input.css('color', '#888888');
	} else if (currentValue == value) {
		input.val('');
		input.css('color', '#000000');
	}
	
	return null;
}

//layout function...
function layoutManager(leftWidth, rightWidth) {
	try {
		var width = $(window).width(),
			height = $(window).height(),
			lft = $('#lft'),
			ctr = $('#ctr'),
			rgt = $('#rgt');
		
		var centerWidth = width - leftWidth - rightWidth;
		
		if (parseInt(ctr.css('height')) > height) {
			centerWidth -= 15;
		};
		
		//set the center left margin
		ctr.css('marginLeft', leftWidth + 'px');
		
		//set the left height
		lft.css('height', (height - 67) + 'px');
		
		//set the widths
		lft.css('width', leftWidth + 'px');
		ctr.css('width', centerWidth + 'px');
		rgt.css('width', rightWidth + 'px');
		
		//set the display to inline-block
		lft.css('display', 'inline-block');
		ctr.css('display', 'inline-block');
		rgt.css('display', 'inline-block');
		
	} catch (e) {
		alert(e);
	}
	
	return null;
}

function disableSelection(target) {
	if (typeof target.onselectstart != 'undefined') {
		//IE route
		target.onselectstart = function(){return false;};
	} else if (typeof target.style.MozUserSelect != 'undefined') {
		//Firefox route
		target.style.MozUserSelect = 'none';
	} else {
		//All other route (ie: Opera)
		target.onmousedown = function(){return false;};
	}
}

function fileInputChange(obj) {
	var disp = jQuery('#' + obj.id + 'Display');
	disp.attr('disabled', false);
	disp.val(obj.value.substring(obj.value.lastIndexOf('\\') + 1));
	disp.attr('disabled', true);
	
	return null;
}
/*
function stdMultiSelectAll(obj) {
	//obj is the stdMultiSelectPadding
	var children = obj.getElementsByTagName('input');
	
	//children[0] should be the all option
	var checked = children[0].checked;
	
	for (var i in children) {
		if (children[i].id != undefined) {
			children[i].checked = checked;
		}
	}
	
	return null;
}
function stdMultiSelectOne(obj) {
	//obj is the checkbox
	var checked = obj.checked;
	
	if (checked == false) {
		//uncheck the 'All' option
		$(obj.id.substring(0, obj.id.lastIndexOf('_')) + '_0').checked = false;
	}
}
*/

function checkLength(inputBox, countBox, submitButton) {
	var inp = $('#' + inputBox);
	var len = $('#' + countBox);
	
	var btn = $('#' + submitButton);
	
	len.attr('disabled', false);
	len.val(160 - inp.val().length);
	len.attr('disabled', true);
	
	if (len.val() < 0) {
		len.css('color', '#ff0000');
		
		btn.attr('disabled', true);
		btn.addClass('stdButtonDisabled');
		btn.removeClass('stdButton');
		
	} else {
		len.css('color', '#000000');
		
		btn.attr('disabled', false);
		btn.addClass('stdButton');
		btn.removeClass('stdButtonDisabled');
	}
	
	return null;
}

function changeFocus(box) {
	var inp = $('#' + box);
	
	if (box == 'areacode' && inp.val().length == 3) {
		$('#prefix').focus();
	} else if (box == 'prefix' && inp.val().length == 3) {
		$('#suffix').focus();
	} else if (box == 'suffix' && inp.val().length == 4) {
		$('#terms').focus();
	}
	
	return null;
}
