var global_var1;
var xmlHttp;

function MM_preloadImages() { //v3.0
	var d=document;
	if (d.images) {
		if (!d.MM_p) d.MM_p=new Array();
		var i,j=d.MM_p.length,a=MM_preloadImages.arguments;
		for(i=0; i<a.length; i++)
			if (a[i].indexOf("#")!=0) {
				d.MM_p[j]=new Image;
				d.MM_p[j++].src=a[i];
			}
	}
}

function MM_swapImgRestore() { //v3.0
	var i,x,a=document.MM_sr;
	for(i=0;a && i<a.length && (x=a[i]) && x.oSrc;i++)
		x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
	var p,i,x;
	if (!d)
		d=document;
	if ((p=n.indexOf("?"))>0 && parent.frames.length) {
		d=parent.frames[n.substring(p+1)].document;
		n=n.substring(0,p);
	}
	if (!(x=d[n]) && d.all)
		x=d.all[n];
	for (i=0;!x && i<d.forms.length;i++)
		x=d.forms[i][n];
	for (i=0;!x && d.layers && i<d.layers.length;i++)
		x=MM_findObj(n,d.layers[i].document);
	if (!x && document.getElementById)
		x=document.getElementById(n);
	return x;
}

function MM_swapImage() { //v3.0
	var i,j=0,x,a=MM_swapImage.arguments;
	document.MM_sr=new Array;
	for(i=0;i<(a.length-2);i+=3)
	if ((x=MM_findObj(a[i]))!=null) {
		document.MM_sr[j++]=x;
		if (!x.oSrc)
			x.oSrc=x.src;
		x.src=a[i+2];
	}
}

function NewWindow(mypage, myname, w, h, scroll)
{
	var winl = (screen.width - w) / 2;
	var wint = (screen.height - h) / 2;
	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+''
	win = window.open(mypage, myname, winprops)

	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }

}

/* clickable stuff */

function go(url)
{
    try
    {
        window.location = url;
    }
    catch (e) { ; }
}

function makeHandOver()
{
    try
    {
        // The cursor is a pointer that indicates a link. CSS2 18.1

        // crappy way that doesn't work anywhere:
        //document.classes.rsb.all.cursor = "pointer";

        // Here's what Apple recommend
        // http://developer.apple.com/internet/javascript/styles.html
        var myStyle = document.styleSheets[0].cssRules["rsb"].style;
        myStyle.cursor = "pointer";

        document.styleSheets.all.cssRules["rsb"].style.cursor = "pointer";

    }
    catch (e) { ; }
}

/* advertising */

function launchClickthruFromFlash(url)
{
    try
    {
        //::adid
        window.location = '/adverts/redirect.wdj?advert='+adid;
    }
    catch (e) { ; }
}

function flashClick()
{

    try
    {
		var URL = '/adverts/redirect.wdj?advert=';

		if (navigator.userAgent.indexOf("MSIE") != -1)
			window.location.href = URL+"df70e354";
		else
			window.location = URL+adid;
    }
    catch (e) { ; }
}

function refresh()
{
    window.location.reload( false );
}

function limitSelection(oSelect, limit){
	var count = 0;
	var i = 0;
	for(i ; i < oSelect.length; i++){
		if (oSelect[i].selected){
			oHistory = i;
			count++;
		}
		if (count > limit){
			oSelect[oHistory].selected = false;
			//alert("You're only allowed " + limit + " selections."); //optional
			break;
		}
	}
}

function SHU(fieldName, value, unhideValues, dropdown)
{
	SelectionHideUnhide(fieldName+'_tr', value, unhideValues);
	if ( dropdown )
		SelectionHideUnhide(fieldName+'_dd', value, unhideValues);
//	if ( document.getElementById(fieldName).style.display == 'block' )
//		document.getElementById(fieldName).focus();
}

function SelectionHideUnhide(fieldName, value, unhideValues) {
	var field = document.getElementById(fieldName);
	var display_value = 'none';
	for(var i = 0;i<unhideValues.length;i++)
	{
		if (value == unhideValues[i])
		  display_value = 'block';
	}
	field.style.display = display_value;
}

function display_toggle(field_name, label, title1, title2) {
	if ( document.getElementById(field_name).style.display  == 'none' ) {
		document.getElementById(field_name).style.display = 'block';
		document.getElementById(label).innerHTML = title2;
	} else {
		document.getElementById(field_name).style.display = 'none';
		document.getElementById(label).innerHTML = title1;
	}
}

/* Editing friends */
function d_confirm(nick,time,id) {
	var o_string = "Are you sure you want to delete "+nick+" from your friend list?";
	//var o_string = "Are you sure you want to delete?";
	if (confirm(o_string)) {
		window.location = "/friend/editFriend.wdj?no-cache="+time+"&fid="+id;
	}
}

function goTo(page) {

	var o_string = "Do you want to save the changes in this page?";
	var mm = document.info.mod.value;
	if (mm=="Yes") {
		if (confirm(o_string)) {
			document.info.change.value = "Yes";
			document.info.my_submit.value = "..:: Change ::..";
		}
		else {
			document.info.change.value = "No";
			document.info.my_submit.value = "";
		}
	}
	else {
		document.info.change.value = "No";
		document.info.my_submit.value = "";
	}

	document.info.page.value = page;
	document.info.submit();
}

function goTo_dj(page) {
	document.info.page.value = page;
	document.info.submit();
}

function goTo_create(page) {
	document.info.page1.value = page;
	//document.info.my_submit.value = "Next";
	document.info.submit();
}

function goTo1(doit) {
	var j=0;
	document.box.action.value = doit;
	document.box.submit();
}

function selectAll(oo) {
	for (i=0;i<box.length;i++) {
		if (box.elements[i].type == "checkbox")
			box.elements[i].checked=oo.checked
	}
}

function dis(text) {
	var detect = navigator.userAgent.toLowerCase();
	if ((detect.indexOf('mac')+1))
		alert('It is a Mac');
	else
		alert('It is not a Mac');
}

function mod1() {
	document.info.mod.value = "Yes";
}

function jumpTo(page, range, type) {
	document.friend.my_submit.value = "Search";
	document.friend.page.value = page;
	document.friend.range.value = range;
	document.friend.type.value = type;
	document.friend.submit();
}

function LimitText(fieldObj,maxChars) {

	var result = true;

	if (fieldObj.value.length >= maxChars) {
		result = false;
		fieldObj.value = fieldObj.value.substring(0,maxChars);
		alert("You can't type in more than "+maxChars+" in this area.");
	}
	if (!checkIt())
		if (window.event)
			window.event.returnValue = result;

	return result;
}

function checkIt() {
	//var OSName="Unknown OS";
	//if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
	//if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
	//if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
	//if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";

	if (navigator.appVersion.indexOf("Mac")!=-1)
		return true;
	else
		return false;
}

function addSelect(oo) {

	var newIndex = oo.options[oo.selectedIndex].value;
	var newIndex1 = oo.options[oo.selectedIndex].text;

	//var oldIndex = document.forms[1].to_name.value;
	var thisForm = oo.form;
	var oldIndex = thisForm.to_name.value;
	var oldText = thisForm.to_name1.value;

	var m_index = new Array();
	var m_text = new Array();
	var i = 0;
	var cou = 0;
	while (oldIndex.length>0) {
		i = oldIndex.indexOf(",");
		if (i>0) {
			m_index[cou] = oldIndex.substring(0,i);
			cou++;
			oldIndex = oldIndex.substring(i+1);
		}
		else {
			m_index[cou] = oldIndex;
			cou++;
			oldIndex = "";
		}
	}

	var m_text = new Array();
	i = 0;
	cou = 0;
	while (oldText.length>0) {
		i = oldText.indexOf(",");
		if (i>0) {
			m_text[cou] = oldText.substring(0,i);
			cou++;
			oldText = oldText.substring(i+1);
		}
		else {
			m_text[cou] = oldText;
			cou++;
			oldText = "";
		}
	}

	var sum = "";
	var sum1 = "";
	var flag = 5;
	for (var i=0; i<m_index.length; i++) {
		if (m_index[i]!=newIndex) {
			if (sum=="") {
				sum = m_index[i];
			}
			else {
				sum = sum + "," + m_index[i];
			}
		}
		else
			flag = 1;
	}
	if (flag==5) {
		if (sum=="")
			sum = newIndex;
		else
			sum = sum + "," + newIndex;
	}

	flag = 5;
	for (var i=0; i<m_text.length; i++) {
		if (m_text[i]!=newIndex1) {
			if (sum1=="") {
				sum1 = m_text[i];
			}
			else {
				sum1 = sum1 + "," + m_text[i];
			}
		}
		else
			flag = 1;
	}
	if (flag==5) {
		if (sum1=="")
			sum1 = newIndex1;
		else
			sum1 = sum1 + "," + newIndex1;
	}

	thisForm.to_name.value = sum;
	thisForm.to_name1.value = sum1;
}

function addSelect_G(oo) {

	var newIndex = oo.options[oo.selectedIndex].value;
	var thisForm = oo.from;
	var oldIndex = thisForm.to_name.value;

	var m_index = new Array();
	var i = 0;
	var cou = 0;
	while (oldIndex.length>0) {
		i = oldIndex.indexOf(",");
		if (i>0) {
			m_index[cou] = oldIndex.substring(0,i);
			cou++;
			oldIndex = oldIndex.substring(i+1);
		}
		else {
			m_index[cou] = oldIndex;
			cou++;
			oldIndex = "";
		}
	}

	var sum = "";
	var sum1 = "";
	var flag = 5;
	for (var i=0; i<m_index.length; i++) {
		if (m_index[i]!=newIndex) {
			if (sum=="") {
				sum = m_index[i];
			}
			else {
				sum = sum + "," + m_index[i];
			}
		}
		else
			flag = 1;
	}
	if (flag==5) {
		if (sum=="")
			sum = newIndex;
		else
			sum = sum + "," + newIndex;
	}

	document.forms[1].to_name.value = sum;
}

function d_p_confirm(time,action,name,page,magic,magic1,tab) {
	var o_string = "Are you sure you want to delete the photo " +name+" ?";
	if (confirm(o_string)) {
		if (page=="g")
			window.location = "/heads/photo/photoupload_group.wdj?no-cache="+time+"&a="+action+"&pic="+name+"&magic="+magic+"&magic1="+magic1;
		else
			if (page=="w")
				window.location = "/heads/photo/photoupload_website.wdj?a="+action+"&pic="+name+"&magic="+magic1+"&tab="+tab;
			else
				window.location = "/heads/photo/photoupload.wdj?no-cache="+time+"&a="+action+"&pic="+name+"&magic1="+magic1;
	}
}

function d_p_confirm1(time,action,name,roofle_id) {
	var o_string = "Are you sure you want to delete the photo " +name+" ?";
	if (confirm(o_string)) {
		window.location = "/heads/photo/?no-cache="+time+"&a="+action+"&pic="+name+"&roofle_id="+roofle_id;
	}
}

function addToList(form) {
	var length=form.email_list.length;
	var name = form.fname.value;
	var email = form.femail.value;
	var f_to = "";
	var same = 0;
	for (var i=0; i<length; i++) {
		if (f_to=="")
			f_to = form.email_list.options[i].text;
		else
			f_to = f_to + ";" +form.email_list.options[i].text;
		if (form.email_list.options[i].value==email)
			same = 1;
	}
	if (same==0 && (email.length>1)) {
		form.email_list.options[length] = new Option(name+" ("+email+")", email, false, false);
		if (f_to=="")
			f_to = name+" ("+email+")";
		else
			f_to = f_to + ";" + name+" ("+email+")";
	}
	form.to.value = f_to;
	form.fname.value = "";
	form.femail.value = "";
}

function deleteToList(form) {

	var ind = form.email_list.selectedIndex;
	form.email_list.options[ind] = null;
	var f_to = "";
	for (var i=0; i<form.email_list.length; i++) {
		if (f_to=="")
			f_to = form.email_list.options[i].text;
		else
			f_to = f_to + ";" +form.email_list.options[i].text;
	}
	form.to.value = f_to;

}

function changetext(form) {
	var namefirst = form.fnamefirst.value;
	var j_field = document.getElementById("jText1");

	if (namefirst.length>0)
		j_field.innerHTML = namefirst;
	else
		j_field.innerHTML = "(YourFriend's name)";

}

function changetext1(form) {
	var o_body = form.o_body.value;
	var j_field = document.getElementById("jText2");

	var maxlength=40;

	var s_body = o_body.split(" ");
	var temp = "";
	var temp1 = "";
	var len = 0;
	for (i=0;i<s_body.length;i++) {
		temp1 = s_body[i];
		while (temp1.length>maxlength) {
			temp = temp+temp1.substr(0,maxlength)+" ";
			len += maxlength+1;
			if (len>70) {
				temp = temp+"\n";
				len = 0;
			}
			temp1 = temp1.substr(maxlength);
		}
		temp = temp+temp1+" ";
		len += temp1.length+1;
		if (len>70) {
			temp = temp+"\n";
			len = 0;
		}
	}

	o_body = temp;
	//replace new line
	rExp = /\n/g;
	newString = "<br>";
	o_body = o_body.replace(rExp, newString);

	//replace space
	rExp = / /g;
	newString = "&nbsp;";
	o_body = o_body.replace(rExp, newString);

	if (o_body.length>0)
		j_field.innerHTML = o_body;
	else
		j_field.innerHTML = "(YourMessageWillAppearHere)";
}

function delete_confirm(group_id,member_type) {
	if (member_type=="moderator")
		var o_string = "Are you sure you want to delete this channel? Once a channel is deleted, it can be restored again.";
	else
		var o_string = "Are you sure you want to unjoin this channel?";

	if (confirm(o_string)) {
		if (member_type=="moderator") {
			window.location = "/group/deleteGroup.wdj?group_id="+group_id;
		}
		else
			window.location = "/group/unjoinGroup.wdj?group_id="+group_id;
	}
}

function delete_confirm_GM(group_id,member_id) {
	var o_string = "Are you sure you want to delete this member from this channel?";
	if (confirm(o_string)) {
		window.location = "/group/deleteMember.wdj?group="+group_id+"&member="+member_id;
	}
}

function delete_confirm_GM1(group_id,member_id) {
	var o_string = "Are you sure you want to delete this member from this channel?";
	if (confirm(o_string)) {
		window.location = "/group/deleteMember1.wdj?group="+group_id+"&member="+member_id;
	}
}

function swap(oo,oo1,list,list1,output) {

	mod1();
	var oldValue = oo.options[oo.selectedIndex].value;
	var oldText = oo.options[oo.selectedIndex].text;

	var index = "";
	oo.options[oo.selectedIndex] = null;
	var mode = 0;
	var iValue = "";
	var iText = "";
	for (var i=0;i<oo1.length;i++) {
		if (mode==0) {
			if (oldText<oo1.options[i].text) {
				iValue = oo1.options[i].value;
				iText = oo1.options[i].text;
				oo1.options[i].value = oldValue;
				oo1.options[i].text = oldText;
				mode = 1;
			}
		}
		else {
			tempValue = oo1.options[i].value;
			tempText = oo1.options[i].text;
			oo1.options[i].value = iValue;
			oo1.options[i].text = iText;
			iValue = tempValue;
			iText = tempText;
		}
	}

	if (mode==1)
		oo1.options[oo1.length] = new Option(iText, iValue, false, false);
	else
		oo1.options[oo1.length] = new Option(oldText, oldValue, false, false);

	for (var i=0;i<list.length;i++) {
		if (i==0)
			index = list.options[i].value;
		else
			index = index+","+list.options[i].value;
	}

	for (var i=0;i<list1.length;i++) {
		if (index=="")
			index = list1.options[i].value;
		else
			index = index+","+list1.options[i].value;
	}
	output.value = index;
}

function swap2(oo,oo1,list,list1,output) {

	mod1();
	var sel = new Array(oo.length);
	var sel1 = new Array(oo.length);
	var cou = 0;
	for(k=0; k<oo.length; k++) {
		if (oo[k].selected) {
			sel[cou] = k;
			sel1[cou] = oo[k].value;
			cou += 1;
		}
	}

	for(k=0; k<cou; k++) {
		oldValue = oo[sel[k]].value;
		oldText = oo[sel[k]].text;
		//oo.options[sel[k]] = null;
		mode = 0;
		iValue = "";
		iText = "";
		for (var i=0;i<oo1.length;i++) {
			if (mode==0) {
				if (oldText<oo1.options[i].text) {
					iValue = oo1.options[i].value;
					iText = oo1.options[i].text;
					oo1.options[i].value = oldValue;
					oo1.options[i].text = oldText;
					mode = 1;
				}
			}
			else {
				tempValue = oo1.options[i].value;
				tempText = oo1.options[i].text;
				oo1.options[i].value = iValue;
				oo1.options[i].text = iText;
				iValue = tempValue;
				iText = tempText;
			}
		}
		if (mode==1)
			oo1.options[oo1.length] = new Option(iText, iValue, false, false);
		else
			oo1.options[oo1.length] = new Option(oldText, oldValue, false, false);

	}

	for(k=0; k<cou; k++) {
		for (j=0; j<oo.length;j++) {
			if (sel1[k]==oo[j].value) {
				oo[j] = null;
				break;
			}
		}
	}

	index = "";
	for (var i=0;i<list.length;i++) {
		if (i==0)
			index = list.options[i].value;
		else
			index = index+","+list.options[i].value;
	}

	for (var i=0;i<list1.length;i++) {
		if (index=="")
			index = list1.options[i].value;
		else
			index = index+","+list1.options[i].value;
	}
	output.value = index;
}

function swap3(oo,oo1,list,output) {

	mod1();
	var sel = new Array(oo.length);
	var sel1 = new Array(oo.length);
	var cou = 0;
	for(k=0; k<oo.length; k++) {
		if (oo[k].selected) {
			sel[cou] = k;
			sel1[cou] = oo[k].value;
			cou += 1;
		}
	}

	for(k=0; k<cou; k++) {
		oldValue = oo[sel[k]].value;
		oldText = oo[sel[k]].text;
		mode = 0;
		iValue = "";
		iText = "";
		for (var i=0;i<oo1.length;i++) {
			if (mode==0) {
				if (oldText<oo1.options[i].text) {
					iValue = oo1.options[i].value;
					iText = oo1.options[i].text;
					oo1.options[i].value = oldValue;
					oo1.options[i].text = oldText;
					mode = 1;
				}
			}
			else {
				tempValue = oo1.options[i].value;
				tempText = oo1.options[i].text;
				oo1.options[i].value = iValue;
				oo1.options[i].text = iText;
				iValue = tempValue;
				iText = tempText;
			}
		}
		if (mode==1)
			oo1.options[oo1.length] = new Option(iText, iValue, false, false);
		else
			oo1.options[oo1.length] = new Option(oldText, oldValue, false, false);

	}

	for(k=0; k<cou; k++) {
		for (j=0; j<oo.length;j++) {
			if (sel1[k]==oo[j].value) {
				oo[j] = null;
				break;
			}
		}
	}

	var index = "";
	for (var i=0;i<list.length;i++) {
		if (i==0)
			index = list.options[i].value;
		else
			index = index+","+list.options[i].value;
	}
	output.value = index;
}

function swap1(oo,oo1,list,output) {

	mod1();
	var oldValue = oo.options[oo.selectedIndex].value;
	var oldText = oo.options[oo.selectedIndex].text;

	var index = "";
	var i =0;
	oo.options[oo.selectedIndex] = null;
	var mode = 0;
	var iValue = "";
	var iText = "";
	for (i=0;i<oo1.length;i++) {
		if (mode==0) {
			if (oldText<oo1.options[i].text) {
				iValue = oo1.options[i].value;
				iText = oo1.options[i].text;
				oo1.options[i].value = oldValue;
				oo1.options[i].text = oldText;
				mode = 1;
			}
		}
		else {
			tempValue = oo1.options[i].value;
			tempText = oo1.options[i].text;
			oo1.options[i].value = iValue;
			oo1.options[i].text = iText;
			iValue = tempValue;
			iText = tempText;
		}
	}
	if (mode==1)
		oo1.options[oo1.length] = new Option(iText, iValue, false, false);
	else
		oo1.options[oo1.length] = new Option(oldText, oldValue, false, false);

	index = "";
	for (i=0;i<list.length;i++) {
		if (i==0)
			index = list.options[i].value;
		else
			index = index+","+list.options[i].value;
	}

	output.value = index;
}

function placeFocus() {
	if (document.forms.length > 0) {
		for (i=0;i<document.forms.length; i++) {
			form1 = document.forms[i];
			if (form1.name=="compose" || form1.name=="edit" || form1.name=="post") {
				for (i = 0; i < form1.length; i++) {
					if (form1.elements[i].name == "body") {
						form1.elements[i].focus();
						return;
					}
				}
			}
		}
	}
}

function placeFocus1() {
	if (document.forms.length > 0) {
		for (i=0;i<document.forms.length; i++) {
			form1 = document.forms[i];
			for (i = 0; i < form1.length; i++) {
				if (form1.elements[i].type == "text") {
					form1.elements[i].focus();
					return;
				}
			}
		}
	}
}

function roofle_swap(oo,oo1,list,output) {
	var oldValue = oo.options[oo.selectedIndex].value;
	var oldText = oo.options[oo.selectedIndex].text;

	var index = "";
	var i =0;
	oo.options[oo.selectedIndex] = null;
	var mode = 0;
	var iValue = "";
	var iText = "";
	for (i=0;i<oo1.length;i++) {
		if (mode==0) {
			if (oldText<oo1.options[i].text) {
				iValue = oo1.options[i].value;
				iText = oo1.options[i].text;
				oo1.options[i].value = oldValue;
				oo1.options[i].text = oldText;
				mode = 1;
			}
		}
		else {
			tempValue = oo1.options[i].value;
			tempText = oo1.options[i].text;
			oo1.options[i].value = iValue;
			oo1.options[i].text = iText;
			iValue = tempValue;
			iText = tempText;
		}
	}
	if (mode==1)
		oo1.options[oo1.length] = new Option(iText, iValue, false, false);
	else
		oo1.options[oo1.length] = new Option(oldText, oldValue, false, false);

	index = "";
	for (i=0;i<list.length;i++) {
		if (i==0)
			index = list.options[i].value;
		else
			index = index+","+list.options[i].value;
	}

	output.value = index;
}

function roofle_remove_all(oo, output) {
	var sel = new Array(oo.length);
	var cou = 0;
	for(k=0; k<oo.length; k++) {
		if (oo[k].selected) {
			sel[cou] = oo[k].value;
			cou += 1;
		}
	}

	for(k=0; k<cou; k++) {
		for (j=0; j<oo.length;j++) {
			if (sel[k]==oo[j].value) {
				oo[j] = null;
				break;
			}
		}
	}

	var index = "";
	for (var i=0;i<oo.length;i++) {
		if (i==0)
			index = oo.options[i].value;
		else
			index = index+","+oo.options[i].value;
	}
	output.value = index;
}

function roofle_swap_all(oo,oo1,list,output) {
	var sel = new Array(oo.length);
	var sel1 = new Array(oo.length);
	var cou = 0;
	for(k=0; k<oo.length; k++) {
		if (oo[k].selected && oo[k].value>0) {
			sel[cou] = k;
			sel1[cou] = oo[k].value;
			cou += 1;
		}
	}

	for(k=0; k<cou; k++) {
		oldValue = oo[sel[k]].value;
		oldText = oo[sel[k]].text;
		//oo.options[sel[k]] = null;
		mode = 0;
		iValue = "";
		iText = "";
		for (var i=0;i<oo1.length;i++) {
			if (mode==0) {
				if (oldText<oo1.options[i].text) {
					iValue = oo1.options[i].value;
					iText = oo1.options[i].text;
					oo1.options[i].value = oldValue;
					oo1.options[i].text = oldText;
					mode = 1;
				}
			}
			else {
				tempValue = oo1.options[i].value;
				tempText = oo1.options[i].text;
				oo1.options[i].value = iValue;
				oo1.options[i].text = iText;
				iValue = tempValue;
				iText = tempText;
			}
		}
		if (mode==1)
			oo1.options[oo1.length] = new Option(iText, iValue, false, false);
		else
			oo1.options[oo1.length] = new Option(oldText, oldValue, false, false);

	}

	for(k=0; k<cou; k++) {
		for (j=0; j<oo.length;j++) {
			if (sel1[k]==oo[j].value) {
				oo[j] = null;
				break;
			}
		}
	}

	var index = "";
	for (var i=0;i<list.length;i++) {
		if (i==0)
			index = list.options[i].value;
		else
			index = index+","+list.options[i].value;
	}
	output.value = index;
}

function filter(o) {
	if (arguments[1] != null) {
		event = arguments[1];
	}
    var keyCode = event.keyCode;
}

function countdown_clock(year, month, day, hour, minute, format) {
	//I chose a div as the container for the timer, but
	//it can be an input tag inside a form, or anything
	//who's displayed content can be changed through
	//client-side scripting.
	html_code = '<div id="countdown"></div>';
	document.write(html_code);

	countdown(year, month, day, hour, minute, format);
}

function countdown(year, month, day, hour, minute, format) {
	Today = new Date();
	Todays_Year = Today.getYear() - 2000;
	Todays_Month = Today.getMonth() + 1;

	//Convert both today's date and the target date into miliseconds.
	Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(),
						 Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();
	Target_Date = (new Date(year, month, day, hour, minute, 00)).getTime();

	//Find their difference, and convert that into seconds.
	Time_Left = Math.round((Target_Date - Todays_Date) / 1000);

	if (Time_Left < 0)
		Time_Left = 0;
	switch(format) {
		case 0:
			//The simplest way to display the time left.
			document.all.countdown.innerHTML = Time_Left + ' seconds';
			break;
		case 1:
			//More detailed.
			Time_Left1 = Time_Left;
			days = Math.floor(Time_Left / (60 * 60 * 24));
			Time_Left %= (60 * 60 * 24);
			hours = Math.floor(Time_Left / (60 * 60));
			Time_Left %= (60 * 60);
			minutes = Math.floor(Time_Left / 60);
			Time_Left %= 60;
			seconds = Time_Left;
			dps = 's'; hps = 's'; mps = 's'; sps = 's';
			//ps is short for plural suffix.
			if (days == 1)
				dps ='';
			if (hours == 1)
				hps ='';
			if (minutes == 1)
				mps ='';
			if (seconds == 1)
				sps ='';
			document.all.countdown.innerHTML = "Begins in ";
			if (days>0)
				document.all.countdown.innerHTML += days + ' day' + dps + ' ';
			if (hours>0)
				document.all.countdown.innerHTML += hours + ' hour' + hps + ' ';
			if (minutes>0)
				document.all.countdown.innerHTML += minutes + ' minute' + mps;
			if (seconds>0)
				document.all.countdown.innerHTML += " and " + seconds + ' second' + sps;
			if (Time_Left1<=0)
				document.all.countdown.innerHTML = 'On Air';
			break;
		default:
			document.all.countdown.innerHTML = Time_Left + ' seconds';
	}

	//Recursive call, keeps the clock ticking.
	setTimeout('countdown(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ');', 1000);
 }

 function countdown_clock1(year, month, day, hour, minute, format) {
 	//I chose a div as the container for the timer, but
 	//it can be an input tag inside a form, or anything
 	//whose displayed content can be changed through
 	//client-side scripting.
 	html_code = '<div id="countdown"></div>';
 	document.write(html_code);

 	countdown1(year, month, day, hour, minute, format);
 }

 function countdown1(year, month, day, hour, minute, format) {
 	Today = new Date();
 	Todays_Year = Today.getYear() - 2000;
 	Todays_Month = Today.getMonth() + 1;

 	//Convert both today's date and the target date into miliseconds.
 	Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(),
 						 Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();
 	Target_Date = (new Date(year, month, day, hour, minute, 00)).getTime();

 	//Find their difference, and convert that into seconds.
 	Time_Left = Math.round((Target_Date - Todays_Date) / 1000);

 	if (Time_Left < 0)
 		Time_Left = 0;
 	switch(format) {
 		case 0:
 			//The simplest way to display the time left.
 			document.all.countdown.innerHTML = Time_Left + ' seconds';
 			break;
 		case 1:
 			//More datailed.
 			Time_Left1 = Time_Left;
 			days = Math.floor(Time_Left / (60 * 60 * 24));
 			Time_Left %= (60 * 60 * 24);
 			hours = Math.floor(Time_Left / (60 * 60));
 			Time_Left %= (60 * 60);
 			minutes = Math.floor(Time_Left / 60);
 			Time_Left %= 60;
 			seconds = Time_Left;
 			dps = 's'; hps = 's'; mps = 's'; sps = 's';
 			//ps is short for plural suffix.
 			if (days == 1) dps ='';
 			if (hours == 1) hps ='';
 			if (minutes == 1) mps ='';
 			if (seconds == 1) sps ='';
 			document.all.countdown.innerHTML = "On Air: ";
 			if (minutes>0) {
 				document.all.countdown.innerHTML += minutes + ' min' + mps;
 				if (seconds>0)
 					document.all.countdown.innerHTML += ' and ';
			}
 			if (seconds>0)
 				document.all.countdown.innerHTML += seconds + ' sec' + sps;
 			if (Time_Left1<=0)
 				document.all.countdown.innerHTML = 'Now on Air';
 			break;
 		default:
 			document.all.countdown.innerHTML = Time_Left + ' secs';
 	}

 	//Recursive call, keeps the clock ticking.
 	setTimeout('countdown1(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ');', 1000);
 }

 function countdown_clock2(year, month, day, hour, minute, format) {
  	html_code = '<div id="countdown"></div>';
  	document.write(html_code);

  	countdown1(year, month, day, hour, minute, format);
 }

 function countdown2(year, month, day, hour, minute, format) {
  	Today = new Date();
  	Todays_Year = Today.getYear() - 2000;
  	Todays_Month = Today.getMonth() + 1;

  	//Convert both today's date and the target date into miliseconds.
  	Todays_Date = (new Date(Todays_Year, Todays_Month, Today.getDate(),
  						 Today.getHours(), Today.getMinutes(), Today.getSeconds())).getTime();
  	Target_Date = (new Date(year, month, day, hour, minute, 00)).getTime();

  	//Find their difference, and convert that into seconds.
  	Time_Left = Math.round((Target_Date - Todays_Date) / 1000);

  	if (Time_Left < 0)
  		Time_Left = 0;
  	switch(format) {
  		case 0:
  			//The simplest way to display the time left.
  			document.all.countdown.innerHTML = Time_Left + ' seconds';
  			break;
  		case 1:
  			//More datailed.
  			Time_Left1 = Time_Left;
  			days = Math.floor(Time_Left / (60 * 60 * 24));
  			Time_Left %= (60 * 60 * 24);
  			hours = Math.floor(Time_Left / (60 * 60));
  			Time_Left %= (60 * 60);
  			minutes = Math.floor(Time_Left / 60);
  			Time_Left %= 60;
  			seconds = Time_Left;
  			dps = 's'; hps = 's'; mps = 's'; sps = 's';
  			//ps is short for plural suffix.
  			if (days == 1)
  				dps ='';
  			if (hours == 1)
  				hps ='';
  			if (minutes == 1)
  				mps ='';
  			if (seconds == 1)
  				sps ='';
  			document.all.countdown.innerHTML = "On Air: ";
  			if (minutes>0) {
  				document.all.countdown.innerHTML += minutes + ' min' + mps;
  				if (seconds>0)
  					document.all.countdown.innerHTML += ' and ';
 			}
  			if (seconds>0)
  				document.all.countdown.innerHTML += seconds + ' sec' + sps;
  			if (Time_Left1<=0)
  				document.all.countdown.innerHTML = 'Now on Air';
  			break;
  		default:
  			document.all.countdown.innerHTML = Time_Left + ' secs';
  	}

  	//Recursive call, keeps the clock ticking.
  	setTimeout('countdown2(' + year + ',' + month + ',' + day + ',' + hour + ',' + minute + ',' + format + ');', 1000);
 }

 function write_control( text ) {
   	document.write(text);
 }

 function change_song(o, o1, o2) {
	//	var s = '<object type="application/x-shockwave-flash" \
	//	width="400" height="30" data="http://www.worlddj.com/music_downloads/xspf_player_slim.swf?autoload=true&song_title=\
	//	' + o + '&sid=' + o1 + '&fid=' + o2 + '&aa=t"><param name="movie" \
	//	value="http://www.worlddj.com/music_downloads/xspf_player_slim.swf?autoload=true&song_title=\
	//	' + o + '&sid=' + o1 + '&fid=' + o2 + '&aa=t" /><param name="wmode" value="transparent"></object>';

	var s = '<embed width="400" height="30" wmode="transparent" menu="true" loop="true" play="true" src="http://www.worlddj.com/music_downloads/xspf_player_slim.swf?autoload=true&song_title=' + o + '&sid=' + o1 + '&fid=' + o2 + '&aa=t" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed>';
	document.getElementById("player").innerHTML = s;
 }


function createXMLHttpRequest() {
	if (window.ActiveXObject) {
		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if (window.XMLHttpRequest) {
		xmlHttp = new XMLHttpRequest();
	}
}

function findNames(sid) {
	createXMLHttpRequest();
	var sname = document.getElementById("autocom").value;
	var url = "/php/ajax_server1.php?sname="+sname+ "&id="+ sid +"&ts="+ new Date().getTime();
	document.getElementById("progress").innerHTML = "Searching...";
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = callback;
	xmlHttp.send(null);
}

function findNames1(sid, attribute, width, style) {
	createXMLHttpRequest();
	var sname = document.getElementById("autocom").value;
	var url = "/php/ajax_server2.php?sname="+sname+ "&id="+ sid +"&attribute=" + attribute + "&width=" + width + "&style=" + style + "&ts="+ new Date().getTime();
	document.getElementById("progress").innerHTML = "Searching...";
	xmlHttp.open("GET", url, true);
	xmlHttp.onreadystatechange = callback;
	xmlHttp.send(null);
}

function callback() {
	if (xmlHttp.readyState == 4) {
		if (xmlHttp.status == 200) {
			document.getElementById("progress").innerHTML = "";
			document.getElementById("result").innerHTML = xmlHttp.responseText;
		}
	}
}

