 //*****************
//show hide 
//*****************
var state = 'none'

function showhide(layer_ref,frame_ref) {
 
	var fza = document.getElementById(frame_ref); 
	if (fza) {			
		if (fza.style.display == 'none'|| fza.style.display=='')
			fza.style.display = 'block';
		else
			fza.style.display = 'none';
	}
	
	var hza = document.getElementById(layer_ref); 
	if (hza) {			
		//alert(hza.style.display);
		if (hza.style.display == 'none' || hza.style.display=='')
			hza.style.display = 'block';
		else
			hza.style.display = 'none';
	} 
}
 
function show(div_ref){
	
	var div = document.getElementById(div_ref); 
	if (div) {		
		div.style.display = 'block';
	}
} 

function hide(div_ref){

	var div = document.getElementById(div_ref); 
	if (div) {
		div.style.display= "none";		
		
	}
} 

function collapse(div_ref){
	var div = document.getElementById(div_ref); 
	if (div) { 	
		//Hide the current image
		div.animate({opacity: 0.0}, 1000)
		.removeClass('show');
	}
}


function swapimgsrc(id,img1,img2){				 
	if (document.getElementById(id)) {
		
		var srcpath = document.getElementById(id).src;
		srcpath = srcpath.substring(srcpath.indexOf(img1));
		//alert(srcpath);
		
		if (srcpath == img1)
			document.getElementById(id).src=img2;
		else 
			document.getElementById(id).src=img1;
	}				
}

function swapclassname(id,classname1,classname2){
	if (document.getElementById(id)) {
		var classname=document.getElementById(id).className;		 
		if (classname == classname1)
			document.getElementById(id).className=classname2;
		else 
			document.getElementById(id).className=classname1;
	}				
}
function swaptooltip(id,tooltip1,tooltip2){
	
	if (document.getElementById(id)) {
		var tooltip=document.getElementById(id).title;		 
		if (tooltip == tooltip1)
			document.getElementById(id).title=tooltip2;
		else 
			document.getElementById(id).title=tooltip1;
	}				
}
function swapinnertext(id,txt1,txt2){
	
	if (document.getElementById(id)) {
		var txt=document.getElementById(id).innerHTML;		 
		if (txt == txt1)
			document.getElementById(id).innerHTML=txt2;
		else 
			document.getElementById(id).innerHTML=txt1;
	}				
}

//****************************
//drop down menu
//**************************** 
var timeout	= 100;
var closetimer	= 0;
var dropitem	= 0;
var dropframe;
var submenuframe;
var submenu;

// open hidden layer
function opendropdown(id,dropframeid)
{	 
	// cancel close timer
	dropdowncanceltimer();

	// close old layer
	if (dropitem) {
		if (dropitem.className.lastIndexOf('stayopen')<=0) dropitem.style.display = 'none';
	}	
	if (dropframe) {
		if (dropframe.className.lastIndexOf('stayopen')<=0)	dropframe.style.display = 'none';
	}
	// get new layer and show it
	dropitem = document.getElementById(id);	
	dropitem.style.display = 'block';
	
	dropframe= document.getElementById(dropframeid);
	  
	if (dropframe) {
		dropframe.style.display = 'block'; 
		dropframe.style.position = 'absolute';
	}	
}

// cancel close timer
function dropdowncanceltimer()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close showed layer
function closedropdown()
{
	if (dropitem) { 
		if (dropitem.className.lastIndexOf('stayopen') < 0) {
			//alert(dropitem.className);
			closealldropdown();
		}	
	} 
}
function closealldropdown(){  
	if (dropitem) dropitem.style.display = 'none';
	if (dropframe) 	dropframe.style.display = 'none'; 
}

// go close timer
function closedropdowntime()
{
	closetimer = window.setTimeout(closedropdown, timeout);
}
// close layer when click-out
document.onclick = closedropdown; 
 
 
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"
		}
	]

};
BrowserDetect.init();

 
