/**
 * Common JS functions
 * @author Lisandro Grassini
 * @date June/2007
 */


/**
 * Delete an existing News
 * @param {Integer} vID
 */
function delNews(vID) {
	
	if(confirm("Confirma eliminar la noticia " + vID + "?")) {
		
		location.href = "index.php?mod=news.list&action=del&idNews=" + vID;
		
	}	
}


/**
 * Delete an existing contact
 * @param {Integer} vID
 */
function delContacto(vID) {
	
	if(confirm("Confirma eliminar el contacto " + vID + "?")) {
		
		location.href = "index.php?mod=contact.list&action=del&id_contacto=" + vID;
		
	}	
}

/**
 * Delete an existing group
 * @param {Integer} vID
 */
function delGroup(vID) {
	
	if(confirm("Confirma eliminar el grupo " + vID + "?")) {
		
		location.href = "index.php?mod=group.list&action=del&idGroup=" + vID;
		
	}	
}

/**
 * Delete an existing Newsleter
 * @param {Integer} vID
 */
function delNewsletter(vID) {
	
	if(confirm("Confirma eliminar newsletter " + vID + "?")) {
		
		location.href = "index.php?mod=newsletter.list&action=del&id_newsletter=" + vID;
		
	}	
}

/**
 * Delete an existing Category
 * @param {Integer} vID
 */
function delCategory(vID) {
	
	if(confirm("Confirma eliminar la categoria " + vID + "?")) {
		
		location.href = "index.php?mod=category.list&action=del&idCategory=" + vID;
		
	}	
}

/**
 * Delete an existing link
 * @param {Integer} vID
 */
function delLink(vID) {
	
	if(confirm("Confirma eliminar el link " + vID + "?")) {
		
		location.href = "index.php?mod=link.list&action=del&idLink=" + vID;
		
	}	
}

/**
 * Delete an existing announce
 * @param {Integer} vID
 */
function delAnuncio(vID) {
	
	if(confirm("Confirma eliminar el anuncio " + vID + "?")) {
		
		location.href = "index.php?mod=announce.list&action=del&id_anuncio=" + vID;
		
	}	
}

/**
 * Delete an existing Blog
 * @param {Integer} vID
 */
function delBlog(vID) {
	
	if(confirm("Confirma eliminar el blog " + vID + "?")) {
		
		location.href = "index.php?mod=blog.list&action=del&id_blog=" + vID;
		
	}	
}

/**
 * Delete an existing recommendation
 * @param {Integer} vID
 */
function delRecommend(vID) {
	
	if(confirm("Confirma eliminar la recomendación " + vID + "?")) {
		
		location.href = "index.php?mod=recommend.list&action=del&idRecommend=" + vID;
		
	}	
}

/**
 * Delete an existing publicity
 * @param {Integer} vID
 */
function delPublicity(vID) {

	if(confirm("Confirma eliminar la publicidad " + vID + "?")) {
		
		location.href = "index.php?mod=publicity.list&action=del&id_publicity=" + vID;
		
	}
}

/**
 * Clear field content
 * @param {String} vField
 */
function fnClear(vField) {
	document.getElementById(vField).value="";
}

/**
 * 
 * @param string vURL
 * @return void
 */
function jump(vURL) {
	location.href = vURL;
}

/**
 * 
 * @return void
 */
function checkAll() {
	
	if ($('#chkAll').attr('checked') == true) {
		$('.chk').attr('checked', true);
	} else {
		$('.chk').attr('checked', false);
	}
}

/**
 * 
 */
function validateContactEmail() {
	
	var vEmail = $('#email').val();
	
	 $.get("modules/ajax_core.php",
	   { action: "validate_dup_contact", email: vEmail },
	   function(data){
	     if (data == 'OK') {
	    	 $("form")[0].submit(); 
	     } else {
	    	 alert(data);
	     }
	   }
	 );
}