// JavaScript Document


//Slider Hide Effect =========================================================

jQuery(document).ready(function() {
  jQuery(".fyfSub").hide();
  //toggle the componenet with class msg_body
  jQuery(".fyfLink").click(function()
  {
    jQuery(this).next(".fyfSub").slideToggle(500);
  });
});

//Searform =========================================================

var DEF_VAL   = "Search"; // Default Value
var isSafari = (navigator.userAgent.indexOf("AppleWebKit") !=-1);
// Detecting not only Safari but WebKit-based browsers

run();
function run()
{
    var oldOnload = window.onload; // window.onload will be overwritten, so save the old value
    if (typeof(window.onload) != "function") {
        window.onload = init;
    } else {
        window.onload = function() {
            oldOnload();
            init();
        }
    }
}

function init() {
    if (!document.getElementById) return;
    var theSearchField = document.getElementById('search');
    if (isSafari) {
        // Changing type to 'search' from 'text'
        // and inserting 'autosave,' 'results,' 'placeholder' values for Safari and WebKit-based browsers
        theSearchField.setAttribute('type', 'search');
        theSearchField.setAttribute('autosave', 'saved.data');
        theSearchField.setAttribute('results', '5');
        theSearchField.setAttribute('placeholder', DEF_VAL);
    } else {
        // Doing the 'Live Search'-displaying-&-hiding-stuff for non-WebKit-based browsers
        theSearchField.onfocus    = focusSearch;
        theSearchField.onblur     = blurSearch;
        if (theSearchField.value=='') theSearchField.value = DEF_VAL;
    }
}

function focusSearch() {
    if (this.value==DEF_VAL) {
        this.value = '';
    }
}

function blurSearch() {
    if (this.value=='') {
        this.value = DEF_VAL;
    }
}

//Bad Browser =========================================================

function badBrowser(){
	if($.browser.msie && parseInt($.browser.version) <= 7){ return true;}
	
	return false;
}

function getBadBrowser(c_name)
{
	if (document.cookie.length>0)
	{
	c_start=document.cookie.indexOf(c_name + "=");
	if (c_start!=-1)
		{ 
		c_start=c_start + c_name.length+1; 
		c_end=document.cookie.indexOf(";",c_start);
		if (c_end==-1) c_end=document.cookie.length;
		return unescape(document.cookie.substring(c_start,c_end));
		} 
	}
	return "";
}	

function setBadBrowser(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

if(badBrowser() && getBadBrowser('browserWarning') != 'seen' ){
	$(function(){
		$("<div id='browserWarning'>You are using an unsafe and outdated browser. You should consider upgrading to <a href='http://www.google.com/chrome'>Google Chrome</a> or <a href='http://getfirefox.com'>FireFox</a>. These updated and secure browsers are free! [<a href='#' id='warningClose'>Close</a>] </div> ")
			.css({
				backgroundColor: '#fcfdde',
				'width': '100%',
				'border-top': 'solid 1px #000',
				'border-bottom': 'solid 1px #000',
				'text-align': 'center',
				padding:'5px 0px 5px 0px',
				'margin-top':'-26px'
			})
			.prependTo("body");
		
		$('#warningClose').click(function(){
			setBadBrowser('browserWarning','seen');
			$('#browserWarning').slideUp('slow');
			return false;
		});
	});	
}

