/* Browser Detection */
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;

/** IMAGES **/
function ViewImage(picurl){
	win=window.open('/ns3/web/popups/viewimage.php?picurl=' + picurl, '', 'width=200,height=200,resizable=1,scrollbars=1');
	win.opener=self; 
	if (!is_chrome) 
		win.moveTo(100,100);
}
function goButton(btName, Action) {
 if (document.images)
  eval('document.getElementById(\''+btName+'\').src='+btName+'_'+Action+'.src');
}

/** SEARCH BUTTON **/
search_button_normal = '';
search_button_press = '';
search_button_hover = '';
function setupSearchButton(path) {
  if (document.images) {
    search_button_normal=new Image(); search_button_normal.src = path + "search_button.gif"; 
    search_button_press =new Image(); search_button_press.src  = path + "search_button_press.gif"; 
    search_button_hover =new Image(); search_button_hover.src  = path + "search_button_over.gif"; 
  }
}

/** POPUP **/
function linkto(href, closewindowyes){
	if (window.opener) {
		window.opener.location.href = href;
		if (closewindowyes){
			window.close();
		}
	} else {
		document.location.href = href;
	}
}
function ReadMessage(from) {
	if (from == 'inbox')
		win=window.open('/web/popups/messageinbox','msg','width=720,height=480,resizable=1,scrollbars=1');
	else
		win=window.open('/web/popups/messageread/member_id/' + from,'msg','width=720,height=480,resizable=1,scrollbars=1');
//	win.opener=self; 
	if (!is_chrome) 
	 	win.moveTo(screen.width/2-360,screen.height/2-200); 
}
function LP(member_id) {
	win=window.open('/web/members/profile/hide_header/1/member_id/' + member_id,'msg','width=720,height=480,resizable=1,scrollbars=1');
//	win.opener=self; 
	if (!is_chrome)
		win.moveTo(screen.width/2-360,screen.height/2-200);
}

/** HELP MODAL **/
helpModlObj = new DHTML_modalMessage();	// We only create one object of this class
helpModlObj.setShadowOffset(5);	// Large shadow
function modalHelpPop(url, cssClass) {
	helpModlObj.setSize(500,330);
	helpModlObj.setCssClassMessageBox(cssClass);
	helpModlObj.setSource(url);
	helpModlObj.setShadowDivVisible(true);	// Enabe or Disable shadow for these boxes	
	helpModlObj.display();
}
function modalHelpPopStatic(html, cssClass) {
	helpModlObj.setSize(500,330);
	helpModlObj.setCssClassMessageBox(cssClass);
	helpModlObj.setHtmlContent(html); 
	helpModlObj.setShadowDivVisible(true);	// Enabe or Disable shadow for these boxes	
	helpModlObj.display();

}
function modalHelpPopClose(){
	helpModlObj.close();	
}

/** COOKIE MANAGEMENT **/
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}
function Set_Cookie(name, value, expires) { 
	//, path, domain, secure ) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );

	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	} else {
		expires = local_cookie_age * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );

	document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + 
		( ( local_cookie_path ) ? ";path=" + local_cookie_path : "" ) + 
		( ( local_cookie_domain ) ? ";domain=" + local_cookie_domain : "" );
//		( ( secure ) ? ";secure" : "" );
}

/** NAVBAR ***
 * Inspired by a script from: http://www.alistapart.com/articles/hybrid/ */
ShowNav = function () {
	navRoot = document.getElementById("nav");
	for (i=0; i<navRoot.childNodes.length; i++) {
		node = navRoot.childNodes[i];
		if (node.nodeName=="LI") {
			node.onmouseover=function() {
				this.className='on';
				navTop = document.getElementById("nav");
				for (x=0; x<navTop.childNodes.length; x++) {
					nodetop = navTop.childNodes[x];
					if (nodetop.nodeName=="LI" && nodetop.id != this.id) {
						nodetop.className = 'off';
					}
				}
			}
		}
	}
}


/** FORUMS **/
function forumPostPreview(form) {
	// backup action
	var oldaction = form.action.value;
		
	// Open popup
	window.open('', 'messagePreview', 'width=720,height=480,resizable=1,scrollbars=1,status=no,location=no,toolbar=no,menubar=no')
		
	// Send preview
	form.action.value='preview';
	form.target="messagePreview";
	form.submit();
		
	// Restore form
	form.action.value = oldaction;
	form.target='';
}

function DelMyThread(thread_id){
	if (thread_id){
		var answer = confirm("Delete this thread watch?");
	}else{
		var answer = confirm("Delete ALL thread watches?");
	}
	if (answer){
		eval('document.del_mythread.thread_id.value=thread_id');
		document.del_mythread.submit();
	}
}

/** PAGE JUSTIFY **/
function webJustifyLeft(){
	Set_Cookie('web_justify', 'left'); 
	document.getElementById('web_container').style.margin='0';
	document.getElementById('mbg').style.background='';
	if (document.getElementById('page_just_set_left')) {
		document.getElementById('page_just_set_left').style.fontWeight = 'bold';
		document.getElementById('page_just_set_right').style.fontWeight = 'normal';
		document.getElementById('page_just_set_center').style.fontWeight = 'normal';
	}
}
function webJustifyRight(){
	Set_Cookie('web_justify', 'right'); 
	document.getElementById('web_container').style.margin='0px 0px 0px auto';
	document.getElementById('mbg').style.background='';
	if (document.getElementById('page_just_set_right')) {
		document.getElementById('page_just_set_right').style.fontWeight = 'bold';
		document.getElementById('page_just_set_left').style.fontWeight = 'normal';
		document.getElementById('page_just_set_center').style.fontWeight = 'normal';
	}
}
function webJustifyCenter(){
	Set_Cookie('web_justify', 'center', '0'); 
	document.getElementById('web_container').style.margin='0px auto';
	if (document.getElementById('page_just_set_center')) {
		document.getElementById('page_just_set_center').style.fontWeight = 'bold';
		document.getElementById('page_just_set_left').style.fontWeight = 'normal';
		document.getElementById('page_just_set_right').style.fontWeight = 'normal';
	}
}

/** COMMENTING **/
function enableCommentAjax(scope, id) {
	// Will only work for browsers with JS
	var cform = document.getElementById("cmtform_"+scope+"_"+id);
	cform.norm_submit.style.display='none';
	cform.ajax_submit.style.display='inline';
	cform.xml.value='1';
}
function submitComment(scope, id) {
	// Get the form ID and check length
	var formname = "cmtform_"+scope+"_"+id;
	var cform = document.getElementById(formname);
	if (!cform || cform.comment.length == 0)
		return;

	// Add comment & lock form
//	alert ("Submitting comment for scope " +formname + " to action " + cform.submiturl.value);
	cform.ajax_submit.disabled='disabled';
	cform.comment.disabled='disabled';
	add_comment(cform.submiturl.value, formname);
	return;
}
function deleteComment(scope, id, comment_id) {
	// Get the form ID and check length
	var formname = "cmtdel_"+scope+"_"+id;
	var cform = document.getElementById(formname);
	cform.comment_id.value = comment_id;
	del_comment(cform.submiturl.value, formname);
}
function resetCommentForm(scope, id) {
	// Reset form
	var cform = document.getElementById("cmtform_"+scope+"_"+id);
	cform.comment.value = "\n\n      Message Uploaded - Thank you... \n      Spam Buster 8000";
	setTimeout("resetCommentFormReal('"+scope+"', '"+id+"')", 20000);
}
// This called when the spambuster timeout has expired
function resetCommentFormReal(scope, id) {
	var cform = document.getElementById("cmtform_"+scope+"_"+id);
	cform.ajax_submit.disabled=false;
	cform.comment.disabled=false;
	cform.comment.value = '';
}

/** ACCOUNT TOOLS **/
/***********************************************
* Form Field Progress Bar- By Ron Jonk- http://www.euronet.nl/~jonkr/
* Modified by Dynamic Drive for minor changes
* Script featured/ available at Dynamic Drive- http://www.dynamicdrive.com
* Please keep this notice intact
***********************************************/
function textCounter(field,counter,maxlimit,linecounter) {
 // text width//
 var fieldWidth =  parseInt(field.offsetWidth);
 var charcnt = field.value.length;        

 // trim the extra text
 if (charcnt > maxlimit) { 
  field.value = field.value.substring(0, maxlimit);
 }

 else { 
 // progress bar percentage
 var percentage = parseInt(100 - (( maxlimit - charcnt) * 100)/maxlimit) ;
 document.getElementById(counter).style.width =  parseInt((fieldWidth*percentage)/100)+"px";
 document.getElementById(counter).innerHTML=percentage+"% used"
 // color correction on style from CCFFF -> CC0000
 setcolor(document.getElementById(counter),percentage,"background-color");
 }
}
function setcolor(obj,percentage,prop){
 obj.style[prop] = "rgb(80%,"+(100-percentage)+"%,"+(100-percentage)+"%)";
}
function ConfirmNameChange(old, limit){
    var newname = document.getElementById('namechangeform').newname.value;
    var answer = confirm("Really change name from \"" + old + "\" to \"" + newname + "\"? You can only change your name once every " + limit + " days.");
    return answer;
}


/*** MEDIA UPLOAD ****/
/*function uploadMedia(handler, field_name) {
	
	var iframe_name = field_name+"_IFRAME";
	var d = document.createElement('DIV');
	d.innerHTML = '<iframe style="display:none" src="about:blank" id="'+iframe_name+'" name="'+iframe_name+'"></iframe>';
	document.getElementById(field_name+'_MSG').appendChild(d);
	
    var uploadForm = document.createElement('FORM');
	uploadForm.setAttribute('id', field_name+'_UPFORM');
	uploadForm.setAttribute('action', handler);
	uploadForm.setAttribute('target', iframe_name);

	var newFile = uploadForm.createElement('FILE');
	uploadForm.replaceChild('FILE'
	

                var r = document.getElementById("dc_ad_holder_<?=$title?>");
                r.parentNode.replaceChild(document.getElementById("dc_ad_data_<?=$title?>"), r);
                var r = document.getElementById("dc_ad_data_<?=$title?>");
                r.style.display='block';
                r.style.height='auto';
                r.style.width='auto';


	return true;

	xmlhttp("POST", handler, uploadMediaResponse, extractFormData(file_input+'_form'));
}*/


/*function uploadMediaResponse(response) {
	var result = eval('(' + response + ')');
	alert (response);

	var formname = "cmtform_"+result.scope+"_"+result.id;
	var listname = "cmtlist_"+result.scope+"_"+result.id;
	var cform = document.getElementById(formname);
	var clist = document.getElementById(listname);
	cform.last_read_id.value=result.lid;
	clist.innerHTML=result.list;

	// Limit commenting time
	if (cform.comment.disabled)
		resetCommentForm(result.scope, result.id);

} */


/*** JAVASCRIPT AJAX TOOLS ****/
// Extract all the data from a form
// and format it in an inline string
// for an AJAX send.
function extractFormData(form_id){
	post_data = '';
	form = document.getElementById(form_id);
	for(i=0;i<form.length;i++){
		if(form.elements[i].name != ''){
			// Don't return value if the input is
			// an unchecked checkbox.
			if(form.elements[i].type != 'checkbox'){
				post_data += form.elements[i].name + '=' + form.elements[i].value + '&';
			}else{
				if(form.elements[i].checked == true){
					post_data += form.elements[i].name + '=' + form.elements[i].value + '&';
				}
			}
		}
	}
	return post_data;
}
function xmlDOM(str){
	// code for IE
	if (window.ActiveXObject)
	{
		var doc=new ActiveXObject("Microsoft.XMLDOM");
		doc.async="false";
		doc.loadXML(str);
	}
	// code for Mozilla, Firefox, Opera, etc.
	else
	{
		var parser=new DOMParser();
		var doc=parser.parseFromString(str,"text/xml");
	}

	return doc
}
function createRequestObject(override_mime) {
	var tmpXmlHttpObject;

	//depending on what the browser supports, use the right way to create the XMLHttpRequest object
	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		tmpXmlHttpObject = new XMLHttpRequest();
		// Set type accordingly to anticipated content type
		if (tmpXmlHttpObject.overrideMimeType && override_mime != '') {
			tmpXmlHttpObject.overrideMimeType(override_mime);
		}else if (tmpXmlHttpObject.overrideMimeType){
			tmpXmlHttpObject.overrideMimeType('text/xml');
			//tmpXmlHttpObject.overrideMimeType('text/html');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			tmpXmlHttpObject = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				tmpXmlHttpObject = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}
	if (!tmpXmlHttpObject) {
		alert('Cannot create AJAX connection. Please upgrade your browser.');
		return false;
	}

	return tmpXmlHttpObject;
}
// Ajax connection request function
var xmlHttpReq = Array();
function xmlhttp(http_method, url, response_action, form_data) {
    xmlHttpReq[url] = false;
//    var self = this;
    xmlHttpReq[url] = new createRequestObject();
    xmlHttpReq[url].open(http_method, url, true);
    xmlHttpReq[url].setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    if (response_action != null) {
      xmlHttpReq[url].onreadystatechange = function() {
        if (xmlHttpReq[url].readyState == 4) {
            response_action(xmlHttpReq[url].responseText);
        }
      }
    }
    xmlHttpReq[url].send(form_data);
    return xmlHttpReq[url];
}
// Ajax response functions
function add_comment_response(response) {
	var result = eval('(' + response + ')');

	var formname = "cmtform_"+result.scope+"_"+result.id;
	var listname = "cmtlist_"+result.scope+"_"+result.id;
	var cform = document.getElementById(formname);
	var clist = document.getElementById(listname);
	cform.last_read_id.value=result.lid;
	clist.innerHTML=result.list;

	// Limit commenting time
	if (cform.comment.disabled)
		resetCommentForm(result.scope, result.id);
}
function del_comment_response(response) {
	var result = eval('(' + response + ')');

	var listname = "cmtlist_"+result.scope+"_"+result.id;
	var formname = "cmtdel_"+result.scope+"_"+result.id;
	var clist = document.getElementById(listname);
	var  cform = document.getElementById(formname);
	clist.innerHTML=result.list;
	cform.comment_id='';
}
function article_listing_update_response(response) {
	document.getElementById('article_container').innerHTML = response;
}
function karma_adjust_xchange_response(response) {
	var ratings = response.split(';');
	document.getElementById("karma_xchange_val").innerHTML = ratings[0]; 
	document.getElementById("karma_val").innerHTML = ratings[1];
}
function sse_ticker_start_cycle(response){
	document.getElementById("sse_ticks").innerHTML = response; 
//	document.getElementById("sse_ticks").innerHTML = document.getElementById("sse_ticks").innerHTML + response;
}
function cult_mass_message_authorisation_response(response){
	document.getElementById("masssetting").innerHTML = response;
}
function send_rating_response(response){
	rating_xml = xmlDOM(response);

	// Set the variables with the output from the XML
	rating_xml = rating_xml.documentElement;
	
	// Update the page only if the vote has been saved
	// to the database.
	if(rating_xml.childNodes[0].hasChildNodes()){
		// My rating.
		document.getElementById('select_submit_form').innerHTML = '<span style="font-weight: bold;">My rating: </span>' + rating_xml.childNodes[0].childNodes[0].nodeValue;
		// Average rating and number of rating. Verify the number
		// rating and set it to plural if it's greater than 1.
		numberOfRating = parseInt(rating_xml.childNodes[2].childNodes[0].nodeValue);
		numberOfRating_string = ' rating';
		if(numberOfRating > 1){
			numberOfRating_string += 's';
		}
	        document.getElementById('average_rating_txt').innerHTML = '<span style="font-weight: bold;">Average Rating: </span>' + rating_xml.childNodes[1].childNodes[0].nodeValue + ' of ' + rating_xml.childNodes[2].childNodes[0].nodeValue + numberOfRating_string;
	}
}
function send_rating_response2(response){
	var result = eval('(' + response + ')');

	document.getElementById('art_avg_txt').innerHTML=result.AVERAGE_RATING;
	document.getElementById('art_num_txt').innerHTML=result.NUM_RATINGS;
	document.getElementById('my_rate_txt').innerHTML=result.MY_RATING;
	document.getElementById('average_rating_stars').innerHTML=result.STARS;
}
function validateRegistrationForm_response(response){
	registrationForm_xml = xmlDOM(response);
	
	// Process all the input form fields.
	input_xml = registrationForm_xml.getElementsByTagName('input');
	error_counter = 0;
	validation_counter = 0;
	for(i=0;i<input_xml.length;i++){
		validation_counter++;
		// Remove the previously set error message.
		if(input_xml[i].getElementsByTagName('id')[0]){
			// If the error 'div' exists, delete it.
			if(document.getElementById(input_xml[i].getElementsByTagName('id')[0].childNodes[0].nodeValue + 'Error')){
				document.getElementById(input_xml[i].getElementsByTagName('id')[0].childNodes[0].nodeValue + 'Error').parentNode.removeChild(document.getElementById(input_xml[i].getElementsByTagName('id')[0].childNodes[0].nodeValue + 'Error'));
			}
		}
		if(input_xml[i].getElementsByTagName('status')[0].childNodes[0].nodeValue == '0'){
			error_counter++;
			// Add an error message before the input node.
			errorMessage = document.createElement('div');
			errorMessage.setAttribute('id', input_xml[i].getElementsByTagName('id')[0].childNodes[0].nodeValue + 'Error');
			errorMessage.style.cssText = 'background-image:url(http://media.newschoolers.com/site/register/arrow_error.gif);background-repeat:no-repeat;color:#dd0033;font-weight:bold;width:425px;padding-left:18px;padding-bottom:2px;padding-top:3px;background-position:0px 3px;margin-left:90px;';
			errorMessage.innerHTML = input_xml[i].getElementsByTagName('errorMessage')[0].childNodes[0].nodeValue;
			// Insert the error message.
			document.getElementById(input_xml[i].getElementsByTagName('id')[0].childNodes[0].nodeValue).parentNode.insertBefore(errorMessage, document.getElementById(input_xml[i].getElementsByTagName('id')[0].childNodes[0].nodeValue));
		}
	}
	if(error_counter == 0 && validation_counter == 6){
		document.location = registrationForm_xml.getElementsByTagName('redirection')[0].childNodes[0].nodeValue;
	}else if(validation_counter == 6){
		document.getElementById('loadingImg').style.visibility = 'hidden';
		document.getElementsByName('formSubmit')[0].value = 'Check Again';
		document.getElementsByName('formSubmit')[0].style.visibility = 'visible';
	}
}
//Ajax send functions
function cult_mass_message_authorisation(request){
	xmlhttp("GET", request, cult_mass_message_authorisation_response, null);
}
function karma_adjust_xchange(request){
	xmlhttp("GET", request, karma_adjust_xchange_response, null, null);
}
function send_rating(request, form){
	xmlhttp("POST", request, send_rating_response, extractFormData(form));
}
function send_rating2(request, form){
	xmlhttp("POST", request, send_rating_response2, extractFormData(form));
}
function sse_ticker_start(request){
	xmlhttp("GET", request, sse_ticker_start_cycle, null);
	setTimeout("sse_ticker_start('" + request + "')", 40000); // 40 seconds
}
function validateRegistrationInput(request){
	xmlhttp("GET", request, validateRegistrationForm_response, null);
}
function article_listing_update(request) {
	xmlhttp("GET", request, article_listing_update_response, null);
}
function add_comment(request, form) {
	xmlhttp("POST", request, add_comment_response, extractFormData(form));
}
function del_comment(request, form) {
	xmlhttp("POST", request, del_comment_response, extractFormData(form));
}
/* function rm_comment(request, form) {
 	xmlhttp("POST", request, add_comment_response, extractFormData(form));
} */




/*** Dropdown slider ***/
var slideDownInitHeight = new Array();
var slidedown_direction = new Array();

var slidedownActive = false;
var contentHeight = false;
var slidedownSpeed = 10; 	// Higher value = faster script
var slidedownTimer = 2;		// Lower value = faster script
function slidedown_showHide(boxId) {
	if(!slidedown_direction[boxId])slidedown_direction[boxId] = 1;
	if(!slideDownInitHeight[boxId])slideDownInitHeight[boxId] = 0;
		
	if(slideDownInitHeight[boxId]==0)slidedown_direction[boxId]=slidedownSpeed; else slidedown_direction[boxId] = slidedownSpeed*-1;
	
	slidedownContentBox = document.getElementById(boxId);
	var subDivs = slidedownContentBox.getElementsByTagName('DIV');
	for(var no=0;no<subDivs.length;no++){
		if(subDivs[no].className=='dropdown_content')slidedownContent = subDivs[no];	
	}

	contentHeight = slidedownContent.offsetHeight;
	
	slidedownContentBox.style.visibility='visible';
	slidedownActive = true;
	slidedown_showHide_start(slidedownContentBox,slidedownContent);
}
function slidedown_showHide_start(slidedownContentBox,slidedownContent) {

	if(!slidedownActive)return;
	slideDownInitHeight[slidedownContentBox.id] = slideDownInitHeight[slidedownContentBox.id]/1 + slidedown_direction[slidedownContentBox.id];
	if(slideDownInitHeight[slidedownContentBox.id] <= 0){
		slidedownActive = false;	
		slidedownContentBox.style.visibility='hidden';
		slideDownInitHeight[slidedownContentBox.id] = 0;
	}
	if(slideDownInitHeight[slidedownContentBox.id]>contentHeight){
		slidedownActive = false;	
	}
	slidedownContentBox.style.height = slideDownInitHeight[slidedownContentBox.id] + 'px';
	slidedownContent.style.top = slideDownInitHeight[slidedownContentBox.id] - contentHeight + 'px';

	setTimeout('slidedown_showHide_start(document.getElementById("' + slidedownContentBox.id + '"),document.getElementById("' + slidedownContent.id + '"))',slidedownTimer);	// Choose a lower value than 10 to make the script move faster
}
function setSlideDownSpeed(newSpeed) {
	slidedownSpeed = newSpeed;
}

/*** Action handlers for logged in module ***/
function QLButtonSwap(action) {
	if (action == 'hoveron') {
		document.getElementById('QLButton').src=QLbutton_over.src;
	} else if (action == 'hoveroff') {
		document.getElementById('QLButton').src=QLbutton_state;
	} else if (action =='click') {
		if (QLbutton_state == QLbutton_active.src)
			QLbutton_state = QLbutton_normal.src;
		else {
			QLbutton_state = QLbutton_active.src;
		}
	}
}
function FListButtonSwap(action) {
	if (action == 'hoveron') {
		document.getElementById('FLButton').src=FLButton_over.src;
	} else if (action == 'hoveroff') {
		document.getElementById('FLButton').src=FLButton_state;
	} else if (action =='click') {
		if (FLButton_state == FLButton_active.src)
			FLButton_state = FLButton_normal.src;
		else {
			FLButton_state = FLButton_active.src;
		}
	}
}

function FListClick(friend_id) {
	// Load profile
	LP(friend_id); 
	
	// Reset the dropdown
	slidedown_showHide('FriendsList'); 
	FListButtonSwap('click'); 
	FListButtonSwap('hoveroff');
}


/****** Animation ******/
/*
// Animation functions for opacity
function highLight(id) {
	for( var i = 0 ; i <= 100 ; i+=5 ) {
		setTimeout("setChatOpacity('" + chatData[0] + "', '" + i + "')", i*3);
	}
}
*/

// Highlight a DIV /w custom background
function highlightBG(id, normal_color, highlight_color, flash_times) {
	// Set the flash counter
	if (flash_times > 1)
		flash_times = flash_times*2 -1; 

	// Set timeouts for flashing
	for( var i = 0 ; i <= flash_times ; i++ ) {
		if (i%2==1)
			setTimeout("setDivBG('" + id + "', '" + normal_color + "')", i*350);
		else
			setTimeout("setDivBG('" + id + "', '" + highlight_color + "')", i*350);
	}
}
function setDivBG(id, color) {
	div = document.getElementById(id);
	if (div) 
		div.style.backgroundColor=color;
}

// Fade stuff out
function fadeOut(id, callBack) {
	for( var i = 0 ; i <= 100 ; i+=5 ) {
		setTimeout("setOpacity('" + id + "', '" + i + "')", (100-i)*5);
	}
	if (callBack) {
		setTimeout(callBack+"('" + id + "')", 100*5);
	}
}

// Fade stuff in
function fadeIn(id) {
	for( var i = 0 ; i <= 100 ; i+=5 ) {
		setTimeout("setOpacity('" + id + "', '" + i + "')", i*5);
	}
}

// Change an item's opacity
function setOpacity(id, value) {
	div = document.getElementById(id);
	if (div) {
		div.style.opacity = value / 100;
		div.style.filter = 'alpha(opacity=' + value + ')';
	}
}

// Change height of an object
function setHeight(div_id, value) {
	div = document.getElementById(div_id);
	if (div) {
		div.style.height = value+'px';
	}
} 

// Shrink an object
function hideDiv(id) {
	height = document.getElementById(id).clientHeight;
	for( var i = 0 ; i <= 100 ; i+=5 ) {
		setTimeout("setOpacity('" + id + "', '" + i + "')", (100-i)*10);
		setTimeout("setHeight('" + id + "', '" + (height * i/100 ) + "')", (100-i)*10);
	}
}

function showDiv(id, height) {
	for( var i = 0 ; i <= 100 ; i+=5 ) {
		setTimeout("setOpacity('" + id + "', '" + i + "')", i*10);
		setTimeout("setHeight('" + id + "', '" + (height * i/100 ) + "')", i*10);
	}
}





/****** Gets the document of an iframe *****/

// Get the document from the iframe stream
function getIframeDoc(iframe_id) {
	// Find the document of the iframe
	var doc = null;  
	var iframe = document.getElementById(iframe_id);
	if (iframe.contentDocument)  
		// Firefox, Opera  
		doc = iframe.contentDocument;  
	else if (iframe.contentWindow)  
		// Internet Explorer  
		doc = iframe.contentWindow.document;  
	else if (iframe.document)  
		// Others?  
		doc = iframe.document;  
	return doc;
}
