var confirm_txt;
var pagedisable = false;
//var site_url;

function getVideosData(pars,site_url)
{	
	if(!pagedisable){
		GetAjaxLoader('MainContent');
		url="http://"+site_url+"/media/index.php";
		var myAjax = new Ajax.Updater(
				{success: 'MainContent'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,	
					evalScripts:true,		
					onFailure: reportError
				});
	}		
}
function getMediaList(pars)
{
	if(!pagedisable){
		url="index.php";
		var myAjax = new Ajax.Updater(
				{success: 'VideosArea'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}	
}

function getallmediadata(pars,site_url)
{
	if(!pagedisable){
	GetAjaxLoader('notesDiv');
		url="http://"+site_url+"/media/index.php";
		var myAjax = new Ajax.Updater(
				{success: 'notesDiv'}, 
				url, 
				{
					method: 'get',
					parameters: pars,	 
					evalScripts:true,				
					onFailure: reportError
				});
	}
}



function showSearchForm(pars,site_url)
{	
	if(!pagedisable){
		GetAjaxLoader('SearchDiv');
		document.getElementById('SearchDiv').style.display = 'block';
		url="http://"+site_url+"/media/search.php";
		var myAjax = new Ajax.Updater(
				{success: 'SearchDiv'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,	
					evalScripts:true,			
					onFailure: reportError
				});
	}		
}

function showHeaderSearchForm(pars, siteurl)
{
	if(!pagedisable){
		GetAjaxLoader('Header_SearchDiv');
		url=siteurl;
		var myAjax = new Ajax.Updater(
				{success: 'Header_SearchDiv'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,	
					evalScripts:true,			
					onFailure: reportError
				});
	}	
}

function showCommunitySearchForm(pars)
{
	if(!pagedisable){
		url="search.php";
		var myAjax = new Ajax.Updater(
				{success: 'SearchDiv'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}	
}
function user_video_fav(div_id, pars,site_url)
{
	if(!pagedisable){
		GetAjaxLoader(div_id);
		url="http://"+site_url+"/media/user_video.php";
		var myAjax = new Ajax.Updater(
				{success: div_id}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
}
function user_video_playlist(div_id, pars,site_url)
{	
	if(!pagedisable){
		GetAjaxLoader(div_id);
		url="http://"+site_url+"/media/user_video.php";
		var myAjax = new Ajax.Updater(
				{success: div_id}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
}

function user_video_rate(pars,site_url)
{
	if(!pagedisable){
		GetAjaxLoader('list_rating');
		url="http://"+site_url+"/media/user_video.php";
		var myAjax = new Ajax.Updater(
				{success: 'list_rating'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
}
function getNotesList(pars,site_url)
{
	if(!pagedisable){
		GetAjaxLoader('notesDiv');
		url="http://"+site_url+"/media/notes.php";
		var myAjax = new Ajax.Updater(
				{success: 'notesDiv'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
}
function getsearchNotesList(pars, site_url)
{
	if(!pagedisable){
		GetAjaxLoader('searchnoteDiv');
		url="http://"+site_url+"/media/user_notes.php";
		var myAjax = new Ajax.Updater(
				{success: 'searchnoteDiv'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
}
function getsearchtagsList(pars)
{
	if(!pagedisable){
		GetAjaxLoader('searchtagDiv');
		url="search_tags.php";
		var myAjax = new Ajax.Updater(
				{success: 'searchtagDiv'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
}

function getSearchResult(pars,site_url)
{	
	if(!pagedisable){
		GetAjaxLoader('MainContent');
		url="http://"+site_url+"/media/user_notes.php";
		var myAjax = new Ajax.Updater(
				{success: 'MainContent'}, 
				url, 
				{
					method: 'post', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
}
function add_notes(pars,site_url)
{
	if(!pagedisable){
		GetAjaxLoader('addnotesDiv');
		url="http://"+site_url+"/media/user_notes.php?mode=add";
		var myAjax = new Ajax.Updater(
				{success: 'addnotesDiv'}, 
				url, 
				{
					method: 'post', 
					parameters: pars,	
					evalScripts:true,			
					onFailure: reportError
				});
	}
}

function delete_notes(pars,site_url)
{
	if(!pagedisable){
		GetAjaxLoader('addnotesDiv');
		url="http://"+site_url+"/media/user_notes.php";
		var myAjax = new Ajax.Updater(
				{success: 'addnotesDiv'}, 
				url, 
				{
					method: 'post', 
					parameters: pars,	
					evalScripts:true,			
					onFailure: reportError
				});
	}
}

function confirm_delete(pars,site_url)
{
	if(!pagedisable){
		var ans=confirm(confirm_txt);
		if(ans==true)
			delete_notes(pars,site_url);
		else
			return false;
	}
}
						
function reportError(originalRequest)
{
	alert('Error in processing your request!');
}

//for submitting the notes
function submitNotes(imagename,site_url)
{
	if(!pagedisable){
		var i = document.getElementById('submit_img');
		i.innerHTML = "";
		add_notes($('addnote').serialize(),site_url);
	}	
}
//for submitting the notes search
function submitNotesSearch(site_url)
{
	if(!pagedisable){
		getSearchResult($('searchnotes').serialize(),site_url);
	}
}

function submit_key(site_url)
{
	if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){
		if(event.keyCode==13)
		{
			
			if(!pagedisable){
			getVideosData($('searchform').serialize(),site_url);
			}
		}
	}
}

function submitSearch(site_url)
{
	if(!pagedisable){
		getVideosData($('searchform').serialize(),site_url);
	}
}

function submitHeaderSearch()
{
	document.search_header_form.submit();
}

function enable_disable(cur_checkbox)
{		
		
		var form = $('searchform');	
		var checkboxes = [];	
		var checked_flag=0;
		var media_ctr = 1;
		
		checkboxes = $$('input').each(function(e){ if(e.type == 'checkbox' && e.name!='medias[]') checkboxes.push(e);
		
			if(e.name=='medias[]' && e.checked==true && media_ctr==1){			
				checked_flag=1;
			}
			media_ctr++;
		 });
		
		checkboxes = form.getInputs('checkbox');	
		
		checkboxes.each(function(e){
			if($(cur_checkbox).checked==true)
			{
				e.enable();
			}
			else if(checked_flag==0)
			{	
				//e.disable();
				if(e.name=='gametypes[]')
					e.disable();
				if(e.name=='game[]')
					e.disable();
				if(e.name=='sizes[]')
					e.disable();
				if(e.name=='stakes[]')
					e.disable();
				if(e.name=='formats[]')
					e.disable();			
			}
				 });
}

function header_enable_disable(cur_checkbox)
{	
	if(!pagedisable){
		var form = $('search_header_form');	
		var checkboxes = [];	
		var checked_flag=0;
		var media_ctr = 1;
		
		checkboxes = $$('input').each(function(e){ if(e.type == 'checkbox' && e.name!='header_medias[]') checkboxes.push(e);
		
			if(e.name=='header_medias[]' && e.checked==true && media_ctr==1){			
				checked_flag=1;
			}
			media_ctr++;
		 });
		 
		//alert(checked_flag);
		
		checkboxes = form.getInputs('checkbox');
		
		checkboxes.each(function(e){
			if($(cur_checkbox).checked==true)
			{
				e.enable();
				//alert(e.enable());
				//$('h_txt_instructor').enable();
				//$('h_sel_instructor').enable();
			}
			else
			if(e.name!='medias[]' && checked_flag==0)
			{
				
				//e.disable();
				if(e.name=='gametypes[]')
					e.disable();
				if(e.name=='game[]')
					e.disable();
				if(e.name=='sizes[]')
					e.disable();
				if(e.name=='stakes[]')
					e.disable();
				if(e.name=='formats[]')
					e.disable();		
				//$('h_txt_instructor').disable();
				//$('h_sel_instructor').disable();
			}
				 });
	}
}

function getVideo(pars, imagename,desc_show,site_url)
{	
	if(!pagedisable){
		url="http://"+site_url+"/media/video.php";
		var myAjax = new Ajax.Updater(
				{success: 'VideoBlock'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,								
					onFailure: reportError
				});	 
	}  
	if(desc_show=="1")
		getDiscussion(pars,site_url);
}

function getPlayer(pars,site_url)
{	
	GetAjaxLoader('VideoBlock');
	url="http://"+site_url+"/media/video.php";
	var myAjax = new Ajax.Updater(
			{success: 'VideoBlock'}, 
			url, 
			{
				method: 'get', 
				parameters: pars,
				evalScripts:true,								
				onFailure: reportError
			});	
}

function getSeries(pars,site_url)
{
		//GetAjaxLoader('series_parentblock');
		url="http://"+site_url+"/media/listing.php";
		var myAjax = new Ajax.Updater(
				{success: 'series_parentblock'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,	
					evalScripts:true,			
					onFailure: reportError
				});
}
function callattach()
{	
	if(!pagedisable){
		at_attach("sample_attach_menu_parent", "sample_attach_menu_child", "hover", "y", "pointer");
	}
}
function callattachs()
{	
	if(!pagedisable){
		at_attach("sample_attach_menu_parents", "sample_attach_menu_child", "hover", "y", "pointer");
	}
}

function attachCoachChild()
{	
	if(!pagedisable){
		at_attach("menu_coach_parent", "coach_menu_child", "hover", "y", "pointer");
	}
}

function attachListChild()
{
	if(!pagedisable){
		at_attach("list_menu_parent", "list_menu_child", "hover", "y", "pointer");
	}
}

function attachShoveChild()
{
	if(!pagedisable){
		at_attach("menu_shove_parent", "shove_menu_child", "hover", "y", "pointer");
	}
}

function attachShoveChild_shove(menu_shove_parent,shove_menu_child)
{
	if(!pagedisable){
		at_attach(menu_shove_parent, shove_menu_child, "hover", "y", "pointer");
	}
}

function callnotes_sort()
{
	if(!pagedisable){
		at_attach("sample_attach_menu_parent1", "sample_attach_menu_child1", "hover", "y", "pointer");
	}
}

function calldiscussion_sort()
{
	if(!pagedisable){
		at_attach_discussion("sample_attach_menu_parent1", "sample_attach_menu_child1", "hover", "y", "pointer");
	}
}

function image_attach()
{
	if(!pagedisable){
		image_at_attach("image_parent", "image_child", "hover", "y", "pointer");
	}
}
function addVideoAlert(pars)
{
	if(!pagedisable){
		GetAjaxLoader('VideoAlert');
		url="user_video.php";
		var myAjax = new Ajax.Updater(
				{success: 'VideoAlert'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}	   
}

function AjaxMediaListing(pars, ajaxPage, divid, showflag, mediaflag, sortby, sortorder,site_url){
	
	if(!pagedisable){
		GetAjaxLoader(divid);
		pars="page="+ajaxPage;
		url="http://"+site_url+"/media/listing.php?showflag="+showflag+"&medias[]="+mediaflag+"&page="+ajaxPage+"&orderby="+sortby+"&sortorder="+sortorder;  
		var myAjax = new Ajax.Updater(
				{success: divid}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
}
 
function showlist(pars,site_url)
{
	if(!pagedisable){
		GetAjaxLoader("showblock");
		url="http://"+site_url+"/media/listing.php";
		var myAjax = new Ajax.Updater(
				{success: 'showblock'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});	
		
		url="http://"+site_url+"/media/list_icon_link.php";
		var myAjax1 = new Ajax.Updater(
				{success: 'linkblock'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
}

function collapse_list(collapseid, listid, divflag,site_url)
{
	if(!pagedisable){
		GetAjaxLoader(collapseid);	
	 	var divflag;
	 	var newflag;
	 	if(divflag==0)
	 		newflag=1;
	 	else
	 		newflag = 0;
	 	url = "http://"+site_url+"/media/collapse_list.php?divflag="+divflag;
	 	new Ajax.Request(url, 
			{  
				method: 'get',   
				onSuccess:
				function(transport)
				{   
					var p = document.getElementById(collapseid);
					var str = "<a href='javascript:void(0)' onClick=javascript:collapse_list('"+collapseid+"','"+listid+"','"+newflag+"','"+site_url+"')>"+transport.responseText+"</a>";
					p.innerHTML = str;
					var c = document.getElementById(listid);
					if(divflag==0){			
						c.style.visibility = "hidden";
						c.style.display = "none";
					}
					else{
						c.style.visibility = "visible";
						c.style.display = "block";
					}	
					BlockAjaxLoader();			
		   		} 
			 }); 
	}
 	
 }
function callmedia_sort_video(media_parent1, media_child1)
{
	if(!pagedisable){
		at_attach_video(media_parent1, media_child1, "hover", "y", "pointer");
	}
}
function callmedia_sort(media_parent1, media_child1)
{
	if(!pagedisable){
		at_attach(media_parent1, media_child1, "hover", "y", "pointer");
	}
}

function free_video(media_parent1, media_child1)
{
	at_attach_free_video(media_parent1, media_child1, "hover", "y", "pointer");
}
function callmedia_sort_schedule(media_parent1, media_child1)
{
	if(!pagedisable){
		at_attach_schedule(media_parent1, media_child1, "hover", "y", "pointer");
	}
}

function callmedia_sort_shove(media_parent1, media_child1)
{
	if(!pagedisable){
		at_attach_shove(media_parent1, media_child1, "hover", "y", "pointer");
	}
}

function todayfeatured_media(media_parent1, media_child1)
{
	if(!pagedisable){
		at_attach_todayschedule(media_parent1, media_child1, "hover", "y", "pointer");
	}
}

function getmediasort(pars,site_url)
{
	if(!pagedisable){
		var tmp=pars.split('&');
		var divtag = tmp[0].split('=');
		GetAjaxLoader(divtag[1]);
		url="http://"+site_url+"/media/listing.php";
		var myAjax = new Ajax.Updater(
				{success: divtag[1]}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}	
}

function quick_list(pars)
{
	if(!pagedisable){
		//GetAjaxLoader('quickhit');
		url="index.php";
		var myAjax = new Ajax.Updater(
				{success: 'quickhit'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}	
}

function getmediatabs(pars,site_url)
{
		GetAjaxLoader('tab');
		url="http://"+site_url+"/media/media_tabs.php";
		var myAjax = new Ajax.Updater(
				{success: 'tab'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
}

function getCommunityData(pars)
{
	if(!pagedisable){
		GetAjaxLoader('MainContent');
		url="index.php";
		var myAjax = new Ajax.Updater(
				{success: 'MainContent'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,	
					evalScripts:true,			
					onFailure: reportError
				});
	}		
}

function SubmitCommunitySearch()
{
	if(!pagedisable){
		getCommunityData($('searchform').serialize());
		//alert($('searchform').serialize());
	}
}

function getdel_tag(txt)
{	
	confirm_txt = txt;
}

function call_search(media_parent1, media_child1)
{	
	if(!pagedisable){
		search_at_attach(media_parent1, media_child1, "click", "y", "pointer");
	}
}
function community_call_search(media_parent1, media_child1)
{	
	if(!pagedisable){
		community_search_at_attach(media_parent1, media_child1, "click", "y", "pointer");
	}
}

function openFlash(v, u, d, t,site_url, videoflag)
{
	if(!pagedisable){
		var url;
		myurl = "http://"+site_url+"/media/download_video.php?video_id=" + v + "&uid=" + u + "&demo=" + d + "&type=" + t + "&videoflag=" + videoflag;
		window.open (myurl, "flashvideo", "resizable=1,location=0,status=0,scrollbars=0,width=385,height=405");
	}
}

function user_next_schedule(div_id,pars,site_url)
{	
	if(!pagedisable){
		url="http://"+site_url+"/community/schedule.php";
		var myAjax = new Ajax.Updater(
				{success: div_id}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}		
}

function open_notes_tags(site_url)
{
	if(!pagedisable){
		var url;
		myurl = "http://"+site_url+"/media/popup_notes_tags.php";
		window.open (myurl, "notes_tags", "resizable=1,location=0,status=0,scrollbars=1,width=450,height=400");
	}
}

function user_article_rate(pars,site_url)
{	
	if(!pagedisable){
		GetAjaxLoader('art_list_rating');
		url="http://"+site_url+"/media/user_article.php";
		var myAjax = new Ajax.Updater(
				{success: 'art_list_rating'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,	
					evalScripts:true,			
					onFailure: reportError
				});
	}
}
//for adding article comments
function add_comments(pars,site_url)
{
	if(!pagedisable){
		GetAjaxLoader('addcomment');
		
		url="http://"+site_url+"/media/user_article_comments.php";
		var myAjax = new Ajax.Updater(
				{success: 'addcommentsDiv'}, 
				url, 
				{
					method: 'post', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
}

//for submitting the article comments
function submitComments(imagename,site_url)
{
	if(!pagedisable){
		var i = document.getElementById('img_submit');
		i.innerHTML = "";
		add_comments($('addcomment').serialize(),site_url);	
		//alert($('addcomment').serialize());	
	}
}

function AjaxCommentsListing(pars, ajaxPage, divid, articleid, mediaflag, sortby, sortorder){
	if(!pagedisable){
		GetAjaxLoader(divid);
		url="../../../media/comments_listing.php?page="+ajaxPage+"&articleid="+articleid;  
		var myAjax = new Ajax.Updater(
				{success: divid}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
}

function unsubscribe_email_alert(pars)
{
	if(!pagedisable){
		GetAjaxLoader('subscription_flag');
		url="../unsubscribe_email_alerts.php";
		var myAjax = new Ajax.Updater(
				{success: 'subscription_flag'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,	
					evalScripts:true,			
					onFailure: reportError
				});
	}
}

function user_latest_media(div_id,pars)
{	
	if(!pagedisable){
		GetAjaxLoader(div_id);
		url="latest_media.php";
		var myAjax = new Ajax.Updater(
				{success: div_id}, 
				url, 
				{
					method: 'get', 
					parameters: pars,	
					evalScripts:true,			
					onFailure: reportError
				});
	}
}
function AjaxCommunityListing(pars, ajaxPage, divid, showflag, mediaflag, sortby, sortorder){
	if(!pagedisable){
		GetAjaxLoader(divid);
		pars="page="+ajaxPage;
		url="latest_media.php?show_schedule="+showflag+"&page="+ajaxPage+"&mediaflag="+mediaflag+"&orderby="+sortby+"&sortorder="+sortorder;  
		var myAjax = new Ajax.Updater(
				{success: divid}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
 }
 
function GetLatestMediaSort(pars)
{
	if(!pagedisable){
		var tmp=pars.split('&');
		var divtag = tmp[0].split('=');
		GetAjaxLoader(divtag[1]);
		url="latest_media.php";
		var myAjax = new Ajax.Updater(
				{success: divtag[1]}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}		
}

function GetAjaxLoader(ajaxdivid)
{	
	var b = document.getElementById('notesDiv');
	if(ajaxdivid=='tab'){
		var i = document.getElementById('VideoBlock');
	}
	else
		var i = document.getElementById(ajaxdivid);
		
	var a = document.getElementById('ajax_loading');
	var l = document.getElementById('LeftPanel');
	
	var top  = (a["at_position"] == "y") ? i.offsetHeight+0 : 0;
  	var left = (a["at_position"] == "x") ? i.offsetWidth +2 : 10;
		
	if(ajaxdivid=='tab')
	{
		var blockheight = i.offsetHeight;
		var blockwidth  = i.offsetWidth;
		if(blockheight=='0')
			pos_y = findPosX(i)+200;
		else	
			pos_y = (blockheight-50) / 2;
		
		pos_x = (blockwidth-50) / 2;
	}
	else
	{	
		pos_x = findPosX(l);
		pos_y = findPosX(i);
	}
	for (; i; i = i.offsetParent)
	{
	 top  += i.offsetTop;
	 left += i.offsetLeft;
	}
	
	if(ajaxdivid=='tab'){
		left = pos_x;
		top = pos_y;  
	}
	else
	{
		left = pos_x + 500;
		top = top + 100;  
	}
	
	if(pos_y<=0)
		top = 200;  
		
    a.style.position   = "absolute";
    a.style.top        = top +'px';
    a.style.left       = left+'px';	
	a.style.visibility= "visible";
	a.style.display = "block";	
	
	//b.style.backgroundColor='gray';
	b.style.filter='alpha(opacity=50)'; /* IE */
	b.style.opacity='0.5'; /* Safari, Opera */
	b.style.MozOpacity='0.50'; /* FireFox */
	b.style.zIndex= '20';
	b.disabled = true;
	pagedisable = true;

	
}

function BlockAjaxLoader()
{
	var a = document.getElementById("ajax_loading");
	var b = document.getElementById('notesDiv');
	if(b!=null){
		a.style.visibility= "hidden";
		a.style.display = "none";
		//b.style.backgroundColor='white';
		b.style.filter='alpha(opacity=110)';
		b.style.opacity='1'; /* Safari, Opera */
		b.style.MozOpacity='1'; /* FireFox */
		b.disabled = false;
		pagedisable = false;
	}
}

function course_days_record(div_id,pars)
{	
	if(!pagedisable){
		GetAjaxLoader(div_id);
		url="courses_details.php";
		var myAjax = new Ajax.Updater(
				{success: div_id}, 
				url, 
				{
					method: 'get', 
					parameters: pars,	
					evalScripts:true,			
					onFailure: reportError
				});
	}
}

function getRelatedContent(pars,site_url)
{
	if(!pagedisable){
		GetAjaxLoader('notesDiv');
		url="http://"+site_url+"/media/related_content.php";
		var myAjax = new Ajax.Updater(
				{success: 'notesDiv'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
}

function getarticlesearch(pars, site_url)
{
	if(!pagedisable){
		GetAjaxLoader('MainContent');
		url="http://"+site_url+"/media/article_search.php";
		var myAjax = new Ajax.Updater(
				{success: 'MainContent'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
}

function showcategory(pars, site_url)
{
	if(!pagedisable){
		GetAjaxLoader('MainContent');
		url="http://"+site_url+"/media/article_search.php";
		var myAjax = new Ajax.Updater(
				{success: 'MainContent'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
}
function user_affiliate_banner(div_id,pars)
{	
	if(!pagedisable){
		GetAjaxLoader(div_id);
		url="affiliate_banner.php";
		var myAjax = new Ajax.Updater(
				{success: div_id}, 
				url, 
				{
					method: 'get', 
					parameters: pars,	
					evalScripts:true,			
					onFailure: reportError
				});
	}
}
function AjaxbannerListing(pars, ajaxPage, divid, show_banner){
	if(!pagedisable){
		GetAjaxLoader(divid);
		pars="page="+ajaxPage;
		url="affiliate_banner.php?show_banner="+show_banner+"&page="+ajaxPage;  
		var myAjax = new Ajax.Updater(
				{success: divid}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
 }
 
 function AjaxshoveListing(pars, ajaxPage, divid, show_banner){
	if(!pagedisable){
		GetAjaxLoader(divid);
		pars="page="+ajaxPage;
		url="index.php?show_banner="+show_banner+"&page="+ajaxPage;  
		var myAjax = new Ajax.Updater(
				{success: divid}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
	
 }
 
 function AjaxshovedetailsListing(pars, ajaxPage, divid, show_banner,id){
	if(!pagedisable){
		GetAjaxLoader(divid);
		pars="page="+ajaxPage;
		url="index.php?show_banner="+show_banner+"&page="+ajaxPage+"&id="+id;  
		var myAjax = new Ajax.Updater(
				{success: divid}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
	
 }
 
function getDiscussion(pars,site_url)
{
	if(!pagedisable){
		GetAjaxLoader('notesDiv');
		url="http://"+site_url+"/media/discussion.php";
		var myAjax = new Ajax.Updater(
				{success: 'notesDiv'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
}

function AjaxforumCommentsListing(pars, ajaxPage, divid, videoid, mediaflag, sortby, sortorder,site_url){
	if(!pagedisable){
		GetAjaxLoader(divid);
		url="http://"+site_url+"/media/forum_post_comments.php?page="+ajaxPage+"&video_id="+videoid+"&sortorder="+sortorder;  
		var myAjax = new Ajax.Updater(
				{success: divid}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
}

function getSortList(pars,site_url)
{
	if(!pagedisable){
		GetAjaxLoader('comments_block');
		url="http://"+site_url+"/media/forum_post_comments.php";
		var myAjax = new Ajax.Updater(
				{success: 'comments_block'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
}


//for submitting the forum post comments
function submitPostComments(imagename,site_url)
{
	if(!pagedisable){
		var i = document.getElementById('img_submit');
		i.innerHTML = "";
		add_forum_comments($('addcomment').serialize(),site_url);
	}
}

//for adding forum post comments
function add_forum_comments(pars,site_url)
{
	if(!pagedisable){
		GetAjaxLoader('addcomment');
		url="http://"+site_url+"/media/user_forum_post_comments.php";		
		var myAjax = new Ajax.Updater(
				{success: 'addcommentsDiv'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
}

//for edit forum post comments
function edit_comments(site_url,flag,parentid,videoid)
{
	if(!pagedisable){
		GetAjaxLoader('newcomm');
		url="http://"+site_url+"/media/user_edit_forum_post_comments.php?video_id="+videoid+"&postid="+parentid+"&flag="+flag;		
		var myAjax = new Ajax.Updater(
				{success: 'newcomm'}, 
				url, 
				{
					method: 'get', 
					evalScripts:true,				
					onFailure: reportError
				});
	}
}
function add_newpost_comments(site_url,flag,parentid,videoid)
{
	
	if(!pagedisable){
		GetAjaxLoader('newcomm');
		url="http://"+site_url+"/media/add_replyquote.php?video_id="+videoid+"&parent_id="+parentid+"&flag="+flag;
		var myAjax = new Ajax.Updater(
				{success: 'newcomm'}, 
				url, 
				{
					method: 'get', 
					evalScripts:true,				
					onFailure: reportError
				});
	}
	//setparentvalue(parentid,videoid);
}

function add_newarticle_comments(site_url,articleid)
{
	
	if(!pagedisable){
		GetAjaxLoader('newarticlecomm');
		url="http://"+site_url+"/media/articlecomment.php?article_id="+articleid;
		var myAjax = new Ajax.Updater(
				{success: 'newarticlecomm'}, 
				url, 
				{
					method: 'get', 
					evalScripts:true,				
					onFailure: reportError
				});
	}
	//setparentvalue(parentid,videoid);
}
function chat_window(pars)
{
		var mychaturl;
		mychaturl = "http://"+pars+"/chat/index.php";
		window.open (mychaturl, "mychatwindow", "resizable=1,location=0,status=0,scrollbars=0,width=762,height=573");
}
function print_article_window(pars,articleid)
{
		var myarticleurl;
		mychaturl = "http://"+pars+"/media/printarticle/"+articleid;
		window.open (mychaturl, "mychatwindow", "resizable=1,location=0,status=0,scrollbars=1,width=635,height=478");
}

function email_article_window(pars,articleid)
{		
		var myarticleurl;
		mychaturl = "http://"+pars+"/media/emailarticle/"+articleid;
		window.open (mychaturl, "mychatwindow", "resizable=1,location=0,status=0,scrollbars=1,width=635,height=250");
}
function attachdownloadmenu()
{	
	if(!pagedisable){
		at_attach("download_menu_parent", "download_menu_child", "hover", "y", "pointer");
	}
}

var popUp = 0;
var popURL = 0;
var popWidth = 0;
var popHeight = 0;

var thisMargin = 10;

var popTopPosition = 23;
var popLeftPosition = 430;

var pause = 20;
var step = 10;	// The higher the number, the faster the window.
var timer = 0;

var screenWidth = 0;
var screenHeight = 0;

var endX = 0;
var endY = 0;

function coaches_bio(pars,authorid,flag,coachname,height)
{	
		var mycoachbiourl;
		mycoachbiourl = "http://"+pars+"/media/coachbio/"+authorid+"/"+coachname;
		
		if(flag==1){
			thiswidth='488';
			popUp = window.open (mycoachbiourl, "mychatwindow", "resizable=0,location=0,toolbar=0,status=0, width=488,height="+height+",left=430,top=23, resizable=yes,scrollbars=yes");
		}
		else
		{
			thiswidth='657';
			popUp = window.open (mycoachbiourl, "mychatwindow", "resizable=0,location=0,toolbar=0,status=0, width=657,height="+height+",left=430,top=23, resizable=yes,scrollbars=yes");
		}
		screenWidth = window.screen.width;
		screenHeight = window.screen.height;
		endX = screenWidth - thiswidth - thisMargin;
		endY = screenHeight - height - thisMargin;
		moveup();
			
}

function movedown() {
	if (popTopPosition <= endY - 50) {
		popUp.moveTo(popLeftPosition,popTopPosition);
		popTopPosition += step;
		timer = setTimeout("movedown()",pause);
	}
	else {
		clearTimeout(timer);
		popTopPosition = endY - 50;
		popUp.moveTo(popLeftPosition,popTopPosition);
		moveright();
	}
}

function moveright() {
	if (popLeftPosition <= endX) {
		popUp.moveTo(popLeftPosition,popTopPosition);
		popLeftPosition += step;
		timer = setTimeout("moveright()",pause);
	}
	else {
		clearTimeout(timer);
		popLeftPosition = endX;
		popUp.moveTo(popLeftPosition,popTopPosition);
		moveup();
	}
}

function moveup() {
	if (popTopPosition >= thisMargin) {
		popUp.moveTo(popLeftPosition,popTopPosition);
		popTopPosition -= step;
		timer = setTimeout("moveup()",pause);
	}
	else {
		clearTimeout(timer);
		popTopPosition = thisMargin;
		popUp.moveTo(popLeftPosition,popTopPosition);
		//moveleft();
	}
}

function moveleft() {
	if (popLeftPosition >= thisMargin) {
		popUp.moveTo(popLeftPosition,popTopPosition);
		popLeftPosition -= step;
		timer = setTimeout("moveleft()",pause);
	}
	else {
		clearTimeout(timer);
		popLeftPosition = thisMargin;
		popUp.moveTo(popLeftPosition,popTopPosition);
	}
}

//for submitting the tag search
function submitTagSearch()
{
	if(!pagedisable){
		getSearchTagResult($('searchtags').serialize());
	}
}

function getSearchTagResult(pars)
{
	if(!pagedisable){
		GetAjaxLoader('SearchContent');
		url="ajax_search_tags.php";
		var myAjax = new Ajax.Updater(
				{success: 'SearchContent'}, 
				url, 
				{
					method: 'post', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
}

function call_loginscreen(media_parent1, media_child1)
{
	if(!pagedisable){
		login_at_attach(media_parent1, media_child1, "click", "y", "pointer");
	}
}

//for submitting the notes
function submitLogin(url)
{
	Login_box1($('new_login').serialize(), url);
}

function close_login_box()
{
	var a  = document.getElementById('Header_loginDiv');
	//a.onclick  = login_at_hide;
	a.style.visibility = "hidden";
	a.style.display = "none";
}

function open_Account_Menu()
{
	var div = document.getElementById('Header_Account_MenuDiv');
	div.style.visibility = "visible";
	div.style.display = "block";
}

function close_Account_Menu()
{
	var div = document.getElementById('Header_Account_MenuDiv');
	div.style.visibility = "hidden";
	div.style.display = "none";
}

function open_my_tags(pars)
{
	if(!pagedisable){
		GetAjaxLoader('notesDiv');
		url=pars;
		var myAjax = new Ajax.Updater(
				{success: 'openDivTag'}, 
				url, 
				{
					method: 'post', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}	
}

function close_search_box()
{
	var a  = document.getElementById('Header_SearchDiv');
	//a.onclick  = search_at_hide;
	a.style.visibility = "hidden";
	a.style.display = "none";
}

function Login_box1(pars, siteurl)
{
	url=siteurl;
	new Ajax.Updater('loginarea',url, 
	{
		asynchronous:true,		
		evalScripts:true,
		parameters: pars,
		requestHeaders:['X-Update', 'ajax'],				
		onComplete:showLoginResponse
	});
}

function showLoginResponse(originalRequest) {
   	var tmp = originalRequest.responseText.split('|');	
    if(tmp[0]=='INACTIVE'){
    	var a  = document.getElementById('loginarea');
    	a.style.visibility = "hidden";
    	a.style.display = "none";
    	document.location.href=tmp[1];
    	tmp="";
    }
    
    if(tmp[0]=='SUCCESS'){
    	var a  = document.getElementById('loginarea');
    	a.style.visibility = "hidden";
    	a.style.display = "none";
    	document.location.href=tmp[1];
    	tmp="";
    }
    if(tmp[0]=='ERROR'){
    	$('loginarea').innerHTML = tmp[1];
   	}
   	
}
function user_video_shove(div_id,pars)
{
	if(!pagedisable){
		GetAjaxLoader(div_id);
		url="../shove/add_shove.php";
		var myAjax = new Ajax.Updater(
				{success: div_id}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
	
}
function quate_article(media_parent1, media_child1)
{
	at_attach_quate_article(media_parent1, media_child1, "hover", "y", "pointer");
}
function showalltags()
{
	if(!pagedisable){
		GetAjaxLoader("Block1");
		url="ajax_search_tags.php";
		var myAjax = new Ajax.Updater(
				{success: 'SearchContent'}, 
				url, 
				{
					method: 'get', 
					evalScripts:true,				
					onFailure: reportError
				});	
	}
}

function AjaxTagListing(pars, ajaxPage, divid, showflag, mediaflag, sortby, sortorder){
	if(!pagedisable){
		GetAjaxLoader(divid);
		pars="page="+ajaxPage;
		url="ajax_search_tags.php?searchstag="+showflag+"&medias[]="+mediaflag+"&page="+ajaxPage+"&orderby="+sortby+"&sortorder="+sortorder;  
		var myAjax = new Ajax.Updater(
				{success: divid}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
}

function coach_popup(media_parent1, media_child1)
{
	at_attach_coach_popup(media_parent1, media_child1, "hover", "y", "pointer");
}

function replyfocus(){
	self.scrollTo(0,500);
	document.getElementById('comments').focus();	
}

function quotereply(divid)
{
	var old2 = document.discuss_timeval.olddiv.value; 
	if(old2!=''){
		var b = document.getElementById(old2);
		b.style.border = 'none';
	}
	
	var a = document.getElementById(divid);
	if(a!=''){
		a.style.border = 'solid 2px #AD0000';
		a.style.padding = '0px 0px 0px 33px';
		a.style.margin  = '0px 1px 0px -38px';
	}	
	document.discuss_timeval.olddiv.value=divid;
}

function showrelatelist(pars,site_url)
{
	if(!pagedisable){
		GetAjaxLoader("showblock");
		url="http://"+site_url+"/media/related_content_listing.php";
		var myAjax = new Ajax.Updater(
				{success: 'showblock'}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});	
	}
}
function shovearticle(site_url,articleid,type)
{
	if(!pagedisable){
		url="http://"+site_url+"/shove/add_shove.php?media_id="+articleid+"&type="+type;
		var myAjax = new Ajax.Updater(
				{success: 'shove_menu_child'}, 
				url, 
				{
					method: 'get', 
					evalScripts:true,				
					onFailure: reportError
				});
	}	
}

function tag_hover(media_parent1, media_child1)
{
 	at_attach_tag_statement(media_parent1, media_child1, "hover", "y", "pointer");
}

function tag_hover_header(media_parent2, media_child2)
{
 	at_attach_tag_header_statement(media_parent2, media_child2, "hover", "y", "pointer");
}

function add_newnote(pars,site_url,videoid)
{
	if(!pagedisable){
		GetAjaxLoader('newnotes');
		url="http://"+site_url+"/media/add_note.php?video_id="+videoid+"&mode=add";
		var myAjax = new Ajax.Updater(
				{success: 'newnotes'}, 
				url, 
				{
					method: 'get',
					parameters: pars, 
					evalScripts:true,				
					onFailure: reportError
				});
	}
}

/*script.js code*/


// Copyright (C) 2005-2008 Ilya S. Lyubinskiy. All rights reserved.
// Technical support: http://www.php-development.ru/
//
// YOU MAY NOT
// (1) Remove or modify this copyright notice.
// (2) Re-distribute this code or any part of it.
//     Instead, you may link to the homepage of this code:
//     http://www.php-development.ru/javascripts/dropdown.php
//
// YOU MAY
// (1) Use this code on your website.
// (2) Use this code as part of another product.
//
// NO WARRANTY
// This code is provided "as is" without warranty of any kind.
// You expressly acknowledge and agree that use of this code is at your own risk.


// ***** Popup Control *********************************************************

// ***** at_show_aux *****

function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+0 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 10;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }
  
  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}
function at_discussion_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+0 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 10;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }
  top = top + 22;
  left = left - 50;
  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// ***** at_show *****

function at_show()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  at_show_aux(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}
function at_show_discuss()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  at_discussion_show_aux(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}

// ***** at_hide *****

function at_hide()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);
}

// ***** at_click *****

function at_click()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") at_show_aux(p.id, c.id); else c.style.visibility = "hidden";
  return false;
}
function at_click_discussion()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") at_discussion_show_aux(p.id, c.id); else c.style.visibility = "hidden";
  return false;
}

// ***** at_attach *****

// PARAMETERS:
// parent   - id of the parent html element
// child    - id of the child  html element that should be droped down
// showtype - "click" = drop down child html element on mouse click
//            "hover" = drop down child html element on mouse over
// position - "x" = display the child html element to the right
//            "y" = display the child html element below
// cursor   - omit to use default cursor or specify CSS cursor name

function at_attach(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);
  
  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  at_show_aux(p.id, c.id);
  c.style.position   = "absolute";
  c.style.visibility = "visible";
  c.style.display = "block";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_click;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
    case "hover":
      p.onmouseover = at_show;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
  }
}
function at_attach_discussion(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);
  
  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  at_discussion_show_aux(p.id, c.id);
  c.style.position   = "absolute";
  c.style.visibility = "visible";
  c.style.display = "block";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_click_discuss;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show_discuss;
      c.onmouseout  = at_hide;
      break;
    case "hover":
      p.onmouseover = at_show_discuss;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show_discuss;
      c.onmouseout  = at_hide;
      break;
  }
}

function CheckPrivateMessage(pars,priv_msg){
	pars="priv_msg="+priv_msg;
   	url=url_pm_alert+"pm_alert.php";
   //alert("hi");
	var myAjax = new Ajax.Updater(
			{success: 'pm_Area'}, 
			url, 
			{
				method: 'get', 
				parameters: pars,
				evalScripts:true,				
				onFailure: reportError
			});
			
 }
 
 
function PrivateMessageUpdate() {
      new PeriodicalExecuter(CheckPrivateMessage, 60);
}


function myPopupRelocate_2() {
	 var scrolledX, scrolledY;
	 if( self.pageYOffset ) {
		   scrolledX = self.pageXOffset;
		   scrolledY = self.pageYOffset;
	 } 
	 else if( document.documentElement && document.documentElement.scrollTop ) {
		   scrolledX = document.documentElement.scrollLeft;
		   scrolledY = document.documentElement.scrollTop;
	 } 
	 else if( document.body ) {
		   scrolledX = document.body.scrollLeft;
		   scrolledY = document.body.scrollTop;
 	 }

 // We just add the scrolled amount to 5 (the desired padding)
 // to find the new coordinates

	 var leftOffset = scrolledX + 5;
	 var topOffset = scrolledY + 5;
	
	 document.getElementById("pm_Area").style.top = topOffset + "px";
	 document.getElementById("pm_Area").style.left = leftOffset + "px";
}

function turnoff_PMAlert(pars){
	//alert(pars);
	url=url_pm_alert+"pm_alert.php";
	var myAjax = new Ajax.Updater(
			{success: 'pm_Area'}, 
			url, 
			{
				method: 'get', 
				parameters: pars,				
				onFailure: reportError
			});
			
	
}

function turnoff_readmessages(pars,path){
	
	/*url=url_pm_alert+"pm_alert.php";
	var myAjax = new Ajax.Updater(
			{success: 'pm_Area'}, 
			url, 
			{
				method: 'get', 
				parameters: pars,				
				onFailure: reportError
			});
	document.getElementById("pm_Area").style.display = "none";
	*/
	window.parent.location="http://"+path+"/private.php";
}

function reportError(originalRequest)
{
	alert('Error in processing your request!');
}

function search_at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );
  pos_x = findPosX(p);
	
  var top  = (c["at_position"] == "y") ? p.offsetHeight+0 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 10;
	
  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    //left += p.offsetLeft;
  }

  //substracting the width of the search div from the x position of search link and adding pixels
  left = pos_x-700+10;
  top = top + 10;  
  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// ***** at_show *****

function search_at_show()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  search_at_show_aux(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}

// ***** at_hide *****

function search_at_hide()
{	
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);
 
}

// ***** at_click *****

function search_at_click()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") search_at_show_aux(p.id, c.id); else c.style.visibility = "hidden";
  return false;
}

// ***** at_attach *****

// PARAMETERS:
// parent   - id of the parent html element
// child    - id of the child  html element that should be droped down
// showtype - "click" = drop down child html element on mouse click
//            "hover" = drop down child html element on mouse over
// position - "x" = display the child html element to the right
//            "y" = display the child html element below
// cursor   - omit to use default cursor or specify CSS cursor name

function search_at_attach(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  search_at_show_aux(p.id, c.id);
  c.style.position   = "absolute";
  c.style.visibility = "visible";
  c.style.display = "block";
	
  if (cursor != undefined) p.style.cursor = cursor;

  /* not being used  
  switch (showtype)
  {
    case "click":
      //p.onclick     = search_at_click;
      //p.onmouseout  = search_at_hide;
      //c.onmouseover = search_at_show;
     // c.onmouseout  = search_at_hide;
      break;
    case "hover":
      //p.onmouseover = search_at_show;
     // p.onmouseout  = search_at_hide;
      //c.onmouseover = search_at_show;
     // c.onmouseout  = search_at_hide;
      break;
  }*/
}

function findPosX(obj){
	var curleft = 0;
	
	if (obj.offsetParent){	
		while(1){
			curleft+=obj.offsetLeft;
			if (!obj.offsetParent){break}
			 obj=obj.offsetParent;
		 }
	
	}else if(obj.x){curleft+=obj.x}
	return curleft;
}

function findPosY(obj){
	var curtop = 0;	
	if (obj.offsetParent){	
		while(1){
			curtop+=obj.offsetTop;
			if (!obj.offsetParent){break}
			 obj=obj.offsetParent;
		 }
	}else if(obj.y){curtop+=obj.y}
	return curtop;
}

function community_search_at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );
  pos_x = findPosX(p);
	
  var top  = (c["at_position"] == "y") ? p.offsetHeight+0 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 10;
	
  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
  }

  //substracting the width of the search div from the x position of search link and adding pixels
  left = pos_x;
  top = top-10;  
  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// ***** at_show *****

function community_search_at_show()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  community_search_at_show_aux(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}


// ***** at_hide *****

function community_search_at_hide()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);
}

function community_search_at_click()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") community_search_at_show_aux(p.id, c.id); else c.style.visibility = "hidden";
  return false;
}

function community_search_at_attach(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  community_search_at_show_aux(p.id, c.id);
  c.style.position   = "absolute";
  c.style.visibility = "visible";
  c.style.display = "block";
	
  if (cursor != undefined) p.style.cursor = cursor;

  /*switch (showtype)
  {
    case "click":
      p.onclick     = community_search_at_click;
      p.onmouseout  = community_search_at_hide;
      c.onmouseover = community_search_at_show;
      c.onmouseout  = community_search_at_hide;
      break;
    case "hover":
      p.onmouseover = community_search_at_show;
      p.onmouseout  = community_search_at_hide;
      c.onmouseover = community_search_at_show;
      c.onmouseout  = community_search_at_hide;
      break;
  }*/
}

function login_at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );
  pos_x = findPosX(p);
	
  var top  = (c["at_position"] == "y") ? p.offsetHeight+0 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 10;
	
  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    //left += p.offsetLeft;
  }

  //substracting the width of the login div from the x position of login link and adding pixels
  left = pos_x-285;
  top = top + 10;  
  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// ***** at_show *****

function login_at_show()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  login_at_show_aux(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}

// ***** at_hide *****

function login_at_hide()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);
}

// ***** at_click *****

function login_at_click()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") login_at_show_aux(p.id, c.id); else c.style.visibility = "hidden";
  return false;
}

// ***** at_attach *****

// PARAMETERS:
// parent   - id of the parent html element
// child    - id of the child  html element that should be droped down
// showtype - "click" = drop down child html element on mouse click
//            "hover" = drop down child html element on mouse over
// position - "x" = display the child html element to the right
//            "y" = display the child html element below
// cursor   - omit to use default cursor or specify CSS cursor name

function login_at_attach(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  login_at_show_aux(p.id, c.id);
  c.style.position   = "absolute";
  c.style.visibility = "visible";
  c.style.display = "block";
	
  if (cursor != undefined) p.style.cursor = cursor;

  /* not being used  
  switch (showtype)
  {
    case "click":
      //p.onclick     = search_at_click;
      //p.onmouseout  = search_at_hide;
      //c.onmouseover = search_at_show;
     // c.onmouseout  = search_at_hide;
      break;
    case "hover":
      //p.onmouseover = search_at_show;
     // p.onmouseout  = search_at_hide;
      //c.onmouseover = search_at_show;
     // c.onmouseout  = search_at_hide;
      break;
  }*/
}

// ***** Popup Control for video page *********************************************************

// ***** at_show_aux *****

function at_attach_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+0 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 10;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }
  left = left+220;
  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// ***** at_show *****

function at_attach_show()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  at_attach_show_aux(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}

// ***** at_hide *****

function at_attach_hide()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);
}

// ***** at_click *****

function at_attach_click()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") at_attach_show_aux(p.id, c.id); else c.style.visibility = "hidden";
  return false;
}

// ***** at_attach *****

// PARAMETERS:
// parent   - id of the parent html element
// child    - id of the child  html element that should be droped down
// showtype - "click" = drop down child html element on mouse click
//            "hover" = drop down child html element on mouse over
// position - "x" = display the child html element to the right
//            "y" = display the child html element below
// cursor   - omit to use default cursor or specify CSS cursor name

function at_attach_video(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);
  
  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  at_attach_show_aux(p.id, c.id);
  c.style.position   = "absolute";
  c.style.visibility = "visible";
  c.style.display = "block";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_attach_click;
      p.onmouseout  = at_attach_hide;
      c.onmouseover = at_attach_show;
      c.onmouseout  = at_attach_hide;
      break;
    case "hover":
      p.onmouseover = at_attach_show;
      p.onmouseout  = at_attach_hide;
      c.onmouseover = at_attach_show;
      c.onmouseout  = at_attach_hide;
      break;
  }
}


//image_attach for media page video image

function image_at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );
  pos_x = findPosX(p);
  
  var top  = (c["at_position"] == "y") ? p.offsetHeight+0 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 10;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    //left += p.offsetLeft;
  }
  left = pos_x-405;
  top = top - 70; 
  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// ***** at_show *****

function image_at_show()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  image_at_show_aux(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}

// ***** at_hide *****

function image_at_hide()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);
}

// ***** at_click *****

function image_at_click()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") image_at_show_aux(p.id, c.id); else c.style.visibility = "hidden";
  return false;
}

// ***** at_attach *****

// PARAMETERS:
// parent   - id of the parent html element
// child    - id of the child  html element that should be droped down
// showtype - "click" = drop down child html element on mouse click
//            "hover" = drop down child html element on mouse over
// position - "x" = display the child html element to the right
//            "y" = display the child html element below
// cursor   - omit to use default cursor or specify CSS cursor name

function image_at_attach(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);
  
  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  at_show_aux(p.id, c.id);
  c.style.position   = "absolute";
  c.style.visibility = "visible";
  c.style.display = "block";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = image_at_click;
      p.onmouseout  = image_at_hide;
      c.onmouseover = image_at_show;
      c.onmouseout  = image_at_hide;
      break;
    case "hover":
      p.onmouseover = image_at_show;
      p.onmouseout  = image_at_hide;
      c.onmouseover = image_at_show;
      c.onmouseout  = image_at_hide;
      break;
  }
}

function at_attach_free_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+0 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 10;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }
  left = left+50;
  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

// ***** at_show *****

function at_attach_free_show()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  at_attach_free_show_aux(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}

// ***** at_hide *****

function at_attach_free_hide()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);
}

// ***** at_click *****

function at_attach_free_click()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") at_attach_free_show_aux(p.id, c.id); else c.style.visibility = "hidden";
  return false;
}

// ***** at_attach *****

// PARAMETERS:
// parent   - id of the parent html element
// child    - id of the child  html element that should be droped down
// showtype - "click" = drop down child html element on mouse click
//            "hover" = drop down child html element on mouse over
// position - "x" = display the child html element to the right
//            "y" = display the child html element below
// cursor   - omit to use default cursor or specify CSS cursor name

function at_attach_free_video(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);
  
  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  at_attach_free_show_aux(p.id, c.id);
  c.style.position   = "absolute";
  c.style.visibility = "visible";
  c.style.display = "block";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_attach_free_click;
      p.onmouseout  = at_attach_free_hide;
      c.onmouseover = at_attach_free_show;
      c.onmouseout  = at_attach_free_hide;
      break;
    case "hover":
      p.onmouseover = at_attach_free_show;
      p.onmouseout  = at_attach_free_hide;
      c.onmouseover = at_attach_free_show;
      c.onmouseout  = at_attach_free_hide;
      break;
  }
}

function at_attach_quate_article(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);
  
  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  at_attach_free_show_aux(p.id, c.id);
  c.style.position   = "absolute";
  c.style.visibility = "visible";
  c.style.display = "block";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_attach_free_click;
      p.onmouseout  = at_attach_free_hide;
      c.onmouseover = at_attach_free_show;
      c.onmouseout  = at_attach_free_hide;
      break;
    case "hover":
      p.onmouseout  = at_attach_free_hide;
      c.onmouseover = at_attach_free_show;
      c.onmouseout  = at_attach_free_hide;
      break;
  }
}

function at_attach_coach_popup(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);
  
  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  at_attach_free_show_aux_coach(p.id, c.id);
  c.style.position   = "absolute";
  c.style.visibility = "visible";
  c.style.display = "block";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_attach_free_click;
     // p.onmouseout  = at_attach_free_hide;
      c.onmouseover = at_attach_free_show;
     // c.onmouseout  = at_attach_free_hide;
      break;
    case "hover":
      //p.onmouseout  = at_attach_free_hide;
      c.onmouseover = at_attach_free_show__coach;
     // c.onmouseout  = at_attach_free_hide;
      break;
  }
}

function at_attach_free_show_aux_coach(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+0 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 10;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }
  
  top=300;
  
  left = left-510;
  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

function at_attach_free_show__coach()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  at_attach_free_show_aux_coach(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}

function at_attach_shove_statement(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);
  
  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  at_attach_free_show_aux_shove(p.id, c.id);
  c.style.position   = "absolute";
  c.style.visibility = "visible";
  c.style.display = "block";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_attach_free_click;
      p.onmouseout  = at_attach_free_hide;
      c.onmouseover = at_attach_free_show;
      c.onmouseout  = at_attach_free_hide;
      break;
    case "hover":
      p.onmouseout  = at_attach_free_hide;
      c.onmouseover = at_attach_free_show_shove;
      c.onmouseout  = at_attach_free_hide;
      break;
  }
}
function at_attach_free_show_aux_shove(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+0 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 10;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }
  left = left+10;
  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

function at_attach_free_show_shove()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  at_attach_free_show_aux_shove(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}
///schedule/////
function at_attach_show_aux_schedule(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+0 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 10;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }
  left = left+100;
  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}
// ***** at_show_schedule *****

function at_attach_show_schedule()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  at_attach_show_aux_schedule(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}
// ***** at_hide *****

function at_attach_hide_schedule()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);
}
// ***** at_click *****

function at_attach_click_schedule()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") at_attach_show_aux_schedule(p.id, c.id); else c.style.visibility = "hidden";
  return false;
}
function at_attach_schedule(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);
  
  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  at_attach_show_aux_schedule(p.id, c.id);
  c.style.position   = "absolute";
  c.style.visibility = "visible";
  c.style.display = "block";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_attach_click_schedule;
      p.onmouseout  = at_attach_hide_schedule;
      c.onmouseover = at_attach_show_schedule;
      c.onmouseout  = at_attach_hide_schedule;
      break;
    case "hover":
      p.onmouseover = at_attach_show_schedule;
      p.onmouseout  = at_attach_hide_schedule;
      c.onmouseover = at_attach_show_schedule;
      c.onmouseout  = at_attach_hide_schedule;
      break;
  }
}

// ***** at_click *****

function at_attach_click_shove()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") at_attach_show_aux_shove(p.id, c.id); else c.style.visibility = "hidden";
  return false;
}

function at_attach_show_aux_shove(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+0 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 10;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }
  left = left-380;
  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}
// ***** at_show_schedule *****

function at_attach_show_shove()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  at_attach_show_aux_shove(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}
// ***** at_hide *****

function at_attach_hide_shove()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);
}

function at_attach_shove(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);
  
  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  at_attach_show_aux_shove(p.id, c.id);
  c.style.position   = "absolute";
  c.style.visibility = "visible";
  c.style.display = "block";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_attach_click_shove;
      p.onmouseout  = at_attach_hide_shove;
      c.onmouseover = at_attach_show_shove;
      c.onmouseout  = at_attach_hide_shove;
      break;
    case "hover":
      p.onmouseover = at_attach_show_shove;
      p.onmouseout  = at_attach_hide_shove;
      c.onmouseover = at_attach_show_shove;
      c.onmouseout  = at_attach_hide_shove;
      break;
  }
}

function at_attach_todayschedule(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);
  
  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  at_attach_show_aux_todayschedule(p.id, c.id);
  c.style.position   = "absolute";
  c.style.visibility = "visible";
  c.style.display = "block";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_attach_click_todayschedule;
      p.onmouseout  = at_attach_hide_todayschedule;
      c.onmouseover = at_attach_show_todayschedule;
      c.onmouseout  = at_attach_hide_todayschedule;
      break;
    case "hover":
      p.onmouseover = at_attach_show_todayschedule;
      p.onmouseout  = at_attach_hide_todayschedule;
      c.onmouseover = at_attach_show_todayschedule;
      c.onmouseout  = at_attach_hide_todayschedule;
      break;
  }
}
function at_attach_show_aux_todayschedule(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+0 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 10;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }
  left = left-260;
  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

function at_attach_click_todayschedule()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") at_attach_show_aux_todayschedule(p.id, c.id); else c.style.visibility = "hidden";
  return false;
}

function at_attach_hide_todayschedule()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333);
}

function at_attach_show_todayschedule()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  at_attach_show_aux_todayschedule(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}

function at_attach_tag_statement(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);
  
  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  at_attach_free_show_aux_tag(p.id, c.id);
  c.style.position   = "absolute";
  c.style.visibility = "visible";
  c.style.display = "block";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_attach_free_click;
      p.onmouseout  = at_attach_free_hide;
      c.onmouseover = at_attach_free_show_tag;
      c.onmouseout  = at_attach_free_hide;
      break;
    case "hover":
      p.onmouseout  = at_attach_free_hide;
      c.onmouseover = at_attach_free_show_tag;
      c.onmouseout  = at_attach_free_hide;
      break;
  }
}

function at_attach_free_show_aux_tag(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+0 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 10;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }
  left = left-120;
  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}


function at_attach_free_show_tag()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  at_attach_free_show_aux_tag(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}

function at_attach_free_show_tag_header()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  at_attach_free_show_aux_tag_header(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}

function at_attach_tag_header_statement(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  at_attach_free_show_aux_tag_header(p.id, c.id);
  c.style.position   = "absolute";
  c.style.visibility = "visible";
  c.style.display = "block";

  if (cursor != undefined) p.style.cursor = cursor;

  switch (showtype)
  {
    case "click":
      p.onclick     = at_attach_free_click;
      p.onmouseout  = at_attach_free_hide;
      c.onmouseover = at_attach_free_show_tag_header;
      c.onmouseout  = at_attach_free_hide;
      break;
    case "hover":
      p.onmouseout  = at_attach_free_hide;
      c.onmouseover = at_attach_free_show_tag_header;
      c.onmouseout  = at_attach_free_hide;
      break;
  }
}

function at_attach_free_show_aux_tag_header(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );
  
  var top  = (c["at_position"] == "y") ? p.offsetHeight+0 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 10;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }
  top = 112;
  left = left - 130;
  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  c.style.visibility = "visible";
}

/* Shove functions */

function ShowaCommentBox( DivName ){
    DivObj = document.getElementById( DivName );
	SplitName = DivName.split( "_" );
	if( DivObj.style.display == 'none'){
	 	DivObj.style.display = 'block';
		document.getElementById( "div_post_comment_" + SplitName[ ( SplitName.length ) - 1 ] ).style.display = 'block';
	}else{
		DivObj.style.display = 'none';
		document.getElementById( "div_post_comment_" + SplitName[ ( SplitName.length ) - 1 ] ).style.display = 'none';
	}
 }
 
function PostComment( shoveID,ActionType,Message,shoveidNew  ){
    BlogIDForCommmentLIst = shoveID;
    BlogIDForCommmentLIstNew = shoveidNew;
	var sendToServer = true;
 	if( ActionType == 'add' ){
 		CommentComment = document.getElementById( "comment_comment_" + shoveID ).value;
		if( CommentComment  == "" ){
			document.getElementById( "comment_comment_" + shoveID ).value;
			sendToServer = false;
		}
		
		if( sendToServer ){
			URLQueryStr = JsSiteVar + "add_comments.php?request=AJAX&shove_id="+shoveID + "&comment=" + CommentComment + "&action_mode=add";
		}else{
		   $('DivPostedCommentMessage_' + BlogIDForCommmentLIst).innerHTML ="Please Enter Required Field";//tmp[2];
		}
		
	}
	if( sendToServer ){
	 	new Ajax.Updater('',URLQueryStr,
			   {
			   asynchronous:true,
			   evalScripts:true,
			   parameters:Form.serialize('vote_shove'),
			   requestHeaders:['X-Update', 'ajax'],
			   onComplete:showResponsePostComment
			   }
		   );
	 }
}

function showResponsePostComment(originalRequest) {
	var tmp=originalRequest.responseText.split( "!@#$%" );
	if( tmp[1] == 'Edit'){
 		 DivnameEdit = "div_edit_comment_box_" + BlogIDForCommmentLIst;
 	    $(DivnameEdit).style.display = "none";
 		$('div_edit_message_comment_box'  ).innerHTML = 'Comment Edited';
	    $('DivPostedCommentMessage_' + BlogIDForCommmentLIstNew ).innerHTML = "";
	 }else{
		document.getElementById( "comment_comment_" + BlogIDForCommmentLIst ).value = '';
		document.getElementById( "divCommentCounter_" + BlogIDForCommmentLIst).innerHTML = tmp[1];
 		$('DivPostedCommentMessage_' + BlogIDForCommmentLIst).innerHTML ="Comment Saved";//tmp[2];
 		$('div_comment_box_' +  BlogIDForCommmentLIst ).innerHTML = tmp[0];
   }
}
  
function nominate_shove(media_parent1, media_child1)
{
	at_attach_shove_statement(media_parent1, media_child1, "hover", "y", "pointer");
}
function check_div_position(obj, mvTop, mvLeft)
{
	obj.style.position = "relative";
	obj.style.top = mvTop;
	obj.style.left = mvLeft;
}

function h_keyword_enable_disable(title,body)
{
			if(document.getElementById("h_media_2").checked==true){
				document.getElementById(title).style.display = "block";
				document.getElementById(body).style.display = "block";
			}
			else if(document.getElementById("h_media_4").checked==true){
				document.getElementById(title).style.display = "block";
				document.getElementById(body).style.display = "block";
			}
			else
			{
				document.getElementById(title).style.display = "none";
				document.getElementById(body).style.display = "none";
			}
			
		
}

function keyword_enable_disable(title,body)
{
	if(document.getElementById("media_2").checked==true){
		document.getElementById(title).style.display = "block";
		document.getElementById(body).style.display = "block";
	}
	else if(document.getElementById("media_4").checked==true){
		document.getElementById(title).style.display = "block";
		document.getElementById(body).style.display = "block";
	}
	else
	{
		document.getElementById(title).style.display = "none";
		document.getElementById(body).style.display = "none";
	}
			
		
}

function category_enable_disable(art_category)
{
	if(document.getElementById("media_4").checked==true){
		document.getElementById(art_category).style.display = "block";
	}
	else{
		document.getElementById(art_category).style.display = "none";
	}
}

function h_category_enable_disable(h_art_category)
{
	if(document.getElementById("h_media_4").checked==true){
		document.getElementById(h_art_category).style.display = "block";
	}
	else{
		document.getElementById(h_art_category).style.display = "none";
	}
}

function mediasort(pars,site_url)
{
	if(!pagedisable){
		var tmp=pars.split('&');
		var divtag = tmp[0].split('=');
		GetAjaxLoader(divtag[1]);
		url="http://"+site_url+"/media/listing.php";
		var myAjax = new Ajax.Updater(
				{success: divtag[1]}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}	
}

function opendiscussion_popup(pars)
{	
		var discussionurl;
		discussionurl = "http://"+pars+"/media/add_post_popup.php";
		
		window.open (discussionurl, "mywindow", "resizable=0,location=0,toolbar=0,status=0,menubar=0,directories=0, left=230,top=230, resizable=0,scrollbars=0");			
}

var GlobalVoteType = '';
var GlobalShoveID = '';
function AjaxVoteShove( ShoveID,VoteType ){ 

	GlobalVoteType = VoteType 
	GlobalShoveID = ShoveID	
	new Ajax.Updater('',JsSiteVar +  'shove_vote.php?request=Ajax&ids=' + ShoveID+"&type=" + VoteType,
		   {
		   asynchronous:true,
		   evalScripts:true,
		   parameters:Form.serialize('vote_shove'),
		   requestHeaders:['X-Update', 'ajax'],
		   onComplete:VoteShoveResponse
		   }
	   );
  }
function VoteShoveResponse(originalRequest) {
    //put returned XML in div
     var tmp=originalRequest.responseText.split('|');
	if( GlobalVoteType != 'fold'){
	  $('shove_counter_' + GlobalShoveID ).innerHTML = tmp[1];
	}
  	if( tmp[0] == 'Shove Voted' || tmp[0] == 'Fold Voted'){
	   if(  GlobalVoteType == 'shove'){	     	
			document.getElementById("shove1_" + GlobalShoveID).innerHTML='';
					
	   }	   
	}	
	$('vote_message').innerHTML = tmp[0];
}

//serach article category listing
function AjaxArticleListing(pars, ajaxPage, divid, showflag, mediaflag, sortby, sortorder,site_url){
	
	if(!pagedisable){
		GetAjaxLoader(divid);
		pars="page="+ajaxPage;
		url="http://"+site_url+"/media/articlelisting.php?category="+showflag+"&divflag="+mediaflag+"&page="+ajaxPage+"&orderby="+sortby+"&sortorder="+sortorder;  
		//alert(url);
		var myAjax = new Ajax.Updater(
				{success: divid}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}
} 

function artilcecategorysort(pars,site_url)
{
	if(!pagedisable){
		var tmp=pars.split('&');
		var divtag = tmp[0].split('=');
		GetAjaxLoader(divtag[1]);
		url="http://"+site_url+"/media/articlelisting.php";
		var myAjax = new Ajax.Updater(
				{success: divtag[1]}, 
				url, 
				{
					method: 'get', 
					parameters: pars,
					evalScripts:true,				
					onFailure: reportError
				});
	}	
}

