/////////////// WICKEDWEB INLINE FLASH REPLACEMENT (WWIFR) COPYRIGHT WICKEDWEB ///////////////

function setDimensions(height, width, id){
	$('#' + id).height(height).attr('height', height).width(width).attr('width', width);
	$('#' + id).mouseout(function(){
		$('#' + id).flash(function(){
			this.SetVariable('resetvar', Math.floor(Math.random()*100));
		});
    });
}

function RGBtoHex(R,G,B){
	return '#'+toHex(R)+toHex(G)+toHex(B);
}
function toHex(N) {
	if (N==null) return "00";
	N=parseInt(N); if (N==0 || isNaN(N)) return "00";
	N=Math.max(0,N); N=Math.min(N,255); N=Math.round(N);
	return "0123456789ABCDEF".charAt((N-N%16)/16)
	+ "0123456789ABCDEF".charAt(N%16);
}
function replaceText(theClass, not, font, path, fontWeight, linkColor, linkHoverColor, linkDecoration, linkHoverDecoration, lineHeight, zoom, offsetX, offsetY){
	$(theClass).not(not).each(function(e){
		if(theClass.indexOf(' ') > -1){
			theClass = theClass.split(' ').join('');
		}
		if(theClass.indexOf('#') > -1){
			theClass = theClass.split('#').join('');
		}
		if(theClass.indexOf('.') > -1){
			theClass = theClass.split('.').join('');
		}
		var myID = 'id' + theClass + e;
		var myText = $(this).html();
		var myWidth = $(this).parent().width();
		var myHeight = $(this).height();
		var myLink = $(this).attr('href');
		var myAlign = $(this).css('text-align');
		var mySize = $(this).css('font-size');
		var myString = $(this).css('color');
		var myColor = "";
		if(fontWeight == '' || fontWeight == null){
			var myWeight = $(this).css('font-weight');
		}
		else{
			var myWeight = fontWeight;
		}
		var myLinkColor = linkColor;
		var myLinkHoverColor = linkHoverColor;
		var myLinkDecoration = linkDecoration;
		var myLinkHoverDecoration = linkHoverDecoration;
		var myLineHeight = lineHeight;
		if(myString.indexOf('#') <= -1){
			for(i=0; i<myString.length; i++){
				if(parseInt(myString.charAt(i))%1 == 0 || myString.charAt(i) == ',') {
					myColor += myString.charAt(i);
				}
			}
			myNewColor = myColor.split(",");
			myColor = RGBtoHex(myNewColor[0],myNewColor[1],myNewColor[2]);
		}
		else{
			myColor = myString;
		}
		if(document.location.href.indexOf('file:///') > -1){
			var live = false;
		}
		else{
			var live = true;
		}
		myText = myText.split("+").join("&#43;");
		myFlash = $.flash.create({swf:path+font+'.swf', width:myWidth, height:myHeight, hasVersion:8, expressInstaller:path+'expressInstall.swf', flashvars:{myID:myID, myText:myText, myLink:myLink, myWidth:myWidth, myHeight:myHeight, mySize:mySize, myColor:myColor, myLinkColor:myLinkColor, myLinkHoverColor:myLinkHoverColor, myLinkDecoration:myLinkDecoration, myLinkHoverDecoration:myLinkHoverDecoration, myWeight:myWeight, myLineHeight:myLineHeight, myAlign:myAlign, zoom:zoom, offsetX:offsetX, offsetY:offsetY, live:live, lcId:myID}, params:{wmode:'transparent'}});
		$(this).html(myFlash);
		$(this).find('object').attr('id', myID).attr('name', myID);
		$(this).append('<span style="display:none;">' + myText + '</span>');
		$(this).css('visibility', 'visible');
	});
}

function selectors(){
	// selector*, not, font*, path*, fontWeight, linkColor, linkHoverColor, linkDecoration, linkHoverDecoration, lineHeight(0 = normal)*, zoom(1 = 100%)* //
	replaceText('#navigation .navoff', '', 'helvetica', '/static/flash/', 'bold', '#FFFFFF', '#000000', '', '', '0', '1', '-2', '-2');
	replaceText('#navigation .navon', '', 'helvetica', '/static/flash/', 'bold', '#000000', '#000000', '', '', '0', '1', '-2', '-2');
	replaceText('#navigation .navparent', '', 'helvetica', '/static/flash/', 'bold', '#000000', '#000000', '', '', '0', '1', '-2', '-2');
	replaceText('.title', '', 'helvetica', '/static/flash/', 'bold', '', '', '', '', '0', '1', '-2', '-2');
	replaceText('.titleSlider', '', 'helvetica', '/static/flash/', 'bold', '', '', '', '', '0', '1', '-2', '-2');
	replaceText('.text', '', 'helvetica', '/static/flash/', 'bold', '', '', '', '', '0', '1', '-2', '-2');
	replaceText('h2', '', 'helvetica', '/static/flash/', 'bold', '', '', '', '', '0', '1', '-2', '-2');
	replaceText('h3', '', 'helvetica', '/static/flash/', 'bold', '', '', '', '', '0', '1', '-2', '-2');
	replaceText('.weatherFactor', '', 'helvetica', '/static/flash/', 'bold', '', '', '', '', '0', '1', '-2', '-2');
}

$(document).ready(function(){
	selectors();
});