// JavaScript Document

$(document).ready(function() {

	// *****
	//
	// Dynamic Header Image
	//
	// *****

/*

	var image_path = '/images/inner_page_images/';
	var image_prefix = 'inner_page';
	var full_path = image_path+image_prefix;

	var random_images = new Array (
		full_path+"1.jpg", 
		full_path+"2.jpg", 
		full_path+"3.jpg", 
		full_path+"4.jpg", 
		full_path+"5.jpg", 
		full_path+"6.jpg", 
		full_path+"7.jpg", 
		full_path+"8.jpg", 
		full_path+"9.jpg", 
		full_path+"10.jpg", 
		full_path+"11.jpg", 
		full_path+"12.jpg", 
		full_path+"13.jpg", 
		full_path+"14.jpg", 
		full_path+"15.jpg", 
		full_path+"16.jpg", 
		full_path+"17.jpg", 
		full_path+"18.jpg", 
		full_path+"19.jpg", 
		full_path+"20.jpg", 
		full_path+"21.jpg", 
		full_path+"22.jpg", 
		full_path+"23.jpg");


	var i = Math.round(random_images.length*Math.random()-1);

	$("td#inner_image").attr("background",random_images[i]);

	// alert(i);
	// alert(random_images[i]);
	// alert($("td.bg_Nor").attr('background'));

*/


	// *****
	//
	// External Links to Frameset
	//
	// *****

	$("*.roundbox") .wrap('<div class="dialog">'+
	'<div class="bd">'+
	'<div class="c">'+
	'<div class="s">'+
	'</div>'+
	'</div>'+
	'</div>'+
	'</div>');

	$('div.dialog').prepend('<div class="hd">'+
	'<div class="c"></div>'+
	'</div>')
	.append('<div class="ft">'+
	'<div class="c"></div>'+
	'</div>');

	// *****
	//
	// External Links to Frameset
	//
	// *****

	document.onclick = function(e)
	{
	  var target = e ? e.target : window.event.srcElement;

	  while (target && !/^(a|body)$/i.test(target.nodeName))
	  {
		target = target.parentNode;
	  }

		if (target && target.href.indexOf('http://') !=-1)
		{

			if (target.href.indexOf('kababayangpilipino.org') == -1 && target.href.indexOf('google.com') == -1)
			{
				var external = window.open('/frameset.php?url='+target.href);
				return false;
			}
		}
	  return;
	}
});

