
// General Functions :: JavaScript Document :: Created By Bluewire Media 

//
// Hides Email Addresses From Spam
//
	function hideEmail(user,domain) {
	  locationstring = "mailto:" + user + "@" + domain;
	  window.location = locationstring;
	}
	
//
// Bluewire Mail Login Form Validation
//	
	function validateLoginForm(form) {
		var errorString = "";
		if(form.username.value == ""){
			errorString += "Please enter a username";
		}
		if(form.password.value == ""){
			if(errorString != ""){
				errorString += " and a passowrd.";
			}
			else{
				errorString += "Please enter a passowrd.";
			}
		}
		if(errorString == ""){
			return true;
		}
		else{
			alert(errorString);
			return false;
		}
	}

//
// Rollover Image Javascript :: Provided by Dreamweaver
//
	function MM_swapImgRestore() { //v3.0
	  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
	}
	
	function MM_preloadImages() { //v3.0
	  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
		if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
	}
	
	function MM_findObj(n, d) { //v4.01
	  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
	  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	  if(!x && d.getElementById) x=d.getElementById(n); return x;
	}
	
	function MM_swapImage() { //v3.0
	  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
	   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
	}


//
// Openup new window in middle of screen | Must Pass in Width, Height and URL of new window.
//
	function openWindow(width, height, url) {
		if(width == "n" || height == "n"){
			width = 490;
			height = 460;
		}
		else if(width == 'product-tour' || height == 'product-tour'){
			width = 750;
			height = 750;
		}
		
		var leftPos = 0;
		var topPos = 0;
		//alert("Width: " + width + " | Height: " + height);
		if (screen) {
			leftPos = (screen.width / 2) - (width/2);
			topPos = (screen.height / 2) - (height/2);
		}
		var newWindow = window.open(url, "" , "width="+width+", height="+height+", left="+leftPos+", top="+topPos+", toolbar=No, location=No, scrollbars=Yes, resizable=Yes, fullscreen=No");
		newWindow.focus();
	}
	
//
// Picks a random quote and returns html image tag string
//

	function getRandomQuote(folder) {
	
		var limit = 0;
		
		if (folder == "default"){
			limit = 19;	//20 Images
		}
		else if (folder == "websites"){
			limit = 8; //9 Images
		}
		else if( folder == "hosting"){
			limit = 4;	//5 Images
		}
		else if (folder == "domains"){
			limit = 3; //3 Images
		}
		else if( folder == "email-and-sms-marketing"){
			limit = 0; //1 Images
		}
		else if (folder == "graphic-design"){
			limit = 1; //2 Images
		}
		else if (folder == "search-optimisation"){
			limit = 0; //1 Images
		}
		
		var randomNumber = Math.floor(Math.random()*limit) + 1;
	
		//alert(randomNumber);
		//alert(folder);
	
		var imageurl = "<img src='../images/quotes/"+folder+"/"+randomNumber+".jpg' alt='Bluewire Media Customer Quote' />";
	
		return imageurl;
	}
	
	//
// Picks a random ad and returns html image tag string
//  NB: If the excluded number matches the random number, it tries again for a different random number.
//      If the excluded number matched the second random number then just don't publish a second ad.
// 
// 1 :  Domains - $110
// 2 :  Email and SMS Marketing  - Custom Designed Templates - $396
// 3 :  Email and SMS Marketing - Designer Campaign - $528
// 4 :  Email and SMS Marketing - Free 30 Day Trial
// 5 :  Graphic Design
// 6 :  Hosting - Email Hosting - $16.50
// 7 :  Hosting - Economy Hosting - $39.00
// 8 :  Hosting - Professional Hosting - $59.00
// 9 :  Search Optimisation - Internet Maketing Report
// 10 : Search Optimisation - Website Evaluations
// 11 : Websites
//
//
	function getRandomAd(excluded) {
		//alert("Help");
		
		var limit = 9;
		var imageURL = "";
		
		var randomNumber = Math.floor(Math.random()*limit) + 1;
		
		//If random number equals the excluded paramater then try again
		if(randomNumber === excluded){
			randomNumber = Math.floor(Math.random()*limit) + 1;
		}
	
		if (randomNumber === 1 && randomNumber != excluded){
			imageURL = "<a href='http://www.bluewiremedia.com.au/domains/domains.html'><img src='http://www.bluewiremedia.com.au/images/ads/domains/domains-110.png' alt='Domains from $110 per domain for two years' /></a>";			
		}
		else if (randomNumber === 2 && randomNumber != excluded){		
			//imageURL = "<a href='http://www.bluewiremedia.com.au/email-and-sms-marketing/email-and-sms-marketing.html'><img src='http://www.bluewiremedia.com.au/images/ads/email-and-sms-marketing/custom-designed-templates-396.png' alt='Bluewire Mail - Custom Designed Templates from $396' /></a>";
			imageURL = "";
		}
		else if (randomNumber === 3 && randomNumber != excluded){			
			imageURL = "<a href='http://www.bluewiremedia.com.au/email-and-sms-marketing/email-and-sms-marketing.html'><img src='http://www.bluewiremedia.com.au/images/ads/email-and-sms-marketing/designer-campaign-528.png' alt='Bluewire Mail - Designer Campaign from $528' /></a>";
			}
		else if (randomNumber === 4 && randomNumber != excluded){			
			imageURL = "<a href='http://www.bluewiremedia.com.au/email-and-sms-marketing/bluewire-mail-free-trial.html'><img src='http://www.bluewiremedia.com.au/images/ads/email-and-sms-marketing/free-30-day-trial.png' alt='Bluewire Mail - Free 30 Day Trial' /></a>";
		}
		else if (randomNumber === 5 && randomNumber != excluded){			
			imageURL = "<a href='http://www.bluewiremedia.com.au/graphic-design/graphic-design.html'><img src='http://www.bluewiremedia.com.au/images/ads/graphic-design/graphic-design.png' alt='Bluewire Media - Graphic Design' /></a>";			
		}
		else if (randomNumber === 6 && randomNumber != excluded){			
			imageURL = "<a href='http://www.bluewiremedia.com.au/hosting/email.html'><img src='http://www.bluewiremedia.com.au/images/ads/hosting/email-hosting-16-50.png' alt='Bluewire Media Email Hosting from $16.50 per month' /></a>";			
		}
		else if (randomNumber === 7 && randomNumber != excluded){			
			imageURL = "<a href='http://www.bluewiremedia.com.au/hosting/economy.html'><img src='http://www.bluewiremedia.com.au/images/ads/hosting/economy-hosting-39.png' alt='Bluewire Economy Hosting from $39 per month' /></a>";			
		}
		else if (randomNumber === 8 && randomNumber != excluded){
			imageURL = "<a href='http://www.bluewiremedia.com.au/hosting/professional.html'><img src='http://www.bluewiremedia.com.au/images/ads/hosting/professional-hosting-59.png' alt='Bluewire Media Professional Hosting From $59 per month' /></a>";			
		}
		else if (randomNumber === 9 && randomNumber != excluded){			
			imageURL = "<a href='http://www.bluewiremedia.com.au/websites/websites.html'><img src='http://www.bluewiremedia.com.au/images/ads/websites/websites.png' alt='Bluewire Media - Websites' /></a>";			
		}	
		else{
			
		}
		
		//alert(imageURL);
		
		return imageURL;
	}
	
	
	
	
	
	
	
	

