var all_div = '';
var base_url = '';
var pre_id = '';
//http://docs.jquery.com/Tutorials:Getting_Started_with_jQuery
function show_hide(curr, objs){
	for (j in objs){
		var curr = '#' + objs[j] + curr;
		/*
		var hide = curr + ":hidden";
		var show = curr + ":visible";

		$(hide).animate({ height: 'show', opacity: 'show' }, 'fast');
		$(show).animate({ height: 'show', opacity: 'hide' }, 'fast');
		*/
		$(curr).slideToggle('fast');
	}
}
function toggleMore(id){
	//alert("hide " + id)
	toggleVisibility('more'+id);
}

function toggleVisibility(nr)
{
	if (document.layers)
	{
		vista = (document.layers[nr].visibility == 'hide') ? 'show' : 'hide'
		document.layers[nr].visibility = vista;
	}
	else if (document.all)
	{
		vista = (document.all[nr].style.visibility == 'hidden') ? 'visible'	: 'hidden';
		document.all[nr].style.visibility = vista;
	}
	else if (document.getElementById)
	{
		vista = (document.getElementById(nr).style.visibility == 'hidden') ? 'visible' : 'hidden';
		document.getElementById(nr).style.visibility = vista;
	}
}
function toggleDisplayBlock(nr)
{
	if (document.layers)
	{
		current = (document.layers[nr].display == 'none') ? 'block' : 'none';
		document.layers[nr].display = current;
	}
	else if (document.all)
	{
		current = (document.all[nr].style.display == 'none') ? 'block' : 'none';
		document.all[nr].style.display = current;
	}
	else if (document.getElementById)
	{
		vista = (document.getElementById(nr).style.display == 'none') ? 'block' : 'none';
		document.getElementById(nr).style.display = vista;
	}
}

function setAll(str){
	all_div = str;
	for( i in all_div ){ toggleMore(all_div[i]); }	//show 'click for more', we hide it first and show it when javascript is available
}


function hideAll(objs, except){
	for (j in objs){
		all = all_div;
		for(i in all){
			if(all[i] != except){
				var other = '#' + objs[j] + all[i];
				other += ":visible";
				$(other).hide();
			}
		}
	}
}
function aol_atc_dsp(title, content, id, nav_id){
	//aol_atc_dsp('cl2', 'cl2', 'aol_atc_dspcommerciallitigat', 'link84')
	var o_title = document.getElementById(id + "_title");
	var o_content = document.getElementById(id + "_content");
	var o_nav_id = document.getElementById(nav_id);
	var o_pre_id = document.getElementById(pre_id);

	o_nav_id.style.color="#1762ff";
	//if(o_pre_id){ o_pre_id.removeAttribute("style"); }
	if(o_pre_id){ o_pre_id.removeAttribute("style", "color"); }

	pre_id = nav_id;

	title_htm = '<div class="hiro_aol_article_tb">';
	title_htm += '<span class="hiro_aol_article_stitle">';
	title_htm += title;
	title_htm += '</span><br>';
	title_htm += '</div>';

	o_title.innerHTML = title_htm;
	o_content.innerHTML = content;
	if(window.hasFlash == false || !document.createElement || !document.getElementById ){
		//sifrNoFlashHack();
		//var obj = $("span.hiro_aol_article_stitle")[0];
		//styles['hiro_aol_article_stitle'] = {extra_css:'font-size:12px; font-weight: bold; letter-spacing:-0.5px;', sct:3};
		//var extra_css = 'font-size:12px; font-weight: bold; letter-spacing:-0.5px;';
		//obj.setAttribute('style', 'margin-right:12px; ' + extra_css);
	} else {
		//var obj = $("span.hiro_aol_article_stitle")[0];
		//var extra_css = 'font-size:13px; font-weight: normal; letter-spacing:0px;'
		//obj.setAttribute('style', 'margin-right:12px; ' + extra_css);
		//sIFR.replaceElement("span.hiro_aol_article_stitle", named({sFlashSrc: base_url+"/modules/sifr/sifr/hiro_heading.swf", sColor: "#494949", sLinkColor: "#6f6f6f", sHoverColor: "#6f6f6f", sBgColor: "#FFFFFF", sFlashVars: "textalign=left"}));
	};
}


function show_one(curr, instance, hl_color, normal_color){
	/*
	if(instance == true){	//means we go to another page
		if ( $.cookie('last_selected_month') ){ curr = $.cookie('last_selected_month'); }
	} $.cookie('last_selected_month', curr);
	*/

	//alert(all_div); for(i in all_div){ alert(i + " : " + all_div[i]); }
	all = all_div;

	//var curr = 'div.article' + curr;
	var curr_t = 'title' + curr;
	var curr = '#article' + curr;

	for(i in all){
		//var other = 'div.article' + all[i];
		var other = '#article' + all[i];
		if( other == curr ){	//show the month
			curr += ":hidden";
			//$(curr).slideDown("fast");
			if(instance == true){ $(curr).show(); }	//instance show
			else { $(curr).animate({ height: 'show', opacity: 'show' }, 'fast'); }
		} else {	//hide the month
			other += ":visible";
			//$(other).slideUp("fast");
			//if(instance == true){ $(other).hide(); }	//instance hide
			//else { $(other).animate({ height: 'hide', opacity: 'hide' }, 'fast'); }
			$(other).hide();
		}

		if(hl_color){	//if we need highlight
			var other_t = 'title' + all[i];
			if( curr_t == other_t ){
				setColor(curr_t, hl_color, true);
			} else {
				setColor(other_t, normal_color, false);
			}
		}
	}
}
function hideAll_instance(objs, except){
	//for(i in all_div){ alert(all_div[i]) }
	for (j in objs){
		for(i in all_div){
			if(all_div[i] != except){
				var other = objs[j] + all_div[i];
				other = document.getElementById(other);
				other.style.display = 'none';
			}
		}
	}
}
function show_one_instance(curr, instance, hl_color, normal_color){
	/*
	if(instance == true){	//means we go to another page
		if ( $.cookie('last_selected_month') ){ curr = $.cookie('last_selected_month'); }
	} $.cookie('last_selected_month', curr);
	*/

	//alert(all_div); for(i in all_div){ alert(i + " : " + all_div[i]); }
	all = all_div;

	//var curr = 'div.article' + curr;
	var curr_t = 'title' + curr;
	var curr = 'article' + curr;

	for(i in all){
		//var other = 'div.article' + all[i];
		var other = 'article' + all[i];
		if( other == curr ){	//show the month
			//curr += ":hidden";
			//$(curr).slideDown("fast");
			/*
			if(instance == true){ $(curr).show(); }	//instance show
			else { $(curr).animate({ height: 'show', opacity: 'show' }, 'fast'); }
			*/
			curr = document.getElementById(curr);
			curr.style.display = 'block';
		} else {	//hide the month
			//other += ":visible";
			//$(other).slideUp("fast");
			//if(instance == true){ $(other).hide(); }	//instance hide
			//else { $(other).animate({ height: 'hide', opacity: 'hide' }, 'fast'); }
			//$(other).hide();
			other = document.getElementById(other);
			other.style.display = 'none';
		}

		if(hl_color){	//if we need highlight
			var other_t = 'title' + all[i];
			if( curr_t == other_t ){
				setColor(curr_t, hl_color, true);
			} else {
				setColor(other_t, normal_color, false);
			}
		}
	}
}


function colorChange(id, color, objs, img_onoff, bk_color){
	for (i in objs){
		obj = objs[i] + id;
		if(objs[i] == "bk"){ setBackGroundColor(obj, bk_color); }
		else { setColor(obj, color, img_onoff); }
	}
}
function setColor(obj, color, img_onoff){
	if( color == undefined ){ return; }
	var img = document.getElementById(obj + "_img");
	var obj = document.getElementById(obj);
	obj.style.color = color;

	if(img){
		var src = img.src;
		if (img_onoff == true){
			img.src = getHLImg(img.src);
		} else {
			img.src = getNRImg(img.src);
		}
	}

	//alert(img)
}
function setBackGroundColor(obj, color){
	if( color == undefined ){ return; }
	var bk = document.getElementById( obj );
	bk.style.backgroundColor = color;
}

function getHLImg(src){
	if( src == undefined ){ return; }
	if( src.indexOf("_h.gif") != -1 ){ return src; } else
	{ return src.replace(/.gif/, "_h.gif"); }
}
function getNRImg(src){
	if( src == undefined ){ return; }
	if( src.indexOf("_h.gif") != -1 ){ return src.replace(/_h.gif/, ".gif") }
	else { return src; }
}

function as(var1, asd, af, g5r, g5){
alert(var1+ " : " + asd+ " : " + af+ " : " + g5r+ " : " + g5)
}

function removeFieldText(obj, txt){
	if( obj.value == txt ){ obj.value = ''; }
}
function putBackFieldText(obj, txt){
	if( obj.value == '' ){ obj.value = txt; }
}
function setBaseUrl(url){
	base_url = url;
}












	function sifrNoFlashHack(){
		var styles = new Object();
		var objects = new Array();

		styles['pri_link'] = {space:15, extra_css:'font-size: 13px; font-weight: bold;', sct:1};
		styles['pri_link_active'] = {space:15, extra_css:'font-size: 13px; font-weight: bold;', sct:1};

		styles['hiro_aol_title'] = {space:6, extra_css:'font-size:12px; font-weight: bold; letter-spacing:-0.5px;', sct:2};
		styles['hiro_aol_title_active'] = {space:6, extra_css:'font-size:12px; font-weight: bold; letter-spacing:-0.5px;', sct:2};

		styles['hiro_aol_article_ptitle'] = {space:0, extra_css:'font-size:12px; font-weight: bold; letter-spacing:-0.5px;', sct:3};
		styles['hiro_aol_article_stitle'] = {space:0, extra_css:'font-size:12px; font-weight: bold; letter-spacing:-0.5px;', sct:3};
		styles['hiro_publication_heading'] = {space:0, extra_css:'font-size:12px; font-weight: bold; letter-spacing:-0.5px;', sct:3};


		for(var i in styles){ objects.push('.'+i); }
		resetCss( objects, styles );
	}
	function resetCss(obj, styles){
		var section_first = new Object();

		if( !obj ){ return; }

		$("span").filter( obj ).each(function(i) {
			var cls = this.getAttribute( document.all ? 'className' : 'class' );
			if( cls ){
				var style = styles[cls];
				var space = style['space'];
				var extra_css = style['extra_css'];
				var sct = style['sct'];
				//if( space == undefined ){ space = 10; }
				//if( !extra_css ){ extra_css = ''; }
				if( section_first[sct] != true ){
					//this.setAttribute('style', 'margin-left:0px; margin-right:'+space+'px; ' + extra_css );
					this.style.cssText = 'margin-left:0px; margin-right:'+space+'px; ' + extra_css
					section_first[sct] = true;
				} else {
					//this.setAttribute('style', 'margin-left:'+space+'px; margin-right:'+space+'px; ' + extra_css);
					this.style.cssText = 'margin-left:'+space+'px; margin-right:'+space+'px; ' + extra_css
				}
			}
		}).end();
	}


	//check if flash play is installed, else replace banner with an image.
	function imageNoFlash(){
		var banner = document.getElementById('banner');
		if( banner != undefined ){
			var content = banner.innerHTML;
			content = content.toLowerCase();
			if( content.indexOf('<embed') >= 0 ){
				var i = content.indexOf('files')// + ('src="').length;
				content = content.substr(i);
				var i = content.indexOf('swf')// - ('swf').length;
				content = base_url+'/'+content.substr(0, i) + 'jpg';
				banner.innerHTML = '<img src="'+content+'" >';
			}
		}
	}




	$(document).ready(function() {
		if(window.hasFlash == false || !document.createElement || !document.getElementById ){
			//imageNoFlash();
			//sifrNoFlashHack();
		} else {
			bannerToFlash();
		}
	} )




	var banner_flash; var banner_flash_height;
	function bannerFlash(swf, height){ banner_flash = swf; banner_flash_height = height; }
	function bannerToFlash(){
		if( banner_flash == null ){ return; }
		var banner = document.getElementById('banner');
		if( banner != undefined ){
			var content = banner.innerHTML;
			content = content.toLowerCase();
			if( content.indexOf('<img') >= 0 ){
				banner.innerHTML = '<embed id="" width="100%" height="'+banner_flash_height+'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" src="'+banner_flash+'" play="true" loop="true" menu="true"></embed>	';
			}
		}
	}


	//in sifr.js,
	//	*for(var i = 0, limit = listNodes.length; i < limit; i++){
	//	*	node = listNodes[i];
	//	*	sifrSpanAdjust(node);
	function sifrSpanAdjust(node){
			//alert( node.innerHTML )

			var txt = node.innerHTML;
			var idx = txt.indexOf('>')+1;
			txt = txt.substr(idx);
			idx = txt.indexOf('<');
			txt = txt.substr(0, idx);
			var cls = node.getAttribute( document.all ? 'className' : 'class' );

			//<A class=pri_link href="/adasd>Home</A>


			var str = 0;
			var end = 0;
			var ext_css = '';
			switch( cls ){
				case 'pri_link' :
				case 'pri_link_active' :
					str = 3;
					end = 2;
					/*
					if( txt == 'Home' ){ end = 11; }
					if( txt == 'About Us' ){ str = 18; end = 5; }
					if( txt == 'Areas of Law' ){ str = 17; }
					if( txt == 'Our People' ){ str = 17; end = 6; }
					if( txt == 'Publications' ){ str = 18; end = 3; }
					if( txt == 'Contact' ){ str = 17; }
					*/
					if( txt == 'Home' ){ str = 0; }
					if( txt == 'Areas of Law' ){ end = 0; }
				break;
				/*
				case 'hiro_aol_title' :
				case 'hiro_aol_title_active' :
					if( txt == 'Commercial/Business Transactions' ){ end = 0; }
					if( txt == 'Commercial Litigation' ){ end = 11; }
					if( txt == 'Estate Planning & Succession' ){ end = 0; }
				break;

				case 'hiro_aol_article_ptitle' :
				case 'hiro_aol_article_stitle' :
				case 'hiro_publication_heading' :
					ext_css = 'font-size:13px; font-weight: normal; letter-spacing:0px;'
				break;
				*/
			}
			node.style.cssText = 'margin-left:'+str+'px; margin-right:'+end+'px; ' + ext_css
			//alert(cls + " : " + txt)
	}