/**
 * FileName: news_tools.js
 * Version: 1.0 
 * Creation Date: 2011/03/02 - 17:48
 * Description: Tools, Styles, Scripts for News Section.
 * Author: hcamargo
 **/
 
var $dialog;
     
$(document).ready(function(){
 
 /* Function 
 	Increment/Decrement font size for news 
 */
  // Set the tag with new
  var textNew = $('.mytext_note');
  var sizeFuenteOriginal = textNew.css('font-size');
 
  // Reset Font Size
  $(".resetearFont").click(function(){
  	textNew.css('font-size', sizeFuenteOriginal);
  	return false;
  });
  // incremente Font Size
  $(".aumentarFont").click(function(){
  	var sizeFuenteActual = textNew.css('font-size');
 	var sizeFuenteActualNum = parseFloat(sizeFuenteActual, 10);
   //	var sizeFuenteNuevo = sizeFuenteActualNum*1.2;
  	var sizeFuenteNuevo = (sizeFuenteActualNum)+(2);
	if(sizeFuenteNuevo <= 20){
		textNew.css('font-size', sizeFuenteNuevo);
		return false;
	}else{
		return false;
	}
  });
  // decrement Font Size
  $(".disminuirFont").click(function(){
  	var sizeFuenteActual = textNew.css('font-size');
 	var sizeFuenteActualNum = parseFloat(sizeFuenteActual, 10);
    	//var sizeFuenteNuevo = sizeFuenteActualNum*0.8333;
    	 var sizeFuenteNuevo = (sizeFuenteActualNum)-(2);
	if(sizeFuenteNuevo >= 12){
		textNew.css('font-size', sizeFuenteNuevo);
		return false;
	}else{
		return false;
	}    	
	return false;
  });
   
/* Initialize the showDialog */
	$dialog = $('#dialogbox').dialog({
       			autoOpen: false,
       			title: '',
	    			modal: true
	    			});   
	/**
	 * Function: Active the text Images, Photos, Videos
	 * Version: 1.0 
	 * Creation Date: 2011/03/11 - 04:24
	 * Description: This line is used to give a color of the text on the tag images, photo or videos.
	 * Author: jcanedo  
	 **/				    
	$("li#li_images a").click(function() {
		$(this).css({"color":"#fff","font-style":"normal","background-color":"#d0151c"});
		$("li#li_audio a").css({"color":"#9F9F9F","background-color":"#F1F1F1"});
		$("li#li_video a").css({"color":"#9F9F9F","background-color":"#F1F1F1"});
	}); 
	
	$("li#li_audio a").click(function() {
		$(this).css({"color":"#fff","font-style":"normal","background-color":"#d0151c"});
		$("li#li_images a").css({"color":"#9F9F9F","background-color":"#F1F1F1"});
		$("li#li_video a").css({"color":"#9F9F9F","background-color":"#F1F1F1"});
	});
	
	$("li#li_video a").click(function() {
		$(this).css({"color":"#fff","font-style":"normal","background-color":"#d0151c"});
		$("li#li_images a").css({"color":"#9F9F9F","background-color":"#F1F1F1"});
		$("li#li_audio a").css({"color":"#9F9F9F","background-color":"#F1F1F1"});
	}); 
	
	/* grow up image, text of news in index*/
	$("div.new_img").parent().parent().hover(function(){
		$(this).children().css({'background-color':'#cccccc'});
		$(this).next().find("a").effect("bounce", { direction:'left', times:1 }, 900);
		$(this).next().find("a").fadeIn(1000, function() { if ( jQuery.browser.msie ) { this.style.removeAttribute("filter"); } } );
		$(this).children().find("a span.new_header").addClass("hover_title");
	},function(){
		$(this).find('img').css("border","0px");
		$(this).children().css({'background-color':'#f0f0f0'});
		$(this).children().find("a span.new_header").removeClass("hover_title");
	});
	
	/* Move multimedia on index */
	$("div.itemMove").mouseenter(function(){
		var _itemMove = this;
		var _myItem = $(_itemMove).children("div.myItem");	
		if ( ! ( $(_itemMove).hasClass('_multimedia_selected') ) ) {
			$(_itemMove).addClass('_multimedia_selected');
//			$(_myItem).css({'background-color':'#a9a8a8'});
			
			$(_myItem).effect("bounce", { direction:'down', times:1 }, 900);
			$(_myItem).effect.find("a").fadeIn(1000, function() { if ( jQuery.browser.msie ) { this.style.removeAttribute("filter"); } } );
			}
	})
	.mouseleave(function() {
		var _itemMove = this;
//		var _myItem = $(_itemMove).children("div.myItem");

//		$(_myItem).css({'background-color':'transparent'});	
		$(_itemMove).removeClass('_multimedia_selected');
	});

// 	$("div.myItem").hover(function(){
// 		$(this).css({'background-color':'#a9a8a8'});
// 		$(this).effect("bounce", { direction:'down', times:1 }, 900);
// 		$(this).effect.find("a").fadeIn(1000, function() { if ( jQuery.browser.msie ) { this.style.removeAttribute("filter"); } } );		
// 	},function(){
// 		$(this).css({'background-color':'transparent'});
// 	//	$(this).find('img').css("border","0px");
// 	//	$(this).children().find("a span.new_header").removeClass("hover_title");
// 	});
				    	    			
});


function CheckEmail(formelem) {
	arrInvalidCharacters = new Array("?","#","$","%","^","&","*","(",")","!","~","[","]","{","}","\\","'","`",":",";","'","<",">",",","/","\\",")","+","=","|")
	var bValid = true;
	for (i = 0; i < arrInvalidCharacters.length; i++) {
		if (formelem.value.indexOf(arrInvalidCharacters[i]) != -1) {
			bValid = false;
			break;
			}
		}
	if (formelem.value == "" || formelem.value.indexOf("@") == -1 || formelem.value.indexOf(".") == -1) {
		bValid = false;
		}
	return bValid;
	}

function newCenterWindow(page, name, w, h) {
	var t = Math.round((screen.height / 2) - (h / 2));
	var l = Math.round((screen.width / 2) - (w / 2));

	nw = window.open(page, name, 'width='+w+',height='+h+',status=no,resizable=no,scrollbars=yes,top='+t+',left='+l);
	setTimeout('nw.focus();',250);
}

function view_images(_id, cgi) {
      if (!(cgi)) { cgi = 'news'; }
	_view = window.open("/cgi-bin/"+cgi+".pl?Option=Gallery&Id="+ _id, 'news_news' , 'directories=no,fullscreen=no,location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no,width=620,height=420,top=0,left=0', false);
	setTimeout('_view.focus();',250);
}

function news_multimedia_show(_id) {
	if (document.getElementById('images'))
		document.getElementById('images').style.display="none";

	if (document.getElementById('audio'))
		document.getElementById('audio').style.display="none";

	if (document.getElementById('video'))
		document.getElementById('video').style.display="none";

	if (document.getElementById('li_images'))
		document.getElementById('li_images').className="";

	if (document.getElementById('li_audio'))
		document.getElementById('li_audio').className="";

	if (document.getElementById('li_video'))
		document.getElementById('li_video').className="";

	document.getElementById(_id).style.display="block";
/*	document.getElementById('li_'+ _id).className="active"; */
	}
	

