<!--
// Home Page - JS Functions - Updated By Selvan
/*
	Ajax Pages 
	----------
	travel channel interest ajax & php Pages
		explore_destination.js
		fill_travel_channel.php

*/
var site_url="http://www.hornbill.loc:5051/";
function getElementPosition(elemID){
	var offsetTrail = document.getElementById(elemID);
	var offsetLeft = 0;
	var offsetTop = 0;
	while (offsetTrail){
	offsetLeft += offsetTrail.offsetLeft;
	offsetTop += offsetTrail.offsetTop;
	offsetTrail = offsetTrail.offsetParent;
	}
	if (navigator.userAgent.indexOf('Mac') != -1 && typeof document.body.leftMargin != 'undefined'){
	offsetLeft += document.body.leftMargin;
	offsetTop += document.body.topMargin;
	}
	return {left:offsetLeft,top:offsetTop};
}
function fnpopup()	{
	document.getElementById("dest2int").innerHTML="refine further by destination";
	var leftpos=(getElementPosition("link_interest").left)-360;
	var toppos=getElementPosition("link_interest").top;
	setheightwidht(leftpos,toppos);
	Popup.showModal('travel_interest',null,null,{'screenColor':'#FFFFFF','screenOpacity':.1});
	return false;
}
function fnshow_trip_request()	{
	var leftpos=(getElementPosition("div_trip_img").left)-258;
	var toppos=getElementPosition("div_trip_img").top;
	setheightwidht(leftpos,toppos);
	Popup.showModal('idfollow',null,null,{'screenColor':'#FFFFFF','screenOpacity':.1});
	return false;
}
var notification_opened=false;
function fnpopup_notification()	{
	var leftpos=(getElementPosition("link_notification").left)-128;
	var toppos=(getElementPosition("link_notification").top)+15;
	setheightwidht(leftpos,toppos);
	notification_opened=true;
	Popup.showModal('not_main',null,null,{'screenColor':'#FFFFFF','screenOpacity':.1});
	return false;
}
function close_note()	{
	Popup.hide('not_main');
	notification_opened=false;
}
function fun_get_uid()	{
	var post_vars = {
		'type'  	: 'getuid'
	};
	$.post(site_url+'call_uid.php', post_vars,
		function(contents) {
			alert(contents);
		}
	);	
}
function fn_send_join()	{
	var post_vars = {
		'type'  	: 'send_mail'
	};
	$.post(site_url+'join_beta.php', post_vars,
		function(contents) {
			document.getElementById("idfollow").innerHTML=contents;
		}
	);	
}
function fn_save_noti_click(not_id)
{
	var xmlHttp;
	xmlHttp=GetXmlHttpObj()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url="";
	url="crop_actions.php?not_id="+not_id+"&action=click_notif&sid="+Math.random()
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 
function bgr_color(obj, color) {
   obj.style.backgroundColor=color
}
function Trim(nStr){return nStr.replace(/(^\s*)|(\s*$)/g, "");}
function fnfocus()	{
	var search_val=document.thissearch.txtsearch.value;
	if(search_val=="search")
		document.thissearch.txtsearch.value="";
}
function fnblur()	{
	var search_val=document.thissearch.txtsearch.value;
	if(search_val=="")	{
		document.thissearch.txtsearch.value="search";
		document.thissearch.txtsearch.style.color = '#999999';
	}
}
function fnover_ph()	{
	document.getElementById("img_home_ph").src=site_url+"images/new_home_p_l_hover.jpg";
	document.getElementById("home_ph_div").className="left_slides_active_left";	
	document.getElementById("ph_left").className="left_slides_active_rit";	
	document.getElementById("ph_slide").className="left_slides_active";	

	document.getElementById("ph_link").className="l_s_act";
	document.getElementById("spn_ph").className="sm_ts_act";
	document.getElementById("ph_links").style.display="block";

}
function fnout_ph()	{
	document.getElementById("img_home_ph").src=site_url+"images/new_home_p_l.jpg";
	document.getElementById("home_ph_div").className="left_slides_n_left";	
	document.getElementById("ph_left").className="left_slides_n_rit";	
	document.getElementById("ph_slide").className="left_slides";	
	
	document.getElementById("ph_link").className="l_s";
	document.getElementById("spn_ph").className="sm_ts";	
	document.getElementById("ph_links").style.display="none";
}
function fnover_video()	{
	document.getElementById("img_home_vi").src=site_url+"images/new_home_v_l_hover.jpg";
	document.getElementById("home_video_div").className="left_slides_active_left";	
	document.getElementById("vi_left").className="left_slides_active_rit";	
	document.getElementById("vi_slide").className="left_slides_active";	

	document.getElementById("vi_link").className="l_s_act";
	document.getElementById("spn_vi").className="sm_ts_act";
	document.getElementById("vi_links").style.display="block";

}
function fnout_video()	{
	document.getElementById("img_home_vi").src=site_url+"images/new_home_v_l.jpg";

	document.getElementById("home_video_div").className="left_slides_n_left";	
	document.getElementById("vi_left").className="left_slides_n_rit";	
	document.getElementById("vi_slide").className="left_slides";	

	document.getElementById("vi_link").className="l_s";
	document.getElementById("spn_vi").className="sm_ts";	
	document.getElementById("vi_links").style.display="none";
}
function fnover_map()	{
	document.getElementById("img_home_map").src=site_url+"images/new_home_m_l_hover.jpg";
	document.getElementById("home_map_div").className="left_slides_active_left";	
	document.getElementById("map_left1").className="left_slides_active_rit";	
	document.getElementById("map_slide").className="left_slides_active";	

	document.getElementById("map_link").className="l_s_act";
	document.getElementById("spn_map").className="sm_ts_act";
	document.getElementById("map_links").style.display="block";

}
function fnout_map()	{
	document.getElementById("img_home_map").src=site_url+"images/new_home_m_l.jpg";
	document.getElementById("home_map_div").className="left_slides_n_left";	
	document.getElementById("map_left1").className="left_slides_n_rit";	
	document.getElementById("map_slide").className="left_slides";	
	
	document.getElementById("map_link").className="l_s";
	document.getElementById("spn_map").className="sm_ts";	
	document.getElementById("map_links").style.display="none";
}
function fnover_community()	{
	document.getElementById("img_comm_map").src=site_url+"images/new_home_comm_l_hover.jpg";
	document.getElementById("home_comm_div").className="left_slides_active_left";	
	document.getElementById("comm_left1").className="left_slides_active_rit";	
	document.getElementById("comm_slide").className="left_slides_active";	

	document.getElementById("comm_link").className="l_s_act";
	document.getElementById("spn_comm").className="sm_ts_act";
	document.getElementById("comm_links").style.display="block";

}
function fnout_community()	{
	document.getElementById("img_comm_map").src=site_url+"images/new_home_comm_l.jpg";
	document.getElementById("home_comm_div").className="left_slides_n_left";	
	document.getElementById("comm_left1").className="left_slides_n_rit";	
	document.getElementById("comm_slide").className="left_slides";	
	
	document.getElementById("comm_link").className="l_s";
	document.getElementById("spn_comm").className="sm_ts";	
	document.getElementById("comm_links").style.display="none";
}

function fnover_journal()	{
	document.getElementById("img_home_journal").src=site_url+"images/new_home_t_l_hover.jpg";
	document.getElementById("home_journal_div").className="left_slides_active_left";	
	document.getElementById("journal_left").className="left_slides_active_rit";	
	document.getElementById("journal_slide").className="left_slides_active";	
	document.getElementById("journal_link").className="l_ssm_active";
	document.getElementById("spn_journal").className="sm_ts_act";
	document.getElementById("journal_links").style.display="block";

}
function fnout_journal()	{
	document.getElementById("img_home_journal").src=site_url+"images/new_home_t_l.jpg";
	document.getElementById("home_journal_div").className="left_slides_n_left";	
	document.getElementById("journal_left").className="left_slides_n_rit";	
	document.getElementById("journal_slide").className="left_slides5";	

	document.getElementById("journal_link").className="l_ssm";
	document.getElementById("spn_journal").className="sm_ts";	
	document.getElementById("journal_links").style.display="none";
}
function fnover_blog()	{
	document.getElementById("img_home_blog").src=site_url+"images/new_home_w_l_hover.jpg";
	document.getElementById("home_blog_div").className="left_slides_active_left";	
	document.getElementById("blog_left").className="left_slides_active_rit";	
	document.getElementById("blog_slide").className="left_slides_active";	
	document.getElementById("blog_link").className="l_ssm_active";
	document.getElementById("spn_blog").className="sm_ts_act";
	document.getElementById("blog_links").style.display="block";

}
function fnout_blog()	{
	document.getElementById("img_home_blog").src=site_url+"images/new_home_w_l.jpg";
	document.getElementById("home_blog_div").className="left_slides_n_left";	
	document.getElementById("blog_left").className="left_slides_n_rit";	
	document.getElementById("blog_slide").className="left_slides5";	
	document.getElementById("blog_link").className="l_ssm";
	document.getElementById("spn_blog").className="sm_ts";	
	document.getElementById("blog_links").style.display="none";
}
function black(nama){
	nama.style.color = '#000000'; 
}
function gray(nama){
	nama.style.color = '#999999';
}

function fnGetCountry(cid,type,cname)	{
	if(type==1000)
	{
		cname=cname.toLowerCase();
		document.destination_form_1.txt_explore_dest.value=cname;
		document.destination_form_1.txt_cid.value=cid;
		document.destination_form_1.txt_type.value=type;
	}
	if(type==2000)
	{
		cname=cname.toLowerCase();
		document.destination_form_1.txt_explore_dest.value=cname;
		document.destination_form_1.txt_cid.value=cid;
		document.destination_form_1.txt_type.value=type;
	}
		//showHint_usflashmap(cid,"home",2000);
	
}
function fnopen_fb_popup(){
	myRef = window.open('fb_connect/index.php?page_action=invite','_blank','left=100px,top=100px,width=780,height=550,scrollbars=1,toolbar=0,resizable=1');
	if(myRef==null){
		alert("Your browser maybe blocking up facebook invite. nn  Please check your Popup Blocker Settings");
	}	
}
function show_cont()	{
	document.getElementById("contributors").style.display="block";	
	document.getElementById("similar_int").style.display="none";	
	document.getElementById("top_cont").className="tabs";	
	document.getElementById("sim_int").className="tabs2";	
}
function show_int()	{
	document.getElementById("contributors").style.display="none";	
	document.getElementById("similar_int").style.display="block";	
	document.getElementById("top_cont").className="tabs2";	
	document.getElementById("sim_int").className="tabs";	
}
function fnGet_usflash()	
{
	if(document.destination_form.txt_inttodesc.value=="yes")
	{
	
		var destinations="";
		var tot=document.destination_form.tot_rows.value;
		for(i=1;i<=tot;i++)	{
			if(document.getElementById("chk"+i).checked)	{
				destinations+=document.getElementById("chk"+i).value+",";
			}
		}	
		showHint_map_inter((destinations.substr(0,destinations.length-1)),"home",document.destination_form_1.txt_cid.value,document.destination_form_1.txt_type.value);
	}
	else
	{	
		showHint_usflashmap(document.destination_form_1.txt_cid.value,"home",document.destination_form_1.txt_type.value);
	}
	Popup.hide('travel_destination')
	interest_close()
	destination_close()	
}
function refine_interest()
{
	
	if(document.destination_form_1.txt_explore_dest.value=="") {
		alert("please choose travel destination");
		return false;
	}
	document.destination_form_1.txt_intchange.value="yes";
	if(document.destination_form_1.txt_explore_dest.value!="")
		document.getElementById("show_destination").innerHTML="<B>destinations selected:</B> "+document.destination_form_1.txt_explore_dest.value;
	else
		document.getElementById("show_destination").innerHTML="";
	
	
	Popup.hide('travel_destination');
	fnpopup();
	document.getElementById("dest2int").innerHTML="";
	
}
function interest_close()
{
	var tot=document.destination_form.tot_rows.value;
	for(i=1;i<=tot;i++)	{
		document.getElementById("chk"+i).checked = false;
	}
	
	document.destination_form_1.txt_explore_dest.value="";
	document.destination_form_1.txt_cid.value="";
	document.destination_form_1.txt_type.value="";
	document.destination_form_1.txt_intchange.value="";
	document.destination_form.txt_inttodesc.value="";
	document.destination_form.select_int.value="";
	
	document.getElementById("show_interest").innerHTML="";
	document.getElementById("show_destination").innerHTML="";
	Popup.hide('travel_interest')

	
}
function destination_close()
{
	Popup.hide('travel_destination')	
}
function refine_destination()
{
	var destinations="";
	var int_val="";
	var tot=document.destination_form.tot_rows.value;
	for(i=1;i<=tot;i++)	{
		if(document.getElementById("chk"+i).checked)	{
			destinations+=document.getElementById("chk"+i).value+",";
			int_val+=document.getElementById("hid_"+i).value+", ";
		}
	}	
	int_val=int_val.substr(0,int_val.length-1)
	document.destination_form.select_int.value=int_val;
	if(destinations=="") {
		alert("please choose travel interest");
		return false;
	}
	document.destination_form.txt_inttodesc.value="yes";
	document.getElementById("show_interest").innerHTML="<B>travel interest selected :</B> "+document.destination_form.select_int.value;
	Popup.hide('travel_interest');
	fnpopup_desc();
	document.getElementById("int2dest").innerHTML="";
	
}

function fnExplore_Dest()	{
	var destinations="";
	var int_val="";
	var tot=document.destination_form.tot_rows.value;
	for(i=1;i<=tot;i++)	{
		if(document.getElementById("chk"+i).checked)	{
			destinations+=document.getElementById("chk"+i).value+",";
			int_val+=document.getElementById("hid_"+i).value+",";
		}
	}	
	document.destination_form.select_int.value=int_val;
	
	if(destinations=="") {
		alert("please choose travel interest");
		return false;
	}

	if(document.destination_form_1.txt_intchange.value=="yes")
		showHint_map_inter((destinations.substr(0,destinations.length-1)),"home",document.destination_form_1.txt_cid.value,document.destination_form_1.txt_type.value);
	else
		showHint((destinations.substr(0,destinations.length-1)),"home");
	
	interest_close()
	destination_close()
}

function fnpopup_desc()	{
	var leftpos=(getElementPosition("link_desc").left);
	var toppos=getElementPosition("link_desc").top-350;
	setheightwidht(leftpos,toppos);
	Popup.showModal('travel_destination',null,null,{'screenColor':'#000000','screenOpacity':.5});
	return false;
}

// Search Functions - Begins
function fnSearchVal()	
{
	if(Trim(document.thissearch.txtsearch.value)=="search")
	{
		document.thissearch.txtsearch.value="";
		document.thissearch.txtsearch.focus();
		alert("please enter the search criteria")
		return false;
	}
	if(Trim(document.thissearch.cmb_search.value)=="" &&  Trim(document.thissearch.txtsearch.value)=="")
	{
		alert("please enter the search criteria")
		return false;
	}
	else
	{
		return true;
	}	
}
function fnSearchVal1()	
{
	if(Trim(document.thissearch1.cmb_search1.value)=="" && Trim(document.thissearch1.txtsearch1.value)=="")
	{
		alert("please enter the search criteria")
		return false;
	}
	else
	{
		return true;
	}	
}
// Search Function  - Ends Here

var current_position=7;

// Step Carousel Home Page
function fnPrevClick(arg)	{
	var channel_div=document.getElementById("channel_div");
	var tot_channels=parseInt(channel_div.style.width+0)/128
	//alert(current_position+" "+tot_channels);
		if(arg==1)
			current_position--;
		else	
			current_position-=7;
	
	var channel_div=document.getElementById("channel_div");
	var less_val=-130;
	if(arg==7)	
		less_val=-910;
	
	var moved_pos=parseInt(channel_div.style.width)/2+parseInt(channel_div.style.left);
}

function fnNextClick(arg)	{
	var channel_div=document.getElementById("channel_div");
	var tot_channels=parseInt(channel_div.style.width+0)/128
	tot_channels = 10;
	if(tot_channels>current_position)	{
		if(arg==1)
			current_position++;
		else	
			current_position+=7;
	}

	var moved_pos=parseInt(channel_div.style.width+0)+parseInt(channel_div.style.left+0);

	var less_val=1024;
	if(arg==7)	
		less_val=1792;
}

function fnSave_Adv_Click(adv_id,page,type)
{
	var xmlHttp;
	xmlHttp=GetXmlHttpObj()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url="";
	url="save_adv_click.php?id="+adv_id+"&type="+type+"&page="+page+"&sid="+Math.random()
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 

function GetXmlHttpObj()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
	objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
	objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
} 

function fncheck(arg){
	//For Home page carousels
	if(arg == 'home'){
		document.getElementById("caro_prev").src="images/new_home_car_lftarrow.jpg";
		if(document.getElementById("hidChannelCount").value > 0){
	  		document.getElementById("caro_next").src="images/new_home_car_ritarrow.jpg";
		}else{
			document.getElementById("caro_next").src="images/new_home_car_ritarrow_hover.jpg";
		}
	}
}


// purpose : used to fill the Course
var xmlHttp
function showHint_map_inter(str,page,cid,ctype)
{
	if(str!='all')	{
		Popup.hide('travel_interest');
	}
	img_indx=1;
	document.getElementById("channel_div").innerHTML="";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url="";
	url="fill_travel_channel.php?q="+str+"&cid="+cid+"&ctype="+ctype;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 
function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		var response=xmlHttp.responseText.split("~~");
		var content=response[0];
		var div_width=response[1];
		document.getElementById("channel_div").style.width=response[1]+"px";
		document.getElementById("channel_div").innerHTML=content;
		document.getElementById("channel_div").style.left="0px";

		if(response[2]=="home")	{
			document.getElementById("caro_next").src="images/new_home_car_ritarrow.jpg";
			document.getElementById("caro_prev").src="images/new_home_car_lftarrow.jpg";
		}
		if(response[2]=="inner")	{
			document.getElementById("right_ch").src="images/new_home_car_ritarrow_hover.jpg";
			document.getElementById("left_ch").src="images/new_home_car_lftarrow.jpg";
		}
		fncheck("home");
	} 
	
} 
function GetXmlHttpObject()
{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
	objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
	objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
} 

//usflash 
function showHint_usflashmap(str,page,type)
{
	img_indx=1;
	document.getElementById("channel_div").innerHTML="";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url="";
	if(page=="inner")
		url="fill_travel_channel_dest_inner.php?q="+str+"&type="+type+"&channel_id="+document.destination_form.channel_id.value;
	else	
		url="fill_travel_channel.php?q="+str+"&type="+type;
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChangedusmap
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	Popup.hide('travel_destination')
}

function stateChangedusmap() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		var response=xmlHttp.responseText.split("~~");
		var content=response[0];
		var div_width=response[1];
		document.getElementById("channel_div").innerHTML = content;
		document.getElementById("channel_div").style.left="0px";
		fncheck(response[2]);
	} 
}

function showHint(str,page)
{
	if (str.length==0)
	{ 
		//document.getElementById("txtHint").innerHTML="<select name='cmbCourse' class='cmbbox'><option value=0>---Select Course---</option></select>";
	//	return
	}
	if(str!='all')	{
		Popup.hide('travel_interest');
	}
	
	img_indx=1;
	document.getElementById("channel_div").innerHTML="";
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url="";
	if(page=="inner")
		url="fill_travel_channel_inner.php?q="+str+"&channel_id="+document.destination_form.channel_id.value;
	else	
		url="fill_travel_channel.php?q="+str
	url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
} 
// Drop Down Menu - Updated By AES - Selvan

var cssdropdown={
disappeardelay: 250, 
disablemenuclick: true, 
enableswipe: 1, 
enableiframeshim: 1, 
dropmenuobj: null, ie: document.all, firefox: document.getElementById&&!document.all, swipetimer: undefined, bottomclip:0,
getposOffset:function(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
},
swipeeffect:function(){
if (this.bottomclip<parseInt(this.dropmenuobj.offsetHeight)){
this.bottomclip+=10+(this.bottomclip/10)
this.dropmenuobj.style.clip="rect(0 auto "+this.bottomclip+"px 0)"
}else
return
this.swipetimer=setTimeout("cssdropdown.swipeeffect()", 10)
},
showhide:function(obj, e){
if (this.ie || this.firefox)
this.dropmenuobj.style.left=this.dropmenuobj.style.top="-500px"
if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover"){
if (this.enableswipe==1){
if (typeof this.swipetimer!="undefined")
clearTimeout(this.swipetimer)
obj.clip="rect(0 auto 0 0)" 
this.bottomclip=0
this.swipeeffect()
}
obj.visibility="visible"
}else if (e.type=="click")
obj.visibility="hidden"
},
iecompattest:function(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
},
clearbrowseredge:function(obj, whichedge){
var edgeoffset=0
if (whichedge=="rightedge"){
var windowedge=this.ie && !window.opera? this.iecompattest().scrollLeft+this.iecompattest().clientWidth-15 : window.pageXOffset+window.innerWidth-15
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetWidth
if (windowedge-this.dropmenuobj.x < this.dropmenuobj.contentmeasure)  //move menu to the left?
edgeoffset=this.dropmenuobj.contentmeasure-obj.offsetWidth
}else{
var topedge=this.ie && !window.opera? this.iecompattest().scrollTop : window.pageYOffset
var windowedge=this.ie && !window.opera? this.iecompattest().scrollTop+this.iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
this.dropmenuobj.contentmeasure=this.dropmenuobj.offsetHeight
if (windowedge-this.dropmenuobj.y < this.dropmenuobj.contentmeasure){ 
edgeoffset=this.dropmenuobj.contentmeasure+obj.offsetHeight
if ((this.dropmenuobj.y-topedge)<this.dropmenuobj.contentmeasure) 
edgeoffset=this.dropmenuobj.y+obj.offsetHeight-topedge
}}
return edgeoffset
},
dropit:function(obj, e, dropmenuID){
if (this.dropmenuobj!=null) 
this.dropmenuobj.style.visibility="hidden" 
this.clearhidemenu()
if (this.ie||this.firefox){
obj.onmouseout=function(){cssdropdown.delayhidemenu()}
obj.onclick=function(){return !cssdropdown.disablemenuclick} 
this.dropmenuobj=document.getElementById(dropmenuID)
this.dropmenuobj.onmouseover=function(){cssdropdown.clearhidemenu()}
this.dropmenuobj.onmouseout=function(e){cssdropdown.dynamichide(e)}
this.dropmenuobj.onclick=function(){cssdropdown.delayhidemenu()}
this.showhide(this.dropmenuobj.style, e)
this.dropmenuobj.x=this.getposOffset(obj, "left")
this.dropmenuobj.y=this.getposOffset(obj, "top")
this.dropmenuobj.style.left=this.dropmenuobj.x-this.clearbrowseredge(obj, "rightedge")+"px"
this.dropmenuobj.style.top=this.dropmenuobj.y-this.clearbrowseredge(obj, "bottomedge")+obj.offsetHeight+1+"px"
this.positionshim() //call iframe shim function
}},
positionshim:function(){ 
if (this.enableiframeshim && typeof this.shimobject!="undefined"){
if (this.dropmenuobj.style.visibility=="visible"){
this.shimobject.style.width=this.dropmenuobj.offsetWidth+"px"
this.shimobject.style.height=this.dropmenuobj.offsetHeight+"px"
this.shimobject.style.left=this.dropmenuobj.style.left
this.shimobject.style.top=this.dropmenuobj.style.top
}
this.shimobject.style.display=(this.dropmenuobj.style.visibility=="visible")? "block" : "none"
}},
hideshim:function(){
if (this.enableiframeshim && typeof this.shimobject!="undefined")
this.shimobject.style.display='none'
},
contains_firefox:function(a, b) {
while (b.parentNode)
if ((b = b.parentNode) == a)
return true;
return false;
},
dynamichide:function(e){
var evtobj=window.event? window.event : e
if (this.ie&&!this.dropmenuobj.contains(evtobj.toElement))
this.delayhidemenu()
else if (this.firefox&&e.currentTarget!= evtobj.relatedTarget&& !this.contains_firefox(evtobj.currentTarget, evtobj.relatedTarget))
this.delayhidemenu()
},
delayhidemenu:function(){
this.delayhide=setTimeout("cssdropdown.dropmenuobj.style.visibility='hidden'; cssdropdown.hideshim()",this.disappeardelay) //hide menu
},
clearhidemenu:function(){
if (this.delayhide!="undefined")
clearTimeout(this.delayhide)
},
startchrome:function(){

for (var ids=0; ids<arguments.length; ids++){
var menuitems=document.getElementById(arguments[ids]).getElementsByTagName("a")
for (var i=0; i<menuitems.length; i++){
if (menuitems[i].getAttribute("rel")){
var relvalue=menuitems[i].getAttribute("rel")
menuitems[i].onmouseover=function(e){
var event=typeof e!="undefined"? e : window.event
cssdropdown.dropit(this,event,this.getAttribute("rel"))
}}}}
if (window.createPopup && !window.XmlHttpRequest){ 
document.write('<IFRAME id="iframeshim"  src="" style="display: none; left: 0; top: 0; z-index: 90; position: absolute; filter: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)" frameBorder="0" scrolling="no"></IFRAME>')
this.shimobject=document.getElementById("iframeshim") 
}}}
var stepcarousel={
	ajaxloadingmsg: '<div style="margin: 1em; font-weight: bold"><img src="ajaxloadr.gif" style="vertical-align: middle" /> Fetching Content. Please wait...</div>', 
	defaultbuttonsfade: 0.4, 
	configholder: {},

	getCSSValue:function(val){ 
		return (val=="auto")? 0 : parseInt(val)
	},

	getremotepanels:function($, config){
		config.$belt.html(this.ajaxloadingmsg)
		$.ajax({
			url: config.contenttype[1], 
			async: true,
			error:function(ajaxrequest){
				config.$belt.html('Error fetching content.<br />Server Response: '+ajaxrequest.responseText)
			},
			success:function(content){
				config.$belt.html(content)
				config.$panels=config.$gallery.find('.'+config.panelclass)
				stepcarousel.alignpanels($, config)
			}
		})
	},

	getoffset:function(what, offsettype){
		return (what.offsetParent)? what[offsettype]+this.getoffset(what.offsetParent, offsettype) : what[offsettype]
	},

	fadebuttons:function(config, currentpanel){
		config.$leftnavbutton.fadeTo('fast', currentpanel==0? this.defaultbuttonsfade : 1)
		config.$rightnavbutton.fadeTo('fast', currentpanel==config.lastvisiblepanel? this.defaultbuttonsfade : 1)
	},

	addnavbuttons:function(config, currentpanel){
		config.$leftnavbutton=$('<img src="'+config.defaultbuttons.leftnav[0]+'">').css({zIndex:50, position:'absolute', left:config.offsets.left+config.defaultbuttons.leftnav[1]+'px', top:config.offsets.top+config.defaultbuttons.leftnav[2]+'px', cursor:'hand', cursor:'pointer'}).attr({title:'Back '+config.defaultbuttons.moveby+' panels'}).appendTo('body')
		config.$rightnavbutton=$('<img src="'+config.defaultbuttons.rightnav[0]+'">').css({zIndex:50, position:'absolute', left:config.offsets.left+config.$gallery.get(0).offsetWidth+config.defaultbuttons.rightnav[1]+'px', top:config.offsets.top+config.defaultbuttons.rightnav[2]+'px', cursor:'hand', cursor:'pointer'}).attr({title:'Forward '+config.defaultbuttons.moveby+' panels'}).appendTo('body')
		config.$leftnavbutton.bind('click', function(){ 
			stepcarousel.stepBy(config.galleryid, -config.defaultbuttons.moveby)
		})
		config.$rightnavbutton.bind('click', function(){ 
			stepcarousel.stepBy(config.galleryid, config.defaultbuttons.moveby)
		})
		if (config.panelbehavior.wraparound==false){ 
			this.fadebuttons(config, currentpanel)
		}
	},

	alignpanels:function($, config){
		var paneloffset=0
		config.paneloffsets=[paneloffset] 
		config.panelwidths=[] 
		config.$panels.each(function(index){ 
			var $currentpanel=$(this)
			$currentpanel.css({float: 'none', position: 'absolute', left: paneloffset+'px'}) 
			$currentpanel.bind('click', function(e){return config.onpanelclick(e.target)}) 
			paneloffset+=stepcarousel.getCSSValue($currentpanel.css('marginRight')) + parseInt($currentpanel.get(0).offsetWidth || $currentpanel.css('width')) 
			config.paneloffsets.push(paneloffset) 
			config.panelwidths.push(paneloffset-config.paneloffsets[config.paneloffsets.length-2]) 
		})
		config.paneloffsets.pop() 
		var addpanelwidths=0
		var lastpanelindex=config.$panels.length-1
		config.lastvisiblepanel=lastpanelindex
		for (var i=config.$panels.length-1; i>=0; i--){
			addpanelwidths+=(i==lastpanelindex? config.panelwidths[lastpanelindex] : config.paneloffsets[i+1]-config.paneloffsets[i])
			if (config.gallerywidth>addpanelwidths){
				config.lastvisiblepanel=i 
			}
		}
		config.$belt.css({width: paneloffset+'px'}) 
		if (config.currentpanel!=0){
			var endpoint=config.paneloffsets[config.currentpanel]+(config.currentpanel==0? 0 : config.beltoffset)
			config.$belt.css({left: -endpoint+'px'})
		}
		if (config.defaultbuttons.enable==true){ 
			this.addnavbuttons(config, config.currentpanel)
			$(window).bind("load, resize", function(){ 
				config.offsets={left:stepcarousel.getoffset(config.$gallery.get(0), "offsetLeft"), top:stepcarousel.getoffset(config.$gallery.get(0), "offsetTop")}
				config.$leftnavbutton.css({left:config.offsets.left+config.defaultbuttons.leftnav[1]+'px', top:config.offsets.top+config.defaultbuttons.leftnav[2]+'px'})
				config.$rightnavbutton.css({left:config.offsets.left+config.$gallery.get(0).offsetWidth+config.defaultbuttons.rightnav[1]+'px', top:config.offsets.top+config.defaultbuttons.rightnav[2]+'px'})
			})
		}
		this.statusreport(config.galleryid)
		config.oninit()
		config.onslideaction(this)
	},
	stepTo:function(galleryid, pindex){ 
		var config=stepcarousel.configholder[galleryid]
		if (typeof config=="undefined"){
			alert("There's an error with your set up of Carousel Viewer \""+galleryid+ "\"!")
			return
		}
		var pindex=Math.min(pindex-1, config.paneloffsets.length-1)
		var endpoint=config.paneloffsets[pindex]+(pindex==0? 0 : config.beltoffset)
		if (config.panelbehavior.wraparound==false && config.defaultbuttons.enable==true){ 
			this.fadebuttons(config, pindex)
		}
		config.$belt.animate({left: -endpoint+'px'}, config.panelbehavior.speed, function(){config.onslideaction(this)})
		config.currentpanel=pindex
		this.statusreport(galleryid)
	},
	stepBy:function(galleryid, steps){
		var config=stepcarousel.configholder[galleryid]
		if (typeof config=="undefined"){
			alert("There's an error with your set up of Carousel Viewer \""+galleryid+ "\"!")
			return
		}
		var direction=(steps>0)? 'forward' : 'back' //If "steps" is negative, that means backwards
		
		//Customized code by - SHEIK
		if(document.getElementById("hidChannel").value == "new"){
			if(document.getElementById("hidChannelCount").value == 0){
				var pindex = 'null' //index of panel to stop at
			}else{
				var pindex = 0+steps //index of panel to stop at
				document.getElementById("hidChannel").value = "old"
			}
		}else{
			var pindex = config.currentpanel+steps //index of panel to stop at
		}
		totcnt = parseInt(document.getElementById("hidChannelCount").value)
		if(pindex > totcnt){
			pindex = totcnt;
		}
		if(pindex != 'null'){
			if(pindex == totcnt){
				document.getElementById("caro_next").src = site_url+"images/new_home_car_ritarrow_hover.jpg";
			}else{
				document.getElementById("caro_next").src = site_url+"images/new_home_car_ritarrow.jpg";
			}
			
			if(pindex < 0 || pindex == 0){
				document.getElementById("caro_prev").src = site_url+"images/new_home_car_lftarrow.jpg";
			}else{
				document.getElementById("caro_prev").src = site_url+"images/new_home_car_lftarrow_hover.jpg";
			}
		}
		if(pindex != 'null'){
			if (config.panelbehavior.wraparound==false){ //if carousel viewer should stop at first or last panel (instead of wrap back or forth)
				pindex=(direction=="back" && pindex<=0)? 0 : (direction=="forward")? Math.min(pindex, config.lastvisiblepanel) : pindex
				if (config.defaultbuttons.enable==true){ //if default nav buttons are enabled, fade them in and out depending on if at start or end of carousel
					stepcarousel.fadebuttons(config, pindex)
				}	
			}
			else{ //else, for normal stepBy behavior
			pindex=(pindex>config.paneloffsets.length-1 || pindex<0 && pindex-steps>0)? 0 : (pindex<0)? config.paneloffsets.length+steps : pindex //take into account end or starting panel and step direction
			}
			var endpoint=config.paneloffsets[pindex]+(pindex==0? 0 : config.beltoffset) //left distance for Belt DIV to travel to
			if (pindex==0 && direction=='forward' || config.currentpanel==0 && direction=='back' && config.panelbehavior.wraparound==true){ //decide whether to apply "push pull" effect
				config.$belt.animate({left: -config.paneloffsets[config.currentpanel]-(direction=='forward'? 100 : -30)+'px'}, 'normal', function(){
					config.$belt.animate({left: -endpoint+'px'}, config.panelbehavior.speed, function(){config.onslideaction(this)})
				})
			}
			else{
				config.$belt.animate({left: -endpoint+'px'}, config.panelbehavior.speed, function(){config.onslideaction(this)})
			}
			config.currentpanel=pindex
			this.statusreport(galleryid)
		}
	},
	statusreport:function(galleryid){
		var config=stepcarousel.configholder[galleryid]
		var startpoint=config.currentpanel //index of first visible panel 
		var visiblewidth=0
		for (var endpoint=startpoint; endpoint<config.paneloffsets.length; endpoint++){ //index (endpoint) of last visible panel
			visiblewidth+=config.panelwidths[endpoint]
			if (visiblewidth>config.gallerywidth){
				break
			}
		}
		startpoint+=1 //format startpoint for user friendiness
		endpoint=(endpoint+1==startpoint)? startpoint : endpoint //If only one image visible on the screen and partially hidden, set endpoint to startpoint
		var valuearray=[startpoint, endpoint, config.panelwidths.length]
		for (var i=0; i<config.statusvars.length; i++){
			window[config.statusvars[i]]=valuearray[i] //Define variable (with user specified name) and set to one of the status values
			config.$statusobjs[i].text(valuearray[i]+" ") //Populate element on page with ID="user specified name" with one of the status values
		}
	},
	setup:function(config){
		//Disable Step Gallery scrollbars ASAP dynamically (enabled for sake of users with JS disabled)
		document.write('<style type="text/css">\n#'+config.galleryid+'{overflow: hidden;}\n</style>')
		jQuery(document).ready(function($){
			config.$gallery=$('#'+config.galleryid)
			config.gallerywidth=config.$gallery.width()
			config.offsets={left:stepcarousel.getoffset(config.$gallery.get(0), "offsetLeft"), top:stepcarousel.getoffset(config.$gallery.get(0), "offsetTop")}
			config.$belt=config.$gallery.find('.'+config.beltclass) //Find Belt DIV that contains all the panels
			config.$panels=config.$gallery.find('.'+config.panelclass) //Find Panel DIVs that each contain a slide
			config.onpanelclick=(typeof config.onpanelclick=="undefined")? function(target){} : config.onpanelclick //attach custom "onpanelclick" event handler
			config.onslideaction=(typeof config.onslide=="undefined")? function(){} : function(beltobj){$(beltobj).stop(); config.onslide()} //attach custom "onslide" event handler
			config.oninit=(typeof config.oninit=="undefined")? function(){} : config.oninit //attach custom "oninit" event handler
			config.beltoffset=stepcarousel.getCSSValue(config.$belt.css('marginLeft')) //Find length of Belt DIV's left margin
			config.statusvars=config.statusvars || []  //get variable names that will hold "start", "end", and "total" slides info
			config.$statusobjs=[$('#'+config.statusvars[0]), $('#'+config.statusvars[1]), $('#'+config.statusvars[2])]
			config.currentpanel=0
			stepcarousel.configholder[config.galleryid]=config //store config parameter as a variable
			if (config.contenttype[0]=="ajax" && typeof config.contenttype[1]!="undefined") //fetch ajax content?
				stepcarousel.getremotepanels($, config)
			else
				stepcarousel.alignpanels($, config) //align panels and initialize gallery
		}) //end document.ready
		jQuery(window).bind('unload', function(){ //clean up
			jQuery.each(config, function(ai, oi){
				oi=null
			})
			config=null
		})
	}
}
// Channel Carousel Initialization
stepcarousel.setup({
	galleryid: 'channel', //id of carousel DIV
	beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
	panelclass: 'panel', //class of panel DIVs each holding content
	panelbehavior: {speed:500, wraparound:false, persist:true},
	defaultbuttons: {enable: false, moveby: 1, leftnav: ['new_home_car_lftarrow.jpg', -5, 80], rightnav: ['new_home_car_ritarrow_hover.jpg', -20, 80]},
	statusvars: ['statusA', 'statusB', 'statusC'], //register 3 variables that contain current panel (start), current panel (last), and total panels
	contenttype: ['inline'] //content setting ['inline'] or ['external', 'path_to_external_file']
})
//popup.js
function isArray(o) {
	return (o!=null && typeof(o)=="object" && typeof(o.length)=="number" && (o.length==0 || defined(o[0])));
};
function isObject(o) {
	return (o!=null && typeof(o)=="object" && defined(o.constructor) && o.constructor==Object && !defined(o.nodeName));
};
function defined(o) {
	return (typeof(o)!="undefined");
};
var divleftpos="";
var divtoppos="";
function setheightwidht(leftpos,toppos)	{
	divtoppos=toppos;
	divleftpos=leftpos;
}
function map(func) {
	var i,j,o;
	var results = [];
	if (typeof(func)=="string") {
		func = new Function('$_',func);
	}
	for (i=1; i<arguments.length; i++) {
		o = arguments[i];
		if (isArray(o)) {
			for (j=0; j<o.length; j++) {
				results[results.length] = func(o[j]);
			}
		}
		else if (isObject(o)) {
			for (j in o) {
				results[results.length] = func(o[j]);
			}
		}
		else {
			results[results.length] = func(o);
		}
	}
	return results;
};
Array.prototype.contains = function(o) {
	var i,l;
	if (!(l = this.length)) { return false; }
	for (i=0; i<l; i++) {
		if (o==this[i]) {
			return true;
		}
	}
};
var DOM = (function() { 
	var dom = {};
	dom.getParentByTagName = function(o,tagNames) {
		if(o==null) { return null; }
		if (isArray(tagNames)) {
			tagNames = map("return $_.toUpperCase()",tagNames);
			while (o=o.parentNode) {
				if (o.nodeName && tagNames.contains(o.nodeName)) {
					return o;
				}
			}
		}
		else {
			tagNames = tagNames.toUpperCase();
			while (o=o.parentNode) {
				if (o.nodeName && tagNames==o.nodeName) {
					return o;
				}
			}
		}
		return null;
	};
	dom.removeNode = function(o) {
		if (o!=null && o.parentNode && o.parentNode.removeChild) {
			for (var i in o) {
				if (typeof(o[i])=="function") {
					o[i] = null;
				}
			}
			o.parentNode.removeChild(o);
			return true;
		}
		return false;
	};
	dom.getOuterWidth = function(o) {
		if (defined(o.offsetWidth)) {
			return o.offsetWidth;
		}
		return null;
	};
	dom.getOuterHeight = function(o) {
		if (defined(o.offsetHeight)) {
			return o.offsetHeight;
		}
		return null;
	};
	dom.resolve = function() {
		var results = new Array();
		var i,j,o;
		for (var i=0; i<arguments.length; i++) {
			var o = arguments[i];
			if (o==null) {
				if (arguments.length==1) {
					return null;
				}
				results[results.length] = null;
			}
			else if (typeof(o)=='string') {
				if (document.getElementById) {
					o = document.getElementById(o);
				}
				else if (document.all) {
					o = document.all[o];
				}
				if (arguments.length==1) {
					return o;
				}
				results[results.length] = o;
			}
			else if (isArray(o)) {
				for (j=0; j<o.length; j++) {
					results[results.length] = o[j];
				}
			}
			else if (isObject(o)) {
				for (j in o) {
					results[results.length] = o[j];
				}
			}
			else if (arguments.length==1) {
				return o;
			}
			else {
				results[results.length] = o;
			}
	  }
	  return results;
	};
	dom.$ = dom.resolve;
	
	return dom;
})();
var CSS = (function(){
	var css = {};
	css.rgb2hex = function(rgbString) {
		if (typeof(rgbString)!="string" || !defined(rgbString.match)) { return null; }
		var result = rgbString.match(/^\s*rgb\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*/);
		if (result==null) { return rgbString; }
		var rgb = +result[1] << 16 | +result[2] << 8 | +result[3];
		var hex = "";
		var digits = "0123456789abcdef";
		while(rgb!=0) { 
			hex = digits.charAt(rgb&0xf)+hex; 
			rgb>>>=4; 
		} 
		while(hex.length<6) { hex='0'+hex; }
		return "#" + hex;
	};
	css.hyphen2camel = function(property) {
		if (!defined(property) || property==null) { return null; }
		if (property.indexOf("-")<0) { return property; }
		var str = "";
		var c = null;
		var l = property.length;
		for (var i=0; i<l; i++) {
			c = property.charAt(i);
			str += (c!="-")?c:property.charAt(++i).toUpperCase();
		}
		return str;
	};
	css.hasClass = function(obj,className) {
		if (!defined(obj) || obj==null || !RegExp) { return false; }
		var re = new RegExp("(^|\\s)" + className + "(\\s|$)");
		if (typeof(obj)=="string") {
			return re.test(obj);
		}
		else if (typeof(obj)=="object" && obj.className) {
			return re.test(obj.className);
		}
		return false;
	};
	css.addClass = function(obj,className) {
		if (typeof(obj)!="object" || obj==null || !defined(obj.className)) { return false; }
		if (obj.className==null || obj.className=='') { 
			obj.className = className; 
			return true; 
		}
		if (css.hasClass(obj,className)) { return true; }
		obj.className = obj.className + " " + className;
		return true;
	};
	css.removeClass = function(obj,className) {
		if (typeof(obj)!="object" || obj==null || !defined(obj.className) || obj.className==null) { return false; }
		if (!css.hasClass(obj,className)) { return false; }
		var re = new RegExp("(^|\\s+)" + className + "(\\s+|$)");
		obj.className = obj.className.replace(re,' ');
		return true;
	};
	css.replaceClass = function(obj,className,newClassName) {
		if (typeof(obj)!="object" || obj==null || !defined(obj.className) || obj.className==null) { return false; }
		css.removeClass(obj,className);
		css.addClass(obj,newClassName);
		return true;
	};
	css.getStyle = function(o, property) {
		if (o==null) { return null; }
		var val = null;
		var camelProperty = css.hyphen2camel(property);
		// Handle "float" property as a special case
		if (property=="float") {
			val = css.getStyle(o,"cssFloat");
			if (val==null) { 
				val = css.getStyle(o,"styleFloat"); 
			}
		}
		else if (o.currentStyle && defined(o.currentStyle[camelProperty])) {
			val = o.currentStyle[camelProperty];
		}
		else if (window.getComputedStyle) {
			val = window.getComputedStyle(o,null).getPropertyValue(property);
		}
		else if (o.style && defined(o.style[camelProperty])) {
			val = o.style[camelProperty];
		}
		if (/^\s*rgb\s*\(/.test(val)) {
			val = css.rgb2hex(val);
		}
		if (/^#/.test(val)) {
			val = val.toLowerCase();
		}
		return val;
	};
	css.get = css.getStyle;
	css.setStyle = function(o, property, value) {
		if (o==null || !defined(o.style) || !defined(property) || property==null || !defined(value)) { return false; }
		if (property=="float") {
			o.style["cssFloat"] = value;
			o.style["styleFloat"] = value;
		}
		else if (property=="opacity") {
			o.style['-moz-opacity'] = value;
			o.style['-khtml-opacity'] = value;
			o.style.opacity = value;
			if (defined(o.style.filter)) {
				o.style.filter = "alpha(opacity=" + value*100 + ")";
			}
		}
		else {
			o.style[css.hyphen2camel(property)] = value;
		}
		return true;
	};
	css.set = css.setStyle;
	
	css.uniqueIdNumber=1000;
	css.createId = function(o) {
		if (defined(o) && o!=null && defined(o.id) && o.id!=null && o.id!="") { 
			return o.id;
		}
		var id = null;
		while (id==null || document.getElementById(id)!=null) {
			id = "ID_"+(css.uniqueIdNumber++);
		}
		if (defined(o) && o!=null && (!defined(o.id)||o.id=="")) {
			o.id = id;
		}
		return id;
	};
	
	return css;
})();

var Event = (function(){
	var ev = {};
	ev.resolve = function(e) {
		if (!defined(e) && defined(window.event)) {
			e = window.event;
		}
		return e;
	};
	
	ev.add = function( obj, type, fn, capture ) {
		if (obj.addEventListener) {
			obj.addEventListener( type, fn, capture );
			return true;
		}
		else if (obj.attachEvent) {
			obj.attachEvent( "on"+type, fn );
			return true;
		}
		return false;
	};

	ev.cancelBubble = function(e) {
		e = ev.resolve(e);
		if (typeof(e.stopPropagation)=="function") { e.stopPropagation(); } 
		if (defined(e.cancelBubble)) { e.cancelBubble = true; }
	};
	ev.stopPropagation = ev.cancelBubble;

	ev.preventDefault = function(e) {
		e = ev.resolve(e);
		if (typeof(e.preventDefault)=="function") { e.preventDefault(); } 
		if (defined(e.returnValue)) { e.returnValue = false; }
	};
	
	return ev;
})();

var Screen = (function() {
	var screen = {};

	screen.getBody = function() {
		if (document.body) {
			return document.body;
		}
		if (document.getElementsByTagName) {
			var bodies = document.getElementsByTagName("BODY");
			if (bodies!=null && bodies.length>0) {
				return bodies[0];
			}
		}
		return null;
	};

	screen.getScrollTop = function() {
		if (document.documentElement && defined(document.documentElement.scrollTop) && document.documentElement.scrollTop>0) {
			return document.documentElement.scrollTop;
		}
		if (document.body && defined(document.body.scrollTop)) {
			return document.body.scrollTop;
		}
		return null;
	};
	
	screen.getScrollLeft = function() {
		if (document.documentElement && defined(document.documentElement.scrollLeft) && document.documentElement.scrollLeft>0) {
			return document.documentElement.scrollLeft;
		}
		if (document.body && defined(document.body.scrollLeft)) {
			return document.body.scrollLeft;
		}
		return null;
	};
	
	screen.zero = function(n) {
		return (!defined(n) || isNaN(n))?0:n;
	};

	screen.getDocumentWidth = function() {
		var width = 0;
		var body = screen.getBody();
		if (document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) {
		    var rightMargin = parseInt(CSS.get(body,'marginRight'),10) || 0;
		    var leftMargin = parseInt(CSS.get(body,'marginLeft'), 10) || 0;
			width = Math.max(body.offsetWidth + leftMargin + rightMargin, document.documentElement.clientWidth);
		}
		else {
			width =  Math.max(body.clientWidth, body.scrollWidth);
		}
		if (isNaN(width) || width==0) {
			width = screen.zero(self.innerWidth);
		}
		return width;
	};
	
	screen.getDocumentHeight = function() {
		var body = screen.getBody();
		var innerHeight = (defined(self.innerHeight)&&!isNaN(self.innerHeight))?self.innerHeight:0;
		if (document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) {
		    var topMargin = parseInt(CSS.get(body,'marginTop'),10) || 0;
		    var bottomMargin = parseInt(CSS.get(body,'marginBottom'), 10) || 0;
			return Math.max(body.offsetHeight + topMargin + bottomMargin, document.documentElement.clientHeight, document.documentElement.scrollHeight, screen.zero(self.innerHeight));
		}
		return Math.max(body.scrollHeight, body.clientHeight, screen.zero(self.innerHeight));
	};
	
	screen.getViewportWidth = function() {
		if (document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) {
			return document.documentElement.clientWidth;
		}
		else if (document.compatMode && document.body) {
			return document.body.clientWidth;
		}
		return screen.zero(self.innerWidth);
	};
	
	screen.getViewportHeight = function() {
		if (!window.opera && document.documentElement && (!document.compatMode || document.compatMode=="CSS1Compat")) {
			return document.documentElement.clientHeight;
		}
		else if (document.compatMode && !window.opera && document.body) {
			return document.body.clientHeight;
		}
		return screen.zero(self.innerHeight);
	};

	return screen;
})();

var Position = (function() {
	function resolveObject(s) {
		if (document.getElementById && document.getElementById(s)!=null) {
			return document.getElementById(s);
		}
		else if (document.all && document.all[s]!=null) {
			return document.all[s];
		}
		else if (document.anchors && document.anchors.length && document.anchors.length>0 && document.anchors[0].x) {
			for (var i=0; i<document.anchors.length; i++) {
				if (document.anchors[i].name==s) { 
					return document.anchors[i]
				}
			}
		}
	}
	
	var pos = {};
	pos.$VERSION = 1.0;
	
	pos.set = function(o,left,top) {
		if (typeof(o)=="string") {
			o = resolveObject(o);
		}
		if (o==null || !o.style) {
			return false;
		}
		
		if (typeof(left)=="object") {
			var pos = left;
			left = pos.left;
			top = pos.top;
		}
		
		o.style.left = left + "px";
		o.style.top = top + "px";
		return true;
	};
	
	pos.get = function(o) {
		var fixBrowserQuirks = true;
		if (typeof(o)=="string") {
			o = resolveObject(o);
		}
		
		if (o==null) {
			return null;
		}
		
		var left = 0;
		var top = 0;
		var width = 0;
		var height = 0;
		var parentNode = null;
		var offsetParent = null;
	
		
		offsetParent = o.offsetParent;
		var originalObject = o;
		var el = o; 
		while (el.parentNode!=null) {
			el = el.parentNode;
			if (el.offsetParent==null) {
			}
			else {
				var considerScroll = true;
				if (fixBrowserQuirks && window.opera) {
					if (el==originalObject.parentNode || el.nodeName=="TR") {
						considerScroll = false;
					}
				}
				if (considerScroll) {
					if (el.scrollTop && el.scrollTop>0) {
						top -= el.scrollTop;
					}
					if (el.scrollLeft && el.scrollLeft>0) {
						left -= el.scrollLeft;
					}
				}
			}
			if (el == offsetParent) {
				left += o.offsetLeft;
				if (el.clientLeft && el.nodeName!="TABLE") { 
					left += el.clientLeft;
				}
				top += o.offsetTop;
				if (el.clientTop && el.nodeName!="TABLE") {
					top += el.clientTop;
				}
				o = el;
				if (o.offsetParent==null) {
					if (o.offsetLeft) {
						left += o.offsetLeft;
					}
					if (o.offsetTop) {
						top += o.offsetTop;
					}
				}
				offsetParent = o.offsetParent;
			}
		}
		
	
		if (originalObject.offsetWidth) {
			width = originalObject.offsetWidth;
		}
		if (originalObject.offsetHeight) {
			height = originalObject.offsetHeight;
		}
		
		return {'left':left, 'top':top, 'width':width, 'height':height
				};
	};
	
	pos.getCenter = function(o) {
		var c = this.get(o);
		if (c==null) { return null; }
		c.left = c.left + (c.width/2);
		c.top = c.top + (c.height/2);
		return c;
	};
	
	return pos;
})();

var Popup = function(div, options) {
	this.div = defined(div)?div:null;
	this.index = Popup.maxIndex++;
	this.ref = "Popup.objects["+this.index+"]";
	Popup.objects[this.index] = this;
	if (typeof(this.div)=="string") {
		Popup.objectsById[this.div] = this;
	}
	if (defined(this.div) && this.div!=null && defined(this.div.id)) {
		Popup.objectsById[this.div.id] = this.div.id;
	}
	if (defined(options) && options!=null && typeof(options)=="object") {
		for (var i in options) {
			this[i] = options[i];
		}
	}
	return this;
};

Popup.maxIndex = 0;
Popup.objects = {};
Popup.objectsById = {};

Popup.minZIndex = 101;

Popup.screenClass = "PopupScreen";
Popup.iframeClass = "PopupIframe";
Popup.screenIframeClass = "PopupScreenIframe";

Popup.hideAll = function() {
	for (var i in Popup.objects) {
		var p = Popup.objects[i];
		if (!p.modal && p.autoHide) {
			p.hide();
		}
	}
};

Event.add(document, "mouseup", Popup.hideAll, false);

Popup.show = function(divObject, referenceObject, position, options, modal) {
	var popup;
	if (defined(divObject)) { 
		popup = new Popup(divObject);
	}
	else {
		popup = new Popup();
		popup.destroyDivOnHide = true;
	}
	if (defined(referenceObject)) { popup.reference = DOM.resolve(referenceObject); }
	if (defined(position)) { popup.position = position; }
	if (defined(options) && options!=null && typeof(options)=="object") {
		for (var i in options) {
			popup[i] = options[i];
		}
	}
	if (typeof(modal)=="boolean") {
		popup.modal = modal;
	}
	popup.destroyObjectsOnHide = true;
	popup.show();
	return popup;
};

Popup.showModal = function(divObject, referenceObject, position, options) {
	Popup.show(divObject, referenceObject, position, options, true);
};

Popup.get = function(divId) {
	if (defined(Popup.objectsById[divId])) {
		return Popup.objectsById[divId];
	}
	return null;
};

Popup.hide = function(divId) {
	var popup = Popup.get(divId);
	if (popup!=null) {
		popup.hide();
	}
};

Popup.prototype.content = null;
Popup.prototype.className = "PopupDiv";
Popup.prototype.style = null; 
Popup.prototype.width = null;
Popup.prototype.height = null;
Popup.prototype.top = null;
Popup.prototype.left = null;
Popup.prototype.offsetLeft = 0;
Popup.prototype.offsetTop = 0;
Popup.prototype.constrainToScreen = true;
Popup.prototype.autoHide = true;
Popup.prototype.useIframeShim = false; 
Popup.prototype.iframe = null;
Popup.prototype.position = null; 
Popup.prototype.reference = null;
Popup.prototype.modal = false;
Popup.prototype.destroyDivOnHide = false;
Popup.prototype.destroyObjectsOnHide = false;
Popup.prototype.screen = null;
Popup.prototype.screenIframeShim = null;
Popup.prototype.screenOpacity=.4;
Popup.prototype.screenColor="#cccccc";

Popup.prototype.show = function(options, modal) {
	this.modal = this.modal || (typeof(modal)=="boolean" && modal);
	if (defined(options) && options!=null && typeof(options)=="object") {
		for (var i in options) {
			this[i] = options[i];
		}
	}
	this.div = DOM.resolve(this.div);
	CSS.setStyle(this.div,'position','absolute');
	if (this.div==null) {
		this.div = this.createDiv();
	}
	if (this.content!=null) {
		this.div.innerHTML = this.content;
		this.content = null;
	}
	if (this.className!=null) {
		this.div.className = this.className;
	}
	if (this.style!=null) {
		this.applyStyle();
	}
	if (this.width!=null) {
		this.div.style.width = this.width+"px";
		this.div.style.overflowX="auto";
	}
	if (this.height!=null) {
		this.div.style.height = this.height+"px";
		this.div.style.overflowY="auto";
	}
	this.transition();
	this.div.onclick = function(e) { 
		Event.cancelBubble(Event.resolve(e));
	};
	this.div.onmouseup = this.div.onclick;
	if (this.modal && this.div.focus) {
		this.div.focus();
	}
};

Popup.prototype.transition = function() {
	if (this.modal) {
		this.addScreen();
	}
	CSS.setStyle(this.div,'visibility','hidden');
	CSS.setStyle(this.div,'display','block');
	this.setPosition();
	if (this.useIframeShim) {
		this.addIframeShim();
	}
	this.div.style.zIndex = Popup.minZIndex++;

	CSS.setStyle(this.div,'display','block');
	CSS.setStyle(this.div,'visibility','visible');
};

Popup.prototype.showModal = function(options) {
	this.show(options,true);
};

Popup.prototype.applyStyle = function() {
	if (this.div!=null && this.style!=null && typeof(this.style)=="object") {
		for (var i in this.style) {
			this.div.style[i] = this.style[i];
		}
	}
};

Popup.prototype.hide = function() {
	if (this.destroyDivOnHide) {
		DOM.removeNode(this.div);
		this.div = null;
		delete Popup.objects[this.id];
	}
	else if (this.div!=null) {
		CSS.setStyle(this.div,'display','none');
	}

	if (this.destroyObjectsOnHide) {
		DOM.removeNode(this.iframe);
		DOM.removeNode(this.screen);
		DOM.removeNode(this.screenIframeShim);
	}
	else {
		if (this.iframe!=null) {
			this.iframe.style.display = "none";
		}
		if (this.screen!=null) {
			this.screen.style.display = "none";
		}
		if (this.screenIframeShim!=null) {
			this.screenIframeShim.style.display = "none";
		}
	}
};

Popup.prototype.setTop = function(top) {
	this.div.style.top = top+"px";
};
Popup.prototype.setLeft = function(left) {
	this.div.style.left = left+"px";
};
Popup.prototype.getTop = function() {
	return parseInt(CSS.getStyle(this.div,"top"),10);
};
Popup.prototype.getLeft = function() {
	return parseInt(CSS.getStyle(this.div,"left"),10);
};

Popup.prototype.setPosition = function() {
	if (this.position!=null) {
		var m = this.position.match(/^(\S+)\s+(\S+)/); 
		if (m!=null && m.length==3) {
			var v = m[1];
			var h = m[2];

			var ref = this.reference;
			if (ref==null) { ref = Screen.getBody(); }
			var p = Position.get(ref);
			var refTop = p.top;
			var refLeft = p.left;
			var refWidth = DOM.getOuterWidth(ref);
			var refHeight = DOM.getOuterHeight(ref);
			
			var width = DOM.getOuterWidth(this.div);
			var height = DOM.getOuterHeight(this.div);
			
			var scrollLeft = Screen.getScrollLeft();
			var scrollTop = Screen.getScrollTop();
			if (v=="above") { this.setTop(refTop-height+this.offsetTop); }
			else if (v=="top") { this.setTop(refTop+this.offsetTop); }
			else if (v=="center") { this.setTop(refTop+(refHeight/2)-(height/2)+this.offsetTop); }
			else if (v=="bottom") { this.setTop(refTop+refHeight-height+this.offsetTop); }
			else if (v=="below") { this.setTop(refTop+refHeight+this.offsetTop); }
			if (h=="adjacent-left") { this.setLeft(refLeft-width+this.offsetLeft); }
			else if (h=="left") { this.setLeft(refLeft+this.offsetLeft); }
			else if (h=="center") { this.setLeft(refLeft+(refWidth/2)-(width/2)+this.offsetLeft); }
			else if (h=="right") { this.setLeft(refLeft+refWidth-width+this.offsetLeft); }
			else if (h=="adjacent-right") { this.setLeft(refLeft+refWidth+this.offsetLeft); }
		}
	}
	else if (this.top==null && this.left==null) {
		this.div.style.top = divtoppos+10+"px";
		this.div.style.left =divleftpos+130+"px";
	}
	else {
		if (this.top==null) { this.top=0; }
		if (this.left==null) { this.left=0; }
		this.div.style.top = this.top+this.offsetTop+"px";
		this.div.style.left = this.left+this.offsetLeft+"px";
	}
	if (this.constrainToScreen) {
	//	this.fitToScreen();
	}
};

Popup.prototype.appendToBody = function(o) {
	var body = Screen.getBody();
	if (body && body.appendChild) {
		body.appendChild(o);
	}
};

Popup.prototype.createDiv = function() {
	if (document.createElement) {
		var d = document.createElement("DIV");
		d.style.position="absolute";
		d.style.display="block";
		d.style.visibility="hidden";
		this.appendToBody(d);
		return d;
	}
	alert("ERROR: Couldn't create DIV element in Popup.prototype.createDiv()");
	return null;
};

Popup.prototype.createIframe = function() {
	if (document.createElement) {
		var i= document.createElement("IFRAME");
		i.style.position="absolute";
		i.style.display="block";
		i.style.visibility="hidden";
		i.style.background="none";
		this.appendToBody(i);
		return i;
	}
	else {
		alert("ERROR: Couldn't create IFRAME object in Popup.prototype.createIframe()");
	}
};

Popup.prototype.addScreen = function() {
	if (this.screen==null) {
		this.screen = this.createDiv();
		this.screen.style.top="0px";
		this.screen.style.left="0px";
		this.screen.style.backgroundColor = this.screenColor;
		this.screen.className=Popup.screenClass;;
		CSS.setStyle(this.screen,"opacity",this.screenOpacity);
		this.screen.onclick = function(e) { 
			Event.cancelBubble(Event.resolve(e)); 
			if(notification_opened)
				close_note();
			}
	}
	if (this.screenIframeShim==null) {
		this.screenIframeShim = this.createIframe();
		this.screenIframeShim.style.top="0px";
		this.screenIframeShim.style.left="0px";
		this.screenIframeShim.className=Popup.screenIframeClass;
		CSS.setStyle(this.screenIframeShim,"opacity",0);
	}
	this.screen.style.width = Screen.getDocumentWidth()+"px";
	this.screen.style.height = Screen.getDocumentHeight()+"px";
	this.screenIframeShim.style.width = Screen.getDocumentWidth()-20+"px";
	this.screenIframeShim.style.height = Screen.getDocumentHeight()-10+"px";
	this.screenIframeShim.style.zIndex = Popup.minZIndex++;
	this.screenIframeShim.style.visibility="visible";
	this.screenIframeShim.style.display="block";
	this.screen.style.zIndex = Popup.minZIndex++;
	this.screen.style.visibility="visible";
	this.screen.style.display="block";
};
-->
