<!-- 

/***************************************************************************
 * IranianRadio
 * 
 * Author: Jason Us
 * 
 * Created: July 19, 2006
 * 
 * Filename: functions.js
 * 
 * Description: Set of random functions some of which are used and some that not
 * in this site. 
 * 
 * TODO: 
 **************************************************************************/


/** 
 * open a popup dialog
 * 
 */
function MM_popupMsg(msg) 
{ //v1.0
  alert(msg);
}

/** 
 * open a popup window 
 * 
 */
function MM_openBrWindow(theURL,winName,features) { 
  window.open(theURL,winName,features);
}


/**
 * Get the browser agent of the current browser viewing the site.
 * TODO: enhance to include more detailed info - version #
 */
function getAgent()
{
	var browserName=navigator.appName; 
	if (browserName=="Netscape")
	{ 
		return "Netscape";
	}
	else if (browserName=="Microsoft Internet Explorer")
	{
		return "Microsoft Internet Explorer";
	}
	else if (browserName=="Opera")
	{
		return "Opera";
	}
	else
	{
		return "Unknown";
	}
}

/**
 * Writes a string to the browser status bar.
 * @param {	string } str The string we wish to display in the status bar. 
 */
function writeToStatusBar(str)
{	
	window.status = str;
}


/**
 * Scroll the window to the bottom of the screen 
 * 
 */
function scrollit() 
{
	for (i=1; i<=500; i++)
	{
		parent.scroll(1,i)
	}
}


/**
 * If user enters a correct email in the subscribe box and clicks "subscribe", add them to
 * the mailing list for IR. 
 * 
 * Alert the user if they have not filled in the their email address in the subscribe box. 
 *
 * TODO: This is just a stub now, tie it into a real functioning script. 
 * Also - we can scroll down to the subscribe form, but not while the status bar ticker is ticking... 
 */
function subscribeUser()
{	
	var subscriber = document.getElementById("subscriber");	

	if ( subscriber.value.indexOf("@") == -1  )
	{
		alert("Please enter a valid email address.");
		//scrollit();
		subscriber.focus();	
		return false;
	}
	else
	{
		return true;
	// Dont need this anymore now that we have a real form to take care of it
	//	alert( subscriber.value + ' is now subscribed to the IranianRadio.com mailing list. ');
	}
}




/**
 * If user enters a correct email in the subscribe box and clicks "unsubscribe", remove them from 
 * the mailing list for IR. 
 * 
 * Alert the user if they have not filled in the their email address in the subscribe box. 
 *
 * TODO: This is just a stub now, tie it into a real functioning script. 
 * Also - we can scroll down to the subscribe form, but not while the status bar ticker is ticking... 
 */
function unsubscribeUser()
{	
	var subscriber = document.getElementById("subscriber");
	
	if ( subscriber.value.indexOf("@") == -1 )
	{
		alert("Please enter a valid email address.");
	//	scrollit();
		subscriber.focus();
	}
	else
	{
		alert( subscriber.value + ' is now unsubscribed from the IranianRadio.com mailing list. ');
	}
}


function getBanner(depth)
{
	// need to make sure the image reference is from
	// the correct level in the directory structure
	var depthString = "";
	
	if ( depth == 1 ) 
	{
		depthString = ".";
	}
		 
	var currentdate = 0;
	var core = 0;
	
	function initArray() {
	
	this.length = initArray.arguments.length;
	  for (var i = 0; i < this.length; i++) {
	  this[i] = initArray.arguments[i];
	  }
	}
	
	
	link = new initArray(
	"http://www.eworldrecord.com/mydestiny.html",
	"http://www.eworldrecord.com/mydestiny.html",
	"http://www.eworldrecord.com/baeedannak.html",
	"http://www.eworldrecord.com/barandeh.html"
	);
	
	image = new initArray(
	depthString + "./images/banners/banner.jpg"
	);
	
// TODO - add these 
/* depthString + "./images/banners/shohreh_1.jpg",
	depthString + "./images/banners/shohreh_3.jpg",
	depthString + "./images/banners/UmmKulthum.jpg",
	depthString + "./images/banners/SaeedMohammadi.jpg" */

	text = new initArray(
	"Shohreh",
	"Shohreh",
	"Umm Kulthum",
	"Saeed Mohammadi"
	);
	
	var currentdate = new Date();
	var core = currentdate.getSeconds() % image.length;
	var ranlink  = link[core];
	var ranimage = image[core];
	var rantext  = text[core];
	
		document.write('<a href=\"' +ranlink+ '\" target=\"_blank\"><img src=\"'+ranimage+'\" border="0" alt=\"'+rantext+'\" width="766" height="95"></a>');
}


//-->

