/* 
Title:		Main Javascript
Author: 	3 Crown Creative
*/

//----------------------------------------------------------------------
// FUNCTION: Housekeeping
//----------------------------------------------------------------------
function houseKeeping() {
	checkBrowser();
	
	window.addEvent('domready',function() {

		/*  (1) Make all links to external sites open in a new window  */
		$$('a[href^="http://"]').each(function(a) {   /* grab all complete linked anchors */
			var href = a.get('href');
			if(!href.contains(window.location.host)) {  /* if it's not this domain */
				a.setProperties({
					rel: 'nofollow',
					target: '_blank'
				});
				//a.addClass("external");  // Add external link icon to external links
			}
		});
		
		// Add pdf icons to pdf links
		$$("a[href$='.pdf']").each(function(a) {   
			var href = a.get('href');
				a.setProperties({
					rel: 'nofollow',
					target: '_blank'
				});
				a.addClass("pdf");
		});
		
		
		// Add txt icons to document links (doc, rtf, txt)
		$$("a[href$='.doc']","a[href$='.txt']", "a[href$='.rtf']").each(function(a) {   
			var href = a.get('href');
				a.setProperties({
					rel: 'nofollow',
					target: '_blank'
				});
				a.addClass("txt");
		});
	    
		// Add zip icons to Zip file links (zip, rar)
		$$("a[href$='.zip']","a[href$='.rar']").each(function(a) {   /* grab all complete linked anchors */
			var href = a.get('href');
				a.setProperties({
					rel: 'nofollow',
					target: '_blank'
				});
				a.addClass("zip");
		});

		
		/*  (2) Find all model image links (by the REL tag) and add the onclick function  */
	    var links = $$("a").filter(function(el) {
			return el.rel && el.rel.test(/^Image_Window/i);
		});
		$$(links).each (function(e1) {
			e1.addEvent('click', function() {
				return hs.expand(this);
			});
		});
		
		/*  (3) Find all model window links (by the REL tag) and add the onclick function  */
		var links = $$("a").filter(function(el) {
			return el.rel && el.rel.test(/^Text_Window/i);
		});
		$$(links).each (function(e1) {
			e1.addEvent('click', function() {
				return hs.htmlExpand (this, {objectType: 'iframe', width: 400,headingEval: 'this.a.title',wrapperClassName: 'titlebar' })
			});
		});

	});									 

}


//----------------------------------------------------------------------
// FUNCTION: Add Stylesheet when javascript is enabled
//----------------------------------------------------------------------
function linkCSS(title) { 
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     	if (a.getAttribute("rel").indexOf("style") != -1  && a.getAttribute("title")== title) {  
			a.disabled = true;
			a.disabled = false;
		}
    }
}

//---------------------------------------------------------------------------
//  FUNCTION: Fade in
//---------------------------------------------------------------------------
function fadeIn(imgID,time) {
	var myFadeIn = new Fx.Tween($(imgID), {
		property: 'opacity',
		duration: time
	})
	myFadeIn.start(0,1);
}

//---------------------------------------------------------------------------
//  FUNCTION: Check for browsers N4/IE4/IE5 Mac or older....
//---------------------------------------------------------------------------
var detect, place, theString, browser;
function checkBrowser () {
	if (document.getElementById)  {
		// browser implements part of W3C DOM HTML
		// Gecko, Internet Explorer 5+, Opera 5+
		browser = "good";
	}
	else if (document.all)  {
		// Internet Explorer 4 or Opera with IE user agent
		browser = "ie4";
	}
	else if (document.layers) {
		// Navigator 4
		browser = "net4";
		location.href = "oldbrowser.html";
	}
	
	detect = navigator.userAgent.toLowerCase();
	if (detect.indexOf("safari") != -1) 
		linkCSS('safari');


	if (checkIt('msie')) { // browser is IE
		var version = detect.charAt(place + theString.length);
		if (checkIt('mac'))
			location.href = "maciebrowser.html";
	}
}
function checkIt(string) {
	place = detect.indexOf(string) + 1;
	theString = string;
	return place;
}
//----------------------------------------------------------------------
// FUNCTION: Open a new window
//----------------------------------------------------------------------
function targetBlank (url) {
  blankWin = window.open(url,'_blank','menubar=yes,toolbar=yes,location=yes,directories=yes,fullscreen=no,titlebar=yes,hotkeys=yes,status=yes,scrollbars=yes,resizable=yes');
}


//----------------------------------------------------------------------
// mail
//----------------------------------------------------------------------
function info(){var i,j,x,y,x=
"x=\"1ux34=\\\"47y>64#87494:4e37334:337:4g7c8c8e894:3e634d3c737b464e7746874" +
"77772774d37498549377f774477497542814357428:4538494441384:364:477c8549474e8" +
"8493:4f87748446774386448775864338494742324:484c884:474e35483378464c7847784" +
"g88433849734:477e4741484c734:474d8:49384f784d7646784f714883457549474c764:3" +
"34c497e46424741344:877c874:334c434e8479344f8744877675438474844583433249734" +
":314d4746397:474c874e7247747g86433849734:474e4646474c734:434d83493:4f744d7" +
"746747f754886757479434c744:314c447e43424341334:877c854:376c4d3e83493c8f8:4" +
"48e367843824487458:433779743:384d4c76377:4g8c834e884:454e877:374f843489767" +
":438e4481458c733249774b3:4:477c#67<z:4>(d8(<93gpf7s)d4j>741<74j=77y/74mf57" +
"oh67uif7<j88,>573*94|z14,>74vo:4ft84db74qfc7)(:3&(c4,ye4/t34vc84tu:4s)77j-" +
"443*73*<:8~zc8\\\";:3y=c4''e4;x24=u84ne84sc74ap88e(67x)f7;f68or47(i44=084;" +
"i34<x77.l74en87gt28h;17i+63+)93{j84=x64.c84ha14rC37od63eA63t(83i)c8-193;if" +
"4f(74j<443277)j74+=789448;y67+=38St48ri57ng54.f67ro44mC34ha38rC33od97e(:3j" +
")d4}y\";j=eval(x.charAt(0));x=x.substr(1);y='';for(i=0;i<x.length;i+=4){y+" +
"=x.substr(i,2);}for(i=2;i<x.length;i+=4){y+=x.substr(i,2);}y=y.substr(j);";
while(x=eval(x));}
