window.addEventListener?window.addEventListener("load",so_init,false):window.attachEvent("onload",so_init);
var d=document, imgs = new Array(), zInterval = null, current=0, pause=false;

function so_init() {
	if(!d.getElementById || !d.createElement)return;
	css = d.createElement("link");
	css.setAttribute("href","default.css");
	css.setAttribute("rel","stylesheet");
	css.setAttribute("type","text/css");
	d.getElementsByTagName("head")[0].appendChild(css);

	imgs = d.getElementById("imageContainer").getElementsByTagName("img");
	for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0;
	imgs[0].style.display = "block";
	imgs[0].xOpacity = .99;

	setTimeout(so_xfade,6000);
}

function so_xfade() {
	cOpacity = imgs[current].xOpacity;
	nIndex = imgs[current+1]?current+1:0;

	nOpacity = imgs[nIndex].xOpacity;

	cOpacity-=.05;
	nOpacity+=.05;

	imgs[nIndex].style.display = "block";
	imgs[current].xOpacity = cOpacity;
	imgs[nIndex].xOpacity = nOpacity;

	setOpacity(imgs[current]);
	setOpacity(imgs[nIndex]);

	if(cOpacity<=0) {
		imgs[current].style.display = "none";
		current = nIndex;
		setTimeout(so_xfade,6000);
	} else {
		setTimeout(so_xfade,50);
	}

	function setOpacity(obj) {
		if(obj.xOpacity>.99) {
			obj.xOpacity = .99;
			return;
		}
		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	}

}

function validateBlogArticleUser(){
	var root = document.blogForm;
	var name = root.name;
	var short_text = root.short_text;

	if(name.value==''){
		alert("Please enter the entry name");
		name.focus();
		return false;
	}
	if(short_text.value==''){
		alert("Please enter a small description");
		short_text.focus();
		return false;
	}
	return true;
}

function validateBlogUser(){
	var root = document.blogForm;
	var name = root.name;
	var short_text = root.short_text;

	if(short_text.value==''){
		alert("Please enter a small description");
		short_text.focus();
		return false;
	}
	return true;
}

var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp = false;
}
}
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

var xmlhttp1=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
try {
xmlhttp1 = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlhttp1 = new ActiveXObject("Microsoft.XMLHTTP");
} catch (E) {
xmlhttp1 = false;
}
}
@end @*/
if (!xmlhttp1 && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp1 = new XMLHttpRequest();
	} catch (e) {
		xmlhttp1=false;
	}
}
if (!xmlhttp1 && window.createRequest) {
	try {
		xmlhttp1 = window.createRequest();
	} catch (e) {
		xmlhttp1=false;
	}
}
function bnRadar(url){
	xmlhttp1.open("GET",url,true);
	xmlhttp1.onreadystatechange=function() {
		if(xmlhttp1.readyState== 4) {
			if(xmlhttp1.status == 200){
				radarResponse = xmlhttp1.responseText;
				//alert(radarResponse);
				printBn(radarResponse);
			}
		}
	}
	xmlhttp1.send(null);
	setTimeout("bnRadar('/news/getBn.php')",60000);
}

function printBn(responce){
	if(responce!='0'&&responce!=''){
		var array = responce.split("_*_");
		var array1 = array[0];
		var array1 = array1.split("|");
		var lang = array1[0];
		var id = array1[1];
		var mess = array[1];
		id = parseInt(id);
		//		alert(id);
		//		if(!isNaN){
		if(mess!=''){
			lang = parseInt(lang);
			date = new Date();
			date.setTime(date.getTime() + (1000 * 60 * 60 * 24 * 30));
			document.cookie = "bncookie" + "=" + id + ";path=/; expires=" + date.toGMTString();
			//document.getElementById('bntag').innerHTML=mess;
			if(lang=='1'){
				document.getElementById('bntag').innerHTML="<table cellpadding='0' cellspacing='0' border='0' width='100%' align='center'><tr><td width='214'><img src='/images/news/breakingnews.gif'></td><td class='whiteText'><a href='/news/more.php?id="+id+"'>"+mess+"</a></td><td valign='top' width='30' align='center' class='whiteTitleSmall black'><a href='#' onclick=\"document.getElementById('breakingnews').style.visibility='hidden'; return false;\"><img src='/images/close2.jpg' style='margin-top:5px;' border='0'></a>&nbsp;&nbsp;</td></tr></TABLE>";
			}else{
				document.getElementById('bntag').innerHTML="<table cellpadding='0' cellspacing='0' border='0' width='100%' align='center'><tr><td valign='top' align='center' width='30' class='whiteTitleSmall black'><a href='#' onclick=\"document.getElementById('breakingnews').style.visibility='hidden'; return false;\">&nbsp;&nbsp;<img src='/images/close2.jpg' style='margin-top:5px;' border='0'></a></td><td class='whiteText' dir='rtl'><a href='/news/more.php?id="+id+"'>"+mess+"</a></td><td width='214'><img src='/images/news/breakingnewsar.gif'></td></tr></TABLE>";
			}
			document.getElementById('breakingnews').style.visibility='visible';

			//	else{
			//		document.getElementById('breakingnews').style.visibility='hidden';
			//	}
			//		}
		}
	}
}

function radar(url){
	xmlhttp.open("GET",url,true);
	xmlhttp.onreadystatechange=function() {
		if(xmlhttp.readyState== 4) {
			if(xmlhttp.status == 200){
				radarResponse = xmlhttp.responseText;
				printSelect(radarResponse);
			}
		}
	}
	xmlhttp.send(null);
	setTimeout("radar('/common/onair.php')",60000);
}

function printSelect(responce){
	if(responce=='0'){
		document.getElementById('onair').innerHTML='';
	}else{
		document.getElementById('onair').innerHTML='';
		document.getElementById('onair').innerHTML="<TABLE cellpadding='0' cellspacing='0' border='0' width='518'><tr><td colspan='2'><img src='/images/spacer.gif' border='0' alt='' width='1' height='7'/></td></tr><tr><td width='166'><img src='/images/onair.gif'></td><td width='352'><marquee class='progmarquee' SCROLLAMOUNT='5' height='26' direction='right'><img src='/images/spacer.gif' width='1' height='26' align='absmiddle' border='0'>"+responce+"</marquee></td></tr></TABLE>";
	}
}

function validateSearch(){
	if(document.search.keyword.value==''){
		alert('Please insert a keyword before submitting');
		document.search.keyword.focus();
		return false;
	}
	return true;
}

function popImage(imageURL,imageTitle){
	//alert(imageURL);
	defaultWidth  = 100;
	defaultHeight = 100;
	//alert(imageURL);
	var optNN='scrollbars=no,width='+defaultWidth+',height='+defaultHeight+',left=100,top=100';
	var optIE='scrollbars=no,width=150,height=100,left=100,top=100';

	var AutoClose = true;

	if (parseInt(navigator.appVersion.charAt(0))>=4){
		var isNN=(navigator.appName=="Netscape")?1:0;
		var isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}
		var optNN='scrollbars=yes,width='+defaultWidth+',height='+defaultHeight+',left=100,top=100';
		var optIE='scrollbars=yes,width=150,height=100,left=100,top=100';

		//if (isNN){imgWin=window.open('about:blank','',optNN);}
		if (isNN){imgWin=window.open('about:blank','',optNN);}
		if (isIE){imgWin=window.open('about:blank','',optIE);}
		with (imgWin.document){
			writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');
			writeln('<sc'+'ript>');
			writeln('var isNN,isIE;');
			writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){');
			writeln('isNN=(navigator.appName=="Netscape")?1:0;');
			writeln('isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
			writeln('function reSizeToImage(){');
			writeln('if (isIE){');
			writeln('window.resizeTo(100,100);');
			writeln('width=100-(document.body.clientWidth-document.images[0].width);');
			writeln('height=100-(document.body.clientHeight-document.images[0].height);');
			writeln('window.resizeTo(width,height);}');
			writeln('if (isNN){');
			writeln('window.innerWidth=document.images["Image"].width;');
			writeln('window.innerHeight=document.images["Image"].height;}}');
			writeln('function doTitle(){document.title="'+imageTitle+'";}');
			writeln('</sc'+'ript>');
			if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
			else writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">');
			writeln('<img name="Image" src="'+imageURL+'" style="display:block"></body></html>');
			close();
		}
}

function validateEditMember(){
	var root = document.members;
	if(root.first_name.value==''){
		alert('Please enter your first name');
		root.first_name.focus();
		return false;
	}
	if(root.last_name.value==''){
		alert('Please enter your last name');
		root.last_name.focus();
		return false;
	}

	if(root.telephone.value==''){
		alert('Please enter your telephone number');
		root.telephone.focus();
		return false;
	}

	if(root.email.value==''){
		alert('Please enter your email');
		root.email.focus();
		return false;
	}

	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=root.email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}

	if(root.home_address.value==''){
		alert('Please enter home address');
		root.home_address.focus();
		return false;
	}

	return true;
}

function checkVote(){
	var root = document.pollvote;
	var c=0;
	for (var i=0, j=root.elements.length; i<j; i++){
		//alert(root.elements[i].checked);
		if(root.elements[i].checked){
			c++;
		}
	}

	if(c=='0'){
		alert('Please select at least one answer before submitting');
		return false;
	}else{
		return true;
	}
}

function passValidation(){
	var root = document.change_password;
	var oldp = root.old.value;
	var newp = root.newp.value;
	var confnew = root.confnew.value;

	if (oldp == '' || newp == '' || confnew == ''){
		alert('Please fill up all the fields');
		root.old.focus();
		return false;
	}
	if (!isNaN(newp)){
		alert('Please insert a password that contains characters.');
		root.newp.focus();
		return false;
	}

	if (newp != confnew){
		alert('The password and it\'s confirmation do not match');
		root.confnew.focus();
		return false;
	}

	oldp = hex_md5(oldp);
	newp = hex_md5(newp);
	confnew = hex_md5(confnew);

	root.old.value = oldp;
	root.newp.value = newp;
	root.confnew.value = confnew;
	root.enc.value = '1';

	return true;
}

function validateVotePoll(){
	var root=document.poll;
	if(root.name.value==''){
		alert('Please provide your full name');
		root.name.focus();
		return false;
	}
	if(root.email.value==''){
		alert('Please provide your email');
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=root.email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}
	if(root.country.value==''){
		alert('Please select a country from the drop down menu');
		root.country.focus();
		return false;
	}

	return true;
}

function validateSendMessage(){
	var root=document.sendMessage;
	if(root.name.value==''){
		alert('Please provide your full name');
		root.name.focus();
		return false;
	}
	if(root.email.value==''){
		alert('Please provide your email');
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=root.email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}
	if(root.country.value==''){
		alert('Please select a country from the drop down menu');
		root.country.focus();
		return false;
	}

	if(root.message.value==''){
		alert('Please provide a message');
		root.message.focus();
		return false;
	}

	return true;
}

function validateLogin(){
	var root = document.memberslog;

	var username = root.username.value;
	var password = root.password.value;
	if (username == 'Username'){
		alert('Please give your username.');
		root.username.focus();
		return false;
	}
	if (password == '********'){
		alert('Please give your password.');
		root.password.focus();
		return false;
	}
	password = hex_md5(password);
	root.password.value = password;
	root.hashed.value = 'yes';
	return true;
}

function validatemailinglist(){
	var root=document.newsletter;
	if(root.name.value=='Full Name'){
		alert('Please provide your full name');
		root.name.focus();
		return false;
	}
	if(root.email.value=='Email'){
		alert('Please provide your email');
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=root.email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}
	return true;
}

function validateTellAFriend(e){
	var root = document.tell_a_friend;
	var name = root.name.value;
	if (name=='Your Name'){
		alert('Please fill up your name');
		root.name.focus();
		return false;
	}
	var email = root.email.value;
	if (email=='Your Email'){
		alert('Please fill up your email');
		root.email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=email.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}
	var count=0;
	for(var i=0;i<e;i++){
		var f_name= eval('root.f_name'+i+'.value');
		var f_email= eval('root.f_email'+i+'.value');
		if(f_name=='Friends Name'&&f_email=='Friends Email'){
			count++;
		}
		if(f_name=='Friends Name'&&f_email!='Friends Email'){
			alert('Please fill up your friends name');
			eval('root.f_name'+i+'.focus()');
			return false;
		}
		if(f_name!='Friends Name'&&f_email=='Friends Email'){
			alert('Please fill up your friends email');
			eval('root.f_email'+i+'.select()');
			return false;
		}
		var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
		if(f_name!=''){
			flag=f_email.match(pattern);
			if(!flag){
				alert('Please insert a valid email address.');
				eval('root.f_email'+i+'.select()');
				return false;
			}
		}
	}
	if(count==e){
		alert('Please provide a friend\'s email');
		root.f_name0.focus();
		return false;
	}

	return true;
}

function changeVisibility(form){

	var vis = document.getElementById(form).style.visibility;
	if(vis=='hidden'){
		document.getElementById(form).style.visibility='visible';
	}else{
		document.getElementById(form).style.visibility='hidden';
	}

	if(form=='newsletter'){
		document.getElementById('tellafriend').style.visibility='hidden';
	}else{
		document.getElementById('newsletter').style.visibility='hidden';
	}
}

function checkContactform(){
	var root=document.contact;

	var name=root.name;
	var email=root.email;
	var subject=root.subject;
	var message=root.message;
	var vcode=root.vcode;

	if(name.value==""){
		alert('Please enter your full name.');
		name.focus();
		return false;
	}
	if(email.value==""){
		alert('Please enter an email address.');
		email.focus();
		return false;
	}
	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;
	flag=email.value.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		email.focus();
		return false;
	}
	if(subject.value==""){
		alert('Please enter the subject.');
		subject.focus();
		return false;
	}
	if(message.value==""){
		alert('Please enter your message.');
		message.focus();
		return false;
	}
	if(vcode.value==""){
		alert('Please supply the visual code before submitting.');
		vcode.focus();
		return false;
	}
	return true;
}

function clearContactForm(){
	var root=document.contact;

	var name=root.name;
	var email=root.email;
	var subject=root.subject;
	var message=root.message;
	var vcode=root.vcode;

	if(confirm('Are you sure you want to clear this form?')){
		name.value="";
		email.value="";
		subject.value="";
		message.value="";
		vcode.value="";

		return false;
	}

	return false;
}

function clearMembersForm(){
	var root=document.members;

	var username=root.username;
	var pass=root.pass;
	var conpass=root.conpass;
	var fname=root.fname;
	var lname=root.lname;
	var tel=root.tel;
	var fax=root.fax;
	var email=root.email;
	var add=root.add;

	if(confirm('Are you sure you want to clear this form?')){
		username.value="";
		pass.value="";
		conpass.value="";
		fname.value="";
		lname.value="";
		tel.value="";
		fax.value="";
		email.value="";
		add.value="";

		return false;
	}

	return false;
}

function validateAddMember(){

	var root = document.members;

	var firstName = root.fname.value;
	var lastName = root.lname.value;
	var address = root.add.value;
	var tel = root.tel.value;
	var email = root.email.value;
	var username = root.username.value;
	var password = root.pass.value;
	var confirm_password = root.conpass.value;
	if (username == ''){
		alert('Please give your username');
		root.username.focus();
		return false;
	}

	if (password == ''){
		alert('Please specify your password');
		root.pass.focus();
		return false;
	}

	if (password != confirm_password){
		alert('Your password and its confirmation do not match');
		root.conpass.focus();
		return false;
	}
	if (firstName == ''){
		alert('Please specify your first name');
		root.fname.focus();
		return false;
	}

	if (lastName == ''){
		alert('Please specify your last name');
		root.lname.focus();
		return false;
	}

	if (tel == ''){
		alert('Please give your home phone');
		root.tel.focus();
		return false;
	}

	if (email == ''){
		alert('Please give your email address');
		root.email.focus();
		return false;
	}

	var pattern = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;

	flag=email.match(pattern);
	if(!flag){
		alert('Please insert a valid email address.');
		root.email.select();
		return false;
	}

	if (address == ''){
		alert('Please specify your address');
		root.add.focus();
		return false;
	}

	password = hex_md5(password);
	confirm_password = hex_md5(confirm_password);

	root.hashed.value = '1';
	root.pass.value = password;
	root.conpass.value = confirm_password;
	return true;
}

function validateForgotPass(){
	var root=document.forgot_pass;
	if(root.username.value==''){
		alert('Please insert your username');
		root.username.focus();
		return false;
	}

	if(root.email.value==''){
		alert('Please insert your email address');
		root.email.focus();
		return false;
	}

	return true;
}