// GLOBAL WWCN JS

function wwcn_EleObjs(e) { if(typeof(e)=='string') { if(document.getElementById) { e=document.getElementById(e); } else if(document.all) { e=document.all[e]; } else { e=null; } } return e; }
function wwcn_writeToLayer(code_string,layer_id){ wwcn_EleObjs(layer_id).innerHTML=code_string; }
function wwcn_hideLayer(layer_id) { wwcn_EleObjs(layer_id).style.display='none'; }
function wwcn_showLayer(layer_id) { wwcn_EleObjs(layer_id).style.display='block'; }

function wwcn_Str(s) { 
	for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}
	return true;
}

function wwcn_isIE() {  return /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent); }

function wwcn_Opacity(e, o) {
	var set = o;
	if(!(e=wwcn_EleObjs(e))) return 2;
  	if (wwcn_Str(e.style.opacity)) {
    	if (set) e.style.opacity = o + '';
    	else o = parseFloat(e.style.opacity);
  	}
  	else if (wwcn_Str(e.style.filter)) {
    	if (set) e.style.filter = 'alpha(opacity=' + (100 * o) + ')';
    	else if (e.filters && e.filters.alpha) { o = e.filters.alpha.opacity / 100; }
  	}
 	 else if (wwcn_Str(e.style.MozOpacity)) {
    	if (set) e.style.MozOpacity = o + '';
    	else o = parseFloat(e.style.MozOpacity);
  	}
  	else if (wwcn_Str(e.style.KhtmlOpacity)) {
    	if (set) e.style.KhtmlOpacity = o + '';
    	else o = parseFloat(e.style.KhtmlOpacity);
  	}
 	return isNaN(o) ? 1 : o;
}


/* VARIABLES */
var wwcn_timeOuts = new Object();
var wwcn_liOtablePre = '<table cellspacing="0" cellpadding="0" border="0" align="center" height="100%"><tr valign="middle" height="100%"><td valign="middle" height="100%" align="center">';
var wwcn_liOtablePost = '</td></tr></table>';


function wwcn_FadeIn(e, r_switch) {
	
	if(!wwcn_timeOuts[e] || r_switch) {
		if(wwcn_timeOuts[e]) { clearTimeout(wwcn_timeOuts[e].t_var); }
		wwcn_timeOuts[e] = { 'opacity' : '', 't_var' : '' }
		wwcn_timeOuts[e].opacity = 0;wwcn_Opacity(e, 0);
	}
	
	wwcn_showLayer(e);
		
	if(wwcn_timeOuts[e].opacity < 1) {
		wwcn_timeOuts[e].opacity = Math.round((wwcn_timeOuts[e].opacity + 0.02) * 100) / 100;
		wwcn_Opacity(e, wwcn_timeOuts[e].opacity);
		to_str = "wwcn_FadeIn('" + e + "')";
		wwcn_timeOuts[e].t_var = setTimeout(to_str,35);
	}
	else {clearTimeout(wwcn_timeOuts[e].t_var); }
	
}

function wwcn_FadeOut(e, r_switch) {
	
	if(!wwcn_timeOuts[e] || r_switch) {
		if(wwcn_timeOuts[e]) { clearTimeout(wwcn_timeOuts[e].t_var); }
		else {
			wwcn_timeOuts[e] = { 'opacity' : '', 't_var' : '' }
			wwcn_timeOuts[e].opacity = 1;wwcn_Opacity(e, 1);
		}
	}
	
	if(wwcn_timeOuts[e].opacity > 0) {
		wwcn_timeOuts[e].opacity = Math.round((wwcn_timeOuts[e].opacity - 0.02) * 100) / 100;
		wwcn_Opacity(e, wwcn_timeOuts[e].opacity);
		to_str = "wwcn_FadeOut('" + e + "')";
		wwcn_timeOuts[e].t_var = setTimeout(to_str,35);
	}
	else {wwcn_hideLayer(e);clearTimeout(wwcn_timeOuts[e].t_var); }
	
}

function init_Fading() {

	for (var i=0; i<wwcn_fadeObjs.length; i++) {
		var fobj_toID = 'fobj_' + i;
		wwcn_timeOuts[fobj_toID] = { 't_var' : '' }
		var to_str = "wwcn_increFade(" + i + ", " + wwcn_fadeObjs[i].hold_time + ")";
		wwcn_timeOuts[fobj_toID].t_var = setTimeout(to_str,wwcn_fadeObjs[i].hold_time);
	}
	
}

function wwcn_increFade(fobj_id, fobj_to) {

	if(wwcn_fadeObjs[fobj_id].fade_active) {
		if(wwcn_fadeObjs.length >= wwcn_fadeObjs[fobj_id].fade_curr) { wwcn_performFade(fobj_id, wwcn_fadeObjs[fobj_id].fade_curr + 1);	}
		else if(wwcn_fadeObjs.length < wwcn_fadeObjs[fobj_id].fade_curr) { wwcn_performFade(fobj_id, 0); }
	}
	wwcn_resetIFade(fobj_id);
	
}

function wwcn_toggleAFade(fobj_id, tog_handler) {

	if(wwcn_fadeObjs[fobj_id].fade_active) { wwcn_fadeObjs[fobj_id].fade_active = 0; }
	else {
		wwcn_fadeObjs[fobj_id].fade_active = 1;
		wwcn_nextFade(fobj_id);
	}
	
	if(typeof tog_handler == 'function') { tog_handler(wwcn_fadeObjs[fobj_id].fade_active); }
	
}

function wwcn_prevFade(fobj_id) {

	if(0 < wwcn_fadeObjs[fobj_id].fade_curr) { wwcn_performFade(fobj_id, wwcn_fadeObjs[fobj_id].fade_curr - 1);	}
	else { wwcn_performFade(fobj_id, wwcn_fadeObjs.length +1); }
	
	wwcn_resetIFade(fobj_id);

}

function wwcn_nextFade(fobj_id) {

	if(wwcn_fadeObjs.length >= wwcn_fadeObjs[fobj_id].fade_curr) { wwcn_performFade(fobj_id, wwcn_fadeObjs[fobj_id].fade_curr + 1);	}
	else { wwcn_performFade(fobj_id, 0); }
	wwcn_resetIFade(fobj_id);

}

function wwcn_performFade(fobj_id, n_fobj_curr) {

	wwcn_FadeOut(wwcn_fadeObjs[fobj_id].fade_order[wwcn_fadeObjs[fobj_id].fade_curr], 1);
	wwcn_fadeObjs[fobj_id].fade_curr = n_fobj_curr;
	wwcn_FadeIn(wwcn_fadeObjs[fobj_id].fade_order[wwcn_fadeObjs[fobj_id].fade_curr], 1);

}

function wwcn_resetIFade(fobj_id) {

	var fobj_toID = 'fobj_' + fobj_id;
	var adjusted_hTime = wwcn_fadeObjs[fobj_id].hold_time + 1750; //takes 1750 milliseconds for fade in/out functions to finish
	var to_str = "wwcn_increFade(" + fobj_id + ", " + adjusted_hTime + ")";
	if(wwcn_timeOuts[fobj_toID].t_var) { clearTimeout(wwcn_timeOuts[fobj_toID].t_var); }
	wwcn_timeOuts[fobj_toID].t_var = setTimeout(to_str,adjusted_hTime);

}

function wwcn_fbsClick(wwcn_fbsGTrackVar) {
	pageTracker._trackPageview('/share/facebook'+wwcn_fbsGTrackVar);
	u=location.href;
	t=document.title;
	var wwcn_jswinFBSharer = window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'wwcn_jswinFBSharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

function wwcn_loadinOvrlay(content_id) {
		
	if(wwcn_ovrlObjs[content_id]) {
		
		if(wwcn_isIE()) { scroll(0,0); }
		wwcn_EleObjs('wwcn_pageoverlaybox').className = '';
		wwcn_EleObjs('wwcn_polbcontentbox').className = '';
		wwcn_writeToLayer(wwcn_liOtablePre + wwcn_ovrlObjs[content_id].content + wwcn_liOtablePost, 'wwcn_polbcontentbox');
		wwcn_ovrlObjs[content_id].is_viewed = true;
		wwcn_ovrlObjs[content_id].pfrm_load();
						
	}

}
	
function wwcn_closeOvrLay() { wwcn_EleObjs('wwcn_polbcontentbox').className = 'wwcn_dsplynne';wwcn_EleObjs('wwcn_pageoverlaybox').className = 'wwcn_dsplynne'; }




