// ProductDisplay.jsp specific JavaScript functions.

function productdisplay_hideTab(_id){
	if ((document.getElementById('productdisplay_show' + _id)) != null) {
	
	document.getElementById('productdisplay_show' + _id).style.display = 'none';
	if (document.getElementById('productdisplay_link' + _id)){
		document.getElementById('productdisplay_link' + _id).className = '';
	}
	
	
	}

}

function productdisplay_hideAllTabs(){
	productdisplay_hideTab('Description');
	productdisplay_hideTab('Features');
	productdisplay_hideTab('Awards');
	productdisplay_hideTab('Demo');
	productdisplay_hideTab('Care');
	productdisplay_hideTab('Similar');
}

function productdisplay_showTab(_id){
	productdisplay_hideAllTabs();
	common_showBareId('productdisplay_show' + _id);
	if (document.getElementById('productdisplay_link' + _id)){
		document.getElementById('productdisplay_link' + _id).className = 'over';
	}
}

var CSS_BLOCK = "block";
var CSS_HIDE = "none";
var CSS_OVER = "over";

function checkForCurrentTab() {
	var tabs = new Array();
	tabs[0] = "Description";
	tabs[1] = "Features";
	tabs[2] = "Awards";
	tabs[3] = "Demo";
	tabs[4] = "Care";
	tabs[5] = "Similar";

	for (i=0; i<tabs.length; i++) {
	    if ((document.getElementById('productdisplay_show' + tabs[i])) != null) {
	    if ((document.getElementById("productdisplay_show"+tabs[i]).style.display) == CSS_BLOCK) {
			return tabs[i];
		}
	    }
		
	}
}

function productdisplay_showTabViaEffects(id){
	var tab = checkForCurrentTab();
	new Effect.BlindUp(document.getElementById("productdisplay_show"+tab));
	document.getElementById('productdisplay_show' + id).style.display = CSS_BLOCK; 
	//alert(document.getElementById("productdisplay_show"+id).style.display);
	document.getElementById('productdisplay_link' + id).className = CSS_OVER;
	document.getElementById('productdisplay_link' + tab).className = CSS_HIDE;
	window.setTimeout("common_hideBareId('productdisplay_show" + tab + "')", 1000);	
}

function productdisplay_showSendToFriend(){
	common_showBareId('tellafriend');
    common_hideBareId('error');
    common_hideBareId('confirmation');
    common_showBareId('productdisplay_emailform');	    
}
	
function productdisplay_init(){

	var message = common_getCookie('SendEmailFatal');
	if (message!=null && message!=""){
	    common_showBareId('productdisplay_showFatal');
	    common_expireCookie('SendEmailFatal');	    
	}

	var error = common_getCookie('SendEmailError');
	if (error!=null && error!=""){
		common_showBareId('tellafriend');
	    common_showBareId('error');
	    common_expireCookie('SendEmailError');

	    error = common_getCookie('SendEmailErrorSenderName');
		if (error!=null && error!=""){
		    common_showBareId('errorSenderName');
		    common_expireCookie('SendEmailErrorSenderName');
		}

	    error = common_getCookie('SendEmailErrorSenderEmail');
		if (error!=null && error!=""){
		    common_showBareId('errorSenderEmail');
		    common_expireCookie('SendEmailErrorSenderEmail');
		}

	    error = common_getCookie('SendEmailErrorRecipientEmail');
		if (error!=null && error!=""){
		    common_showBareId('errorRecipientEmail');
		    common_expireCookie('SendEmailErrorRecipientEmail');
		}

	    error = common_getCookie('SendEmailErrorSubject');
		if (error!=null && error!=""){
		    common_showBareId('errorSubject');
		    common_expireCookie('SendEmailErrorSubject');
		}

	    error = common_getCookie('SendEmailErrorMessage');
		if (error!=null && error!=""){
		    common_showBareId('errorMessage');
		    common_expireCookie('SendEmailErrorMessage');
		}
	}

	var confirmation = common_getCookie('SendEmailConfirmation');
	if (confirmation!=null && confirmation!=""){
		common_showBareId('tellafriend');
	    common_showBareId('confirmation');
	    common_hideBareId('productdisplay_emailform');	    
	    common_expireCookie('SendEmailConfirmation');	    
	}
	
	var senderName = common_getCookie('SendEmailSenderName');
	if (senderName!=null && senderName!=""){
		if (document.getElementById("name")){
			document.getElementById("name").value=senderName;
		}
	    common_expireCookie('SendEmailSenderName');	    
	}		
	var senderEmail = common_getCookie('SendEmailSenderEmail');
	if (senderEmail!=null && senderEmail!=""){
		if (document.getElementById("email")){
			document.getElementById("email").value=senderEmail;
		}
	    common_expireCookie('SendEmailSenderEmail');	    
	}	
	var recipientEmail = common_getCookie('SendEmailRecipientEmail');
	if (recipientEmail!=null && recipientEmail!=""){
		if (document.getElementById("toemail")){
			document.getElementById("toemail").value=recipientEmail;
		}
	    common_expireCookie('SendEmailRecipientEmail');	    
	}	
	var message = common_getCookie('SendEmailMessage');
	if (message!=null && message!=""){
		if (document.getElementById("message")){
			document.getElementById("message").value=message;
		}
	    common_expireCookie('SendEmailMessage');	    
	}	
}
