var searching;
var previous_value;
var submitting;


function unsearching(element){
       var searching = "FALSE";
       clear_it(element);
}

function redirect_me(){
	if (searching == "FALSE"){
		window.location = 'http://www.twu.org/';
		}
	else{return;}
	}

function is_submitting(){
        submitting = 1;
}

function clear_it(element){
   var searching = "TRUE";
   if (element.value){
           if(submitting){return;}
           else{
	           previous_value = element.value;
	    	   element.value = "";
	           return;
                  }
               submitting = 0;
           }
   if(element.value == ""){
           element.value = previous_value;
   }
}



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: "Chrome",
			identity: "Chrome"
		},
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari",
			versionSearch: "Version"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			   string: navigator.userAgent,
			   subString: "iPhone",
			   identity: "iPhone/iPod"
	    },
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};




function IEVersion(){
	var _n=navigator,_w=window,_d=document;
	var version="NA";
	var na=_n.userAgent;
	var ieDocMode="NA";
	var ie8BrowserMode="NA";
	// Look for msie and make sure its not opera in disguise
	if(/msie/i.test(na) && (!_w.opera)){
		// also check for spoofers by checking known IE objects
		if(_w.attachEvent && _w.ActiveXObject){		
			// Get version displayed in UA although if its IE 8 running in 7 or compat mode it will appear as 7
			version = (na.match( /.+ie\s([\d.]+)/i ) || [])[1];
			// Its IE 8 pretending to be IE 7 or in compat mode		
			if(parseInt(version)==7){				
				// documentMode is only supported in IE 8 so we know if its here its really IE 8
				if(_d.documentMode){
					version = 8; //reset? change if you need to
					// IE in Compat mode will mention Trident in the useragent
					if(/trident\/\d/i.test(na)){
						ie8BrowserMode = "Compat Mode";
					// if it doesn't then its running in IE 7 mode
					}else{
						ie8BrowserMode = "IE 7 Mode";
					}
				}
			}else if(parseInt(version)==8){
				// IE 8 will always have documentMode available
				if(_d.documentMode){ ie8BrowserMode = "IE 8 Mode";}
			}
			// If we are in IE 8 (any mode) or previous versions of IE we check for the documentMode or compatMode for pre 8 versions			
			ieDocMode = (_d.documentMode) ? _d.documentMode : (_d.compatMode && _d.compatMode=="CSS1Compat") ? 7 : 5;//default to quirks mode IE5				   			
		}
	}
				 
	return {
		"UserAgent" : na,
		"Version" : version,
		"BrowserMode" : ie8BrowserMode,
		"DocMode": ieDocMode
	}			
}

var your_version = new IEVersion();
BrowserDetect.init();
var browser = BrowserDetect.browser;
if (browser == 'Explorer' && your_version.Version != 8 && your_version.Version != 7){
if(document.getElementById("index")){
	var index = document.getElementById("index");
	index.href = 'http://www.twu.org/index.php/international/index_sheet_ie';
	}
if(document.getElementById("index_index")){
	var index = document.getElementById("index_index");
	index.href = 'http://www.twu.org/index.php/international/index_sheet_ie_index';
	}
if(document.getElementById("members")){
    var members = document.getElementById("members");
    members.href = "http://www.twu.org/index.php/international/members_common_ie";
	}
if(document.getElementById("blog")){
	var blog = document.getElementById("blog");
	blog.href = 'http://www.twu.org/index.php/international/blog_sheet_ie';
	}
if(document.getElementById("calendar")){
    var calendar = document.getElementById("calendar");
    calendar.href = "http://www.twu.org/index.php/international/calendar_ie";
	}
if(document.getElementById("map")){
	var map = document.getElementById("map");
	map.href = 'http://www.twu.org/index.php/international/map_sheet_ie';
	}
if(document.getElementById("union")){
    var union = document.getElementById("union");
    union.href = "http://www.twu.org/index.php/international/our_union_sheet_ie";
	}
if(document.getElementById("publications")){
	var publications = document.getElementById("publications");
	publications.href = 'http://www.twu.org/index.php/international/publications_sheet_ie';
	}
if(document.getElementById("update")){
    var update = document.getElementById("update");
    update.href = "http://www.twu.org/index.php/international/update_sheet_ie";
	}
if(document.getElementById("union_plus")){
    var union_plus = document.getElementById("union_plus");
    union_plus.href = "http://www.twu.org/index.php/international/union_plus_sheet_ie";
	}
if(document.getElementById("quill")){
    var quill = document.getElementById("quill");
    quill.href = "http://www.twu.org/index.php/international/quill_ie";
    }
if(document.getElementById("volunteer")){
     var volunteer = document.getElementById("volunteer");
     volunteer.href = "http://www.twu.org/index.php/international/volunteer_sheet_ie";
}
if(document.getElementById("search")){
     var search = document.getElementById("search");
     search.href = "http://www.twu.org/index.php/international/search_sheet_ie";
}
if(document.getElementById("tv")){
     var tv = document.getElementById("tv");
     tv.href = "http://www.twu.org/index.php/international/tv_sheet_ie";
}
if(document.getElementById("efca_sheet")){
     var efca_sheet = document.getElementById("efca_sheet");
     efca_sheet.href = "http://www.twu.org/index.php/international/efca_sheet_ie";
}
function fade(object){
     object.style.opacity = '.7';
}
function unfade(object){
     object.style.opacity = '1';
}
}
if (browser == 'Explorer' && your_version.Version == 7){
function fade(object){
     object.style.opacity = '.7';
}
function unfade(object){
     object.style.opacity = '1';
}
if(document.getElementById("index_index")){
	var index = document.getElementById("index_index");
	index.href = 'http://72.3.139.132/index.php/international/index_sheet_ie7';
	}
if(document.getElementById("union")){
	var our_union = document.getElementById("union");
	our_union.href = 'http://72.3.139.132/index.php/international/our_union_sheet_ie7';
	}
if(document.getElementById("index")){
	var index = document.getElementById("index");
	index.href = 'http://72.3.139.132/index.php/international/index_sheet_ie7';
	}
if(document.getElementById("blog")){
	var blog = document.getElementById("blog");
	blog.href = 'http://72.3.139.132/index.php/international/blog_sheet_ie8';
	}
if(document.getElementById("members")){
	var members = document.getElementById("members");
	members.href = 'http://72.3.139.132/index.php/international/members_common_ie7';
	}
if(document.getElementById("publications")){
	var publications = document.getElementById("publications");
	publications.href = 'http://72.3.139.132/index.php/international/publications_sheet_ie7';
	}
}
if (browser == 'Explorer' && your_version.Version == 8){
function fade(object){
     object.style.opacity = '.7';
}
function unfade(object){
     object.style.opacity = '1';
}
if(document.getElementById("index_index")){
	var index = document.getElementById("index_index");
        if (your_version.BrowserMode != 'Compat Mode'){
	        index.href = 'http://72.3.139.132/index.php/international/index_sheet_ie8_nocompat';
        }
        else {
                index.href = 'http://72.3.139.132/index.php/international/index_sheet_ie8';
        }
	}
if(document.getElementById("union")){
	var our_union = document.getElementById("union");
	our_union.href = 'http://72.3.139.132/index.php/international/our_union_sheet_ie8';
	}
if(document.getElementById("index")){
	var index = document.getElementById("index");
        if (your_version.BrowserMode != 'Compat Mode'){
	        index.href = 'http://72.3.139.132/index.php/international/index_sheet_ie8_nocompat';
        }
        else {
                index.href = 'http://72.3.139.132/index.php/international/index_sheet_ie8';
        }
	}
if(document.getElementById("blog")){
	var blog = document.getElementById("blog");
	blog.href = 'http://72.3.139.132/index.php/international/blog_sheet_ie8';
	}
if(document.getElementById("members")){
	var members = document.getElementById("members");
	members.href = 'http://72.3.139.132/index.php/international/members_common_ie8';
	}
}



