//STUFF//


function relocate(path) {
	location.href = path;
}


function confirm_relocate(path) {

	if (!confirm('Are you sure?')) return;
	location.href = path;

}


function show_desc(n) {
	
	var div = getobj('wp_'+n);
	
	div.style.display = 'block';
	
	this.onmouseout = function(e) {
		div.style.display = 'none';
	}

}


function goto(url, frame, list, h) {

	var l = getobj('layout');
	var x = parent.getobj('extcontent');
	var p = getobj('progress');
	
	if (h) window.scrollTo(0,0);

	extcontent.window.location.href = url;
	
	switch_getstarted('get_frame', 'get_frame,get_started');


	$('progress').style.display = 'block';
	$('layout').style.height = 10000+'px';
	
	height = (h) ? 0 : 147; 
	
	if (document.all) {
		
		Event.observe(x, 'load', function() {  
			$('progress').style.display = 'none';
			
			$('layout').style.height  = height+'px';
			
		}, false);

	} else if (document.layers) {
		parent.document.layers['extcontent'].onload = function(o) {
			$('progress').style.display = 'none';
			$('layout').style.height  = height+'px';
		}

	} else {
			parent.document.getElementById('extcontent').onload = function(o) {
				$('progress').style.display = 'none';
				$('layout').style.height = height+'px';
			}
	}
}


function checkframe() {
	

	var w = window.name;


		if (document.all) {
			
			
			parent.document.all[w].scrolling = 'no';
			parent.document.all[w].height = parseInt(document.body.scrollHeight);
			
			
		} else if (document.layers) {

			
			parent.document.layers['widgetholder'].scrolling = 'no';
			parent.document.layers[w].height = parseInt(document.body.scrollHeight);
			

		} else {
			parent.document.getElementById(w).scrolling = 'no';
			parent.document.getElementById(w).height = parseInt(document.body.scrollHeight);
			

		}
	
}

function check_blog_window() {

	
	if (window.name == 'extcontent') {
		
		
		$('header_background').style.display = 'none';
		
		$('footer').style.display = 'none';
		
		
		$('content').style.width = 100 + '%';
		$('container').style.width = 100 + '%';
		$('navbar').style.display = 'none';
		if (document.all) {
			
			document.body.style.overflow = 'hidden';

			parent.document.all['extcontent'].height = parseInt(document.body.scrollHeight);
			parent.document.all['extcontent'].scrolling = 'no';
			
		} else if (document.layers) {

			document.body.style.overflow = 'hidden';
			
			parent.document.layers['extcontent'].height = parseInt(document.body.scrollHeight);
			parent.document.layers['extcontent'].scrolling = 'no';

		} else {

			parent.document.getElementById('extcontent').height = parseInt(document.body.scrollHeight);
			parent.document.getElementById('extcontent').scrolling = 'no';

		}

	}

}

function checkwindow(page) {

	
	if (window.name == 'extcontent') {
		
		
		$('header_background').style.display = 'none';
		$('content').style.width = 100 + '%';
		$('footer').style.display = 'none';
		
		
		if (page == 'blog') {
			
			$('content').style.width = 100 + '%';
			$('container').style.width = 100 + '%';
			$('navbar').style.display = 'none';
			
		}

		
		if (document.all) {
			
			document.body.style.overflow = 'hidden';

			parent.document.all['extcontent'].height = parseInt(document.body.scrollHeight);
			parent.document.all['extcontent'].scrolling = 'no';
			
		} else if (document.layers) {

			document.body.style.overflow = 'hidden';
			
			parent.document.layers['extcontent'].height = parseInt(document.body.scrollHeight);
			parent.document.layers['extcontent'].scrolling = 'no';

		} else {

			parent.document.getElementById('extcontent').height = parseInt(document.body.scrollHeight);
			parent.document.getElementById('extcontent').scrolling = 'no';

		}

	}

}


function getobj(x) {
	
	var e;
	
	if (document.all) { e = document.all[x];
	} else if (document.layers) { e = document.layers[x];
	} else { e = document.getElementById(x);
	}
	
	return e;
	
}

function populate(source, prefix) {
	populate2(source, prefix);
}

function populate2(source, prefix) {

	var x = source;
	var i = x.selectedIndex;
	var n = x.options[i].text.toLowerCase();
	var v = x.options[i].value.toLowerCase();


	for (o = 0; o < x.options.length; o++) {
		
		var id = x.options[o].value.toLowerCase();
		
		//alert(v+'_'+id+'_'+prefix);
		
		if (!$(id+'_'+prefix)) continue;
		

		if (v == id) $(id+'_'+prefix).style.display = 'block';
		else $(id+'_'+prefix).style.display = 'none';
		
	}
	
}


function populate_radio(source, prefix) {


	var list = ['credit_card','paypal','mail_in_registration'];
	var s = source.value.toLowerCase();

	for (o = 0; o < list.length; o++) {
		
		var id = list[o];

		if (!$(id+'_'+prefix)) continue;

		if (s == id) $(id+'_'+prefix).style.display = 'block';
		else $(id+'_'+prefix).style.display = 'none';
		
	}
	
}


function jz_popup(src, text) {

	var popup = getobj('jzpopup');

	var xoffset = 15;
	var yoffset = 10;

	src.onmousemove = function(e) {
	
		var x, y, right, bottom;
		  
		try { x = e.pageX; y = e.pageY; } // FF
		catch(e) { x = event.x; y = event.y; } // IE
		
		right = (document.documentElement.clientWidth || 
		document.body.clientWidth || document.body.scrollWidth);
		bottom = (window.scrollY || document.documentElement.scrollTop || document.body.scrollTop) + 
		(window.innerHeight || document.documentElement.clientHeight || 
		 document.body.clientHeight || document.body.scrollHeight);
		
		x += xoffset;
		y += yoffset;
		
		if (x > right-popup.offsetWidth) x = right-popup.offsetWidth;
		if (y > bottom-popup.offsetHeight) y = bottom-popup.offsetHeight;
		  
		popup.style.top = y+'px';
		popup.style.left = x+'px';
		popup.innerHTML = text;

		popup.style.display = 'block';	
		
	}
	
			
	src.onmouseout = function(e) {
		popup.style.display = 'none';	
	}
	/*
	src.onclick = function(e) {
		popup.style.display = 'none';	
	}
	*/
	document.onmouseout = function(e) {
		popup.style.display = 'none';	
	}
			


	
	
}

function show_menu3(obj, src_menu, where, hori, vert, over, parent) {
	
	var y = 0;
	var x = 0;
	

	
	var menu = getobj(src_menu);

	if (!menu) return;


	if (vert == 'down') y = parseInt(findtop(obj)) + parseInt(obj.offsetHeight);	
	else y = parseInt(findtop(obj)) - parseInt(menu.offsetHeight);
	
	//alert(parseInt(obj.offsetHeight));
	
	if (hori) y = y - parseInt(obj.offsetHeight);

	
	if (hori == 'right') x = parseInt(findleft(obj)) + parseInt(obj.offsetWidth);
	else if (hori == 'left') x = parseInt(findleft(obj)) - parseInt(menu.offsetWidth);	
	else  x = parseInt(findleft(obj));
	
	
	
	
	
	if (over && hori=='left') x = x + parseInt(obj.offsetWidth);
	
	if (over && hori=='right') x = x - parseInt(obj.offsetWidth);
	
	var w = parseInt(obj.offsetWidth) - 22;
	var w2 = parseInt(menu.offsetWidth) - 22;
	

	menu.style.top = y+'px';
	menu.style.left = x+'px';
	

	if (w2 < w) menu.style.width = w+'px';


	obj.onmouseout = function(e) {

		if (target(e)) {
			menu.style.top = where;
			if (parent) obj.className = parent;
		}
	}
	
	menu.onmouseover = function(e) {
		show_menu3(obj, src_menu, where, hori, vert, over, parent);
		if (parent) obj.className = parent+'2';
	}
	
	menu.onmouseout = function(e) {

			if (target(e)) {
				menu.style.top = where;
				if (parent) obj.className = parent;
			}
	}
	


}


function hide_click_menu(src_menu) {

	var menu = getobj(src_menu);
	if (!menu) return;





	menu.style.top = -1000+'px';
	menu.style.left = -1000+'px';

	return;

}

function show_click_menu(src_obj, src_menu, where, hori, vert, over, parent) {
	
	var obj = getobj(src_obj);
	if (!obj) return;

	var menu = getobj(src_menu);
	if (!menu) return;


	hide_click_menu(newjax.calendar.open_menu);
	newjax.calendar.open_menu = src_menu;


	var y = 0;
	var x = 0;


	if (vert == 'down') y = parseInt(findtop(obj)) + parseInt(obj.offsetHeight);	
	else y = parseInt(findtop(obj)) - parseInt(menu.offsetHeight);
	
	//alert(parseInt(obj.offsetHeight));
	
	if (hori) y = y - parseInt(obj.offsetHeight);

	
	if (hori == 'right') x = parseInt(findleft(obj)) + parseInt(obj.offsetWidth);
	else if (hori == 'left') x = parseInt(findleft(obj)) - parseInt(menu.offsetWidth);	
	else  x = parseInt(findleft(obj));
	

	if (over && hori=='left') x = x + parseInt(obj.offsetWidth);
	if (over && hori=='right') x = x - parseInt(obj.offsetWidth);
	
	var w = parseInt(obj.offsetWidth) - 22;
	var w2 = parseInt(menu.offsetWidth) - 22;
	

	menu.style.top = y+'px';
	menu.style.left = x+'px';

	if (w2 < w) menu.style.width = w+'px';



	return;

	obj.onmouseout = function(e) {

		if (target(e)) {
			menu.style.top = where;
			if (parent) obj.className = parent;
		}
	}
	
	menu.onmouseover = function(e) {

		show_click_menu(src_obj, src_menu, where, hori, vert, over, parent);
		if (parent) obj.className = parent+'2';

	}
	
	menu.onmouseout = function(e) {

			if (target(e)) {
				menu.style.top = where;
				if (parent) obj.className = parent;
			}
	}
	


}

function show_menu(obj, src_menu, where, dir) {
	
	var y = 0;
	var x = 0;
	
	var menu = getobj(src_menu);


	if (dir == 'down') y = parseInt(findtop(obj)) + parseInt(obj.offsetHeight);	
	else if (dir == 'right') y = parseInt(findtop(obj));
	else if (dir == 'left') y = parseInt(findtop(obj));
	else y = parseInt(findtop(obj)) - parseInt(menu.offsetHeight);
	
	

	
	if (dir == 'right') x = parseInt(findleft(obj)) + parseInt(obj.offsetWidth);
	else if (dir == 'left') x = parseInt(findleft(obj)) - parseInt(menu.offsetWidth);	
	else  x = parseInt(findleft(obj));
	
	
	
	var w = parseInt(obj.offsetWidth) - 22;
	var w2 = parseInt(menu.offsetWidth) - 22;
	

	menu.style.top = y+'px';
	menu.style.left = x+'px';
	

	if (w2 < w) menu.style.width = w+'px';


//alert(x+' '+y);


	obj.onmouseout = function(e) {
		if (target(e)) menu.style.top = where;
	}
	
	menu.onmouseover = function(e) {
		show_menu(obj, src_menu, where, dir);
	}
	
	menu.onmouseout = function(e) {
			if (target(e)) menu.style.top = where;
	}
	


}



function target(e) {
	

	if (!e) var e = window.event;
	var tg = (window.event) ? e.srcElement : e.target;



	if (tg.nodeName == 'SELECT' || tg.nodeName == 'OPTION' || tg.nodeName == 'INPUT') return false;



	var reltg = (e.relatedTarget) ? e.relatedTarget : e.toElement;
	while (reltg != tg && reltg.nodeName != 'BODY') reltg = reltg.parentNode
	if (reltg == tg) return false;
	return true;
	

}
			
			
function show_menu2(obj, menu, where) {
	
	var yy = $('profileScroller').offsetTop;
	var xx = $('profileScroller').offsetLeft;
	
	var y = parseInt(obj.offsetTop) + yy + parseInt(obj.offsetHeight);
	var x = parseInt(obj.offsetLeft) + xx;

	var w = parseInt(obj.offsetWidth) - 22;

	var w2 = parseInt($(menu).offsetWidth) - 22;


	obj.className = 'initial2';
	

	$(menu).style.top = y+'px';
	$(menu).style.left = x+'px';

	if (w2 < w) $(menu).style.width = w+'px';
	
	obj.onmouseout = function() {
		
		if (document.layers || document.all) {
			if (event.toElement != $(menu) && $(menu).contains(event.toElement) == false ) {
				$(menu).style.top = where;
				obj.className = 'initial';
			}
		} else {
			$(menu).style.top = where;
			obj.className = 'initial';
		}
		
	}
	
	
	$(menu).onmouseover = function() {
		show_menu2(obj, menu, where);
		
	}
	
	$(menu).onmouseout = function() {
		if (document.layers || document.all) {
			if (event.toElement != $(menu) && $(menu).contains(event.toElement) == false ) {
				$(menu).style.top = where;
				obj.className = 'initial';
			}
		} else {
			$(menu).style.top = where;
			obj.className = 'initial';
		}
	}
	
	

}






function findtop(obj) {
	var curtop = 0;
	if (!obj) return;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent) {
			curtop += obj.offsetTop;
		}
	
	return curtop;
}


function findleft(obj) {
	var curleft = 0;
	if (!obj) return;
		curleft = obj.offsetLeft;
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft;
		}
			
		
	
	return curleft;
}



function findwidth(obj) {
	var curwidth = 0;
	if (!obj) return;
		curwidth = obj.offsetWidth;
		while (obj = obj.offsetParent) {
			curwidth += obj.offsetWidth;
		}
			
		
	
	return curwidth;
}





function hide_menu(obj, menu) {
	$(menu).style.display = 'none';
}




function openwindow(url, name, h, w) {
	win = window.open(url,name,"width="+h+",height="+w+"");
}



function populate_single(source, div) {

	if (source.type == 'radio') var v = source.value;
	else var v = source.options[source.selectedIndex].value;

	if (v+'_option' == div) $(div).style.display = 'block';
	else $(div).style.display = 'none';

}


function populate(source, prefix) {
	
	
	var x = getobj(source+prefix);
	var f = getobj('customfields_'+prefix);
	
	var i = x.selectedIndex;
	var n = x.options[i].text;
	var v = x.options[i].value;
	var id = '';
	

	if (n == 'Custom') f.style.display = 'block';
	else f.style.display = 'none';
	
	
	
	for (o = 0; o < x.options.length; o++) {
		
		id = x.options[o].value;

		if (v == id) $(id+'_'+prefix).style.display = 'block';
		else $(id+'_'+prefix).style.display = 'none';
		
	}

}



function showdiv(id){

    var theElement = getobj(id);
      theElement.style.display = "block";
  
}


function hidediv(id){

    var theElement = getobj(id);
      theElement.style.display = "none";
  
}


function switch_page( id, pages, name ) {
  var i = 0;
  var p = name;

  for(i = 1; i <= pages; i++) {
	if (id == p+i) if ($(p+i)) $(p+i).style.display = "block";
    if (id != p+i) if ($(p+i)) $(p+i).style.display = "none";
  }
  
  $('help').style.display = "none";
  $('expand').style.width = '100%';
  
}



function switch_label(id) {

	var x = getobj(id);
	
	if (x.innerHTML == 'Expand') x.innerHTML = 'Collapse';
	else x.innerHTML = 'Expand';
	
}

function switch_class(id, myclass, list) {
	
	var i = 0;
	var panels = list.split(",");

	for(i = 0; i < panels.length; i++) {
		
		var x = getobj(panels[i]);

    	if(id == x) if(x) x.className = myclass+'2';
    	if(id != x) if(x) x.className = myclass;
	}
}

function switch_cell(id, list, newtab) {

	if (!newtab) newtab = 'newtab';
	
	var over = (newtab == 'newtab') ? 'over' : '_over';
	
	
	var i = 0;
	var panels = list.split(",");

	for(i=0; i < panels.length; i++) {
		
		var x = getobj(panels[i]);
		var crumb = getobj(x.id+'_crumb');

    	if (id == panels[i]) {
			
			x.style.display = "block";
			crumb.className = newtab+over;
			
    	} else {
			
			x.style.display = (id == 'expand_all_tab') ? "block" : "none";
			crumb.className = newtab;

		}
	}
}





function goToURL(form)
  {
        
    var myindex=form.dropdownmenu.selectedIndex
    if(!myindex=="")
      {
        window.location.href=form.dropdownmenu.options[myindex].value;
      
        // This is an alternative method you can use
        // var frameTarget = "_new";
        // window.open(form.dropdownmenu.options[myindex].value,frameTarget,"");
      }
}

function showjlz(object) {
  if (document.getElementById) {
    document.getElementById(object).style.visibility = 'visible';
  }
  else if (document.layers && document.layers[object]) {
    document.layers[object].visibility = 'visible';
  }
  else if (document.all) {
    document.all[object].style.visibility = 'visible';
  }
}

function hidejlz(object) {
  if (document.getElementById) {
    document.getElementById(object).style.visibility = 'hidden';
  }
  else if (document.layers && document.layers[object]) {
    document.layers[object].visibility = 'hidden';
  }
  else if (document.all) {
    document.all[object].style.visibility = 'hidden';
  }
}

function toggleLayerjz( whichLayer ) {
  var elem, vis;
  if( document.getElementById ) // this is the way the standards work
    elem = document.getElementById( whichLayer );
  else if( document.all ) // this is the way old msie versions work
      elem = document.all[whichLayer];
  else if( document.layers ) // this is the way nn4 works
    elem = document.layers[whichLayer];
  vis = elem.style;
  // if the style.display value is blank we try to figure it out here
  if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
    vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
  vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}
