// JavaScript Document
// Author: Wei Lu - Mindblossom Inc.

//this fucntion will show one element and hide another, element ids are passed as parameters
function showHide(toShow, toHide){
	
	if(document.getElementById){
		document.getElementById(toShow).style.display = 'block';
		//document.getElementById('comments_form_box').style.display = 'block';
		document.getElementById(toHide).style.display = 'none';
	}//if	
}

//this function will hide the div
function hide(toHide){	
	document.getElementById(toHide).style.display = 'none';
}//hide

//this function will show the div
function show(toShow){
	
if(document.getElementById){
		document.getElementById(toShow).style.display = 'block';
	}//if
}//show



var searchFlag;
//this function will display the search form
function displaySearch(toShow, isSearch){
	if (document.getElementById){
		//if it's the header login, set the my cl state
		if (isSearch){
			if (!searchFlag){
				searchFlag = true;
				new Effect.Appear(toShow);
							}
		}else {
			new Effect.Appear(toShow);
		}//if

	}//if
}//displaySearch

//this function will hide the search form
function hideSearch(toHide, isSearch){
	if (searchFlag){
	document.getElementById(toHide).style.display = 'none';
	searchFlag = false;
	}
	
}//hideSearch

//this function will turn to current nav btn on and other off
function turnOnNav(btn_num){
	var j;
	
	for (j=1; j<=5; j++){
		document.getElementById('nav' + j).className = 'nav_' + j + '_off';
		}
	document.getElementById('nav' + btn_num).className = 'nav_' + btn_num + '_on';

}


//this function will display a message and then remove it after 3 seconds
function displayMessage(el){
	if (document.getElementById){
		//use scriptaculous to fade in message
		new Effect.Appear(el);
		//use scriptaculous to fade out message after 3 seconds
		if (navigator.platform.indexOf("Mac") > -1){
			window.setTimeout("document.getElementById('" + el + "').style.visibility = 'hidden';", 3000);
		}else{
		window.setTimeout("new Effect.Fade('" + el + "');", 3000);
		}
	}//if	
}//displayMessage


//this function will display poll results
function showPollResults(){	
	document.getElementById('poll_result').style.display = 'block';
	document.getElementById('latest_poll').style.display = 'none';
}

//this function will display poll results
function showPoll(){	
	document.getElementById('poll_result').style.display = 'none';
	document.getElementById('latest_poll').style.display = 'block';
}


//this function will display SMS Module IF CODE HAS BEEN ENTERED
function showSMS_Used(){	
	document.getElementById('sms_module').style.display = 'none';
	document.getElementById('sms_module_used').style.display = 'block';
}

//this function will display SMS Module WINNING SCREEN
function showSMS_Winning(){	
	document.getElementById('sms_module').style.display = 'none';
	document.getElementById('sms_module_winning').style.display = 'block';
}

//this function will display SMS Module LOSING SCREEN
function showSMS_losing(){	
	document.getElementById('sms_module').style.display = 'none';
	document.getElementById('sms_module_losing').style.display = 'block';
}

//this function will display SMS Module LOSING SCREEN
function showSMS_draw(){	
	document.getElementById('sms_module').style.display = 'none';
	document.getElementById('sms_module_draw').style.display = 'block';
}

function clearText(textElement, defaultElement) 
{ 
	if (textElement.value == defaultElement.value) 
	{ 
	textElement.value = "" ; 
	} 
} 


// JavaScript Document
function changeCSSClass(id, newClass) {
		
	if (newClass != "#"){
		identity=document.getElementById(id);
		identity.className=newClass;	
		
		//navContainer = document.getElementById('nav_container');
	}
}

//change all css
function changeAllVideoCSSClass(count, id, newClass){
	var i=1;
	while (document.getElementById(id + i)) {
		changeCSSClass(id+i, newClass);
		i++;
	}
}

//expert latest_QA class switch
function switchClass(target){
		if (target.className=='' ) 
			{target.className='orange';}
		else{
			target.className='';
		}
}


//************************************************winner/non-winner Box************************************************/
function showWinner(){
	document.getElementById('winner_tab').className = 'winner_tab_on';
	document.getElementById('nonWinner_tab').className = 'nonWinner_tab_off';	
	document.getElementById('winners_container').style.display = 'block';
	document.getElementById('nonWinners_container').style.display = 'none';
	
}

function showNonWinner(){
	document.getElementById('winner_tab').className = 'winner_tab_off';
	document.getElementById('nonWinner_tab').className = 'nonWinner_tab_on';	
	document.getElementById('winners_container').style.display = 'none';
	document.getElementById('nonWinners_container').style.display = 'block';	
}

//***********************************************LOVE/NO LOVE COMMENT Box************************************************/
function showLoveIt(){
	document.getElementById('love_tab').className = 'love_tab_on';
	document.getElementById('dont_love_tab').className = 'no_love_tab_off';	
	document.getElementById('why_love_comment').style.display = 'block';
	document.getElementById('why_no_love_comment').style.display = 'none';
	
}

function showDontLoveIt(){
	document.getElementById('love_tab').className = 'love_tab_off';
	document.getElementById('dont_love_tab').className = 'no_love_tab_on';	
	document.getElementById('why_love_comment').style.display = 'none';
	document.getElementById('why_no_love_comment').style.display = 'block';
}
