jqN(function() {
	setComments();
});

function setComments(){
	commentHash = window.location.toString().split('#')[1];
	if (commentHash == "comment"){
		jqN('.tab-content').eq(1).show();
		jqN('.tab-trigger').eq(1).show().addClass('selected');
	}else{
		jqN('.tab-trigger').eq(0).show().addClass('selected');
		jqN('.tab-content').eq(0).show();
	}
	jqN('.tab-trigger').bind('click',toggleComments);
}

function toggleComments(){
	if(!jqN(this).hasClass('selected')){
		jqN('.tab-trigger').removeClass('selected');
		jqN('.tab-content').hide();
		var index = jqN('.tab-trigger').index(this);
		jqN('.tab-content').eq(index).show();
		jqN(this).addClass('selected');
	}
}

function numString(num){
	num = '' + num;
	if (num.length > 3) {
		var x = num.length % 3;
		var output = (x > 0 ? (num.substring(0,x)) : '');
		for (i=0 ; i < Math.floor(num.length / 3); i++) {
			if ((x == 0) && (i == 0))
				output += num.substring(x+ 3 * i, x + 3 * i + 3);
			else
				output+= ',' + num.substring(x + 3 * i, x + 3 * i + 3);
		}
		return (output);
	}
	else return num;
}

function valForm(){
		var msg='';
		if(jqN('#url').val()== '' || jqN('#url').val() == 'URL'){
			msg += 'Please enter the url of the site\n';
		}
		if(jqN('#contentTitle').val()== '' || jqN('#contentTitle').val() == 'Title'){
			msg += 'Please enter the title of post\n';
		}
		if(jqN('#postText').val()== ''){
			msg += 'Please enter the description of post\n';
		}
		if(jqN('#show').val()== '' || jqN('#show').val() == '-- SELECT --'){
			msg += 'Please select the show\n';
		}
		if(jqN('#tags').val()== '' || jqN('#tags').val() == 'Tags'){
			msg += 'Please enter a couple tags for your post\n';
		}
		if(msg != ''){
			alert(msg);
			return false;
		}else{
			return true;
		}
	return false;
}





jqN.fn.clearForm = function(){
	return this.each(function(){
		var type = this.type, tag = this.tagName.toLowerCase();
		if(tag == 'form')
			return jqN(':input',this).clearForm();
		if(type == 'text' || type == 'password' || tag == 'textarea')
			this.value = '';
		else if(type == 'checkbox' || type == 'radio')
			this.checked = false;
		else if(tag == 'select')
			this.selectedIndex = -1;		
	});
}

