sfHover = function() {
	if (document.getElementById("left_menu") == null)
		return;
	var sfEls = document.getElementById("left_menu").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		if (sfEls[i].childNodes[1] != null) {
			sfEls[i].className += " hitems"
			sfEls[i].childNodes[0].onclick=function() {
				if (this.href.indexOf('#') != -1) {
					if (this.parentNode.className.indexOf("expanded") != -1) 
						this.parentNode.className = this.parentNode.className.replace(new RegExp("expanded\\b"), "");
					else {
						this.parentNode.className += " expanded";						
					}
					var obj = this;
					while (obj.parentNode.id != 'left_menu')
						obj = obj.parentNode;
					for (var i=0; i<obj.parentNode.childNodes.length; i++) {
						if (obj.parentNode.childNodes[i] != obj) {
							obj.parentNode.childNodes[i].className = obj.parentNode.childNodes[i].className.replace(new RegExp("expanded\\b"), "");
						}
					}
				    return false;
				}
				return true;			
			}
		}
	}
}
window.onload = sfHover;

var helpItems = new Array();


$.validator.addMethod('type_trade', function (value, element) {
	var errors = $('span.error');
	if (document.getElementById('new_company_type').value != '' || document.getElementById('new_company_trade').value != '') {
		for (var i=0; i< errors.length; i++)
			if (errors[i].getAttribute('htmlfor') == 'new_company_type' || errors[i].getAttribute('htmlfor') == 'new_company_trade')
				errors[i].style.display = 'none';
		
		return true;
	}
	else {
		for (var i=0; i< errors.length; i++)
			if (errors[i].getAttribute('htmlfor') == 'new_company_type' || errors[i].getAttribute('htmlfor') == 'new_company_trade')
				errors[i].style.display = 'inline';
	}
}, '<img src="/images/form_required.gif" alt="Prosze wybrac branze lub rodzaj" title="Prosze wybrac branze lub rodzaj" width="12" height="12"/>');

function updateSurveyTO() {
	setTimeout('updateSurvey()', 300);
}

function updateSurvey() {
	for (var i=0; i<5; i++) {
		if (currentData['question' + i] != null) {
			//alert('img_' + i + '_' + currentData['question' + i]);
			faceClick(document.getElementById('img_' + i + '_' + currentData['question' + i]));
		}
	}
}

function publish() {
	if (currentData.newcustomer == null) {
		currentData.newcustomer = new Array();
	}
	
	var new_company_usernick = '';
	var new_company_useremail = '';
	var new_user_usernick = '';
	var new_user_useremail = '';
	var new_user_useremail2 = '';
	var new_account_agreement = '';
	var new_user_name = '';
	var new_user_surname = '';
	var new_user_password = '';
	var new_user_password2 = '';
	var new_user_sex = '';
	var new_user_dateday = '';
	var new_user_datemonth = '';
	var new_user_dateyear = '';
	var new_user_region = '';
	var captcha = '';
	if (document.getElementById('new_user_agreement') != null) {
		if (document.getElementById('new_user_agreement').checked == false) {
			showMessage('Proszę zaakceptować Regulamin Publikacji Opinii w serwisie', 3);
			return;
		}
		new_company_usernick = document.getElementById('new_user_usernick').value;
		new_company_useremail = document.getElementById('new_user_useremail').value;
		captcha = document.getElementById('captcha').value;
		
		
		if (document.getElementById('new_account_agreement') != null) {
			if (document.getElementById('new_account_agreement').checked == true) {
				new_account_agreement = 1;
				
				new_user_usernick = document.getElementById('new_user_usernick').value;
				new_user_useremail = document.getElementById('new_user_useremail').value;
				new_user_useremail2 = document.getElementById('new_user_useremail2').value;
				new_user_name = document.getElementById('new_user_name').value;
				new_user_surname = document.getElementById('new_user_surname').value;
				new_user_password = document.getElementById('new_user_password').value;
				new_user_password2 = document.getElementById('new_user_password2').value;
				new_user_sex = document.getElementById('new_user_sex').value;
				new_user_dateday = document.getElementById('new_user_dateday').value;
				new_user_datemonth = document.getElementById('new_user_datemonth').value;
				new_user_dateyear = document.getElementById('new_user_dateyear').value;
				new_user_region = document.getElementById('new_user_region').value;
			}			
		}
	}

	showPleaseWait();
	ajaxCall('NewOppinion', 'savesurveyanswer', {
			page: currentPagename, 
			companyid: currentData.companyid, 
			questionid_0: currentData.questionid_0,
			questionid_1: currentData.questionid_1,
			questionid_2: currentData.questionid_2,
			questionid_3: currentData.questionid_3,
			questionid_4: currentData.questionid_4,
			question0: parseInt(currentData.question0)-2,
			question1: parseInt(currentData.question1)-2,
			question2: parseInt(currentData.question2)-2,
			question3: parseInt(currentData.question3)-2,
			question4: parseInt(currentData.question4)-2,
			opinniontext: currentData.opinniontext,
			new_company_name: currentData.newcustomer['new_company_name'],
			new_company_nip: currentData.newcustomer['new_company_nip'],
			new_company_regon: currentData.newcustomer['new_company_regon'],
			new_company_krs: currentData.newcustomer['new_company_krs'],
			new_company_type: currentData.newcustomer['new_company_type'],
			new_company_trade: currentData.newcustomer['new_company_trade'],
			new_company_street: currentData.newcustomer['new_company_street'],
			new_company_streetnumber: currentData.newcustomer['new_company_streetnumber'],
			new_company_postalcode: currentData.newcustomer['new_company_postalcode'],
			new_company_city: currentData.newcustomer['new_company_city'],
			new_company_phone: currentData.newcustomer['new_company_phone'],
			new_company_email: currentData.newcustomer['new_company_email'],
			new_company_www: currentData.newcustomer['new_company_www'],
			new_company_description: currentData.newcustomer['new_company_description'],
			new_company_usernick: new_company_usernick,
			new_company_useremail: new_company_useremail,
			new_user_usernick: new_user_usernick,
			new_user_useremail: new_user_useremail,
			new_user_useremail2: new_user_useremail2,
			new_account_agreement: new_account_agreement,
			new_user_name: new_user_name,
			new_user_surname: new_user_surname,
			new_user_password: new_user_password,
			new_user_password2: new_user_password2,
			new_user_sex: new_user_sex,
			new_user_dateday: new_user_dateday,
			new_user_datemonth: new_user_datemonth,
			new_user_dateyear: new_user_dateyear,
			new_user_region: new_user_region,
			captcha: captcha
		}, null, function() {
			hidePleaseWait();
		});

}

var currentStep = 1;
var currentPagename = '';
var currentData = new Object();

function newOpinnionCallback() {
//	alert('currentStep=' + currentStep);
	setFormValidation();
	if (currentStep == 1) {
		if (!currentData.disableCompany) {
			activebookmarkid = '';
			if (currentData.companyid != null) {
				activateBookmarkTab(document.getElementById('searchbookmark'));
				ajaxGetItem('newoppinioncompanylist', currentPagename, currentData.companyid);
			}
			else {
				setFormValues('#new_company_form', currentData.newcustomer);
				activateBookmarkTab(document.getElementById('newcompanybookmark'));
			}
		}
	}
	else if (currentStep == 2) {
		ajaxCall('NewOppinion', 'getsurvey', {page: currentPagename, companyid: (currentData.companyid != null ? currentData.companyid : ''), typeid: (currentData.newcustomer != null ? currentData.newcustomer['new_company_type'] : ''), tradeid: (currentData.newcustomer != null ? currentData.newcustomer['new_company_trade'] : '')}, null, updateSurveyTO);
		if (currentData.opinniontext != null)
			document.getElementById('opinniontext').value = currentData.opinniontext;

	}
	else if (currentStep == 3) {
		var captcha = $(".captchaimage");
		if (captcha.length > 0) {
			if ($(".captchaimage")[0].src.indexOf('s.gif') != -1) {
				var d = new Date();
				$(".captchaimage")[0].src = '/captcha/images/image.php?' + d.getTime();
			}
		}
/*		
		if (currentData.new_user_usernick != null)
			document.getElementById('new_user_usernick').value = currentData.new_user_usernick;
		if (currentData.new_user_useremail != null)
			document.getElementById('new_user_useremail').value = currentData.new_user_useremail;
		if (currentData.new_user_agreement != null)
			document.getElementById('new_user_agreement').checked = currentData.new_user_agreement;
*/
		setFormValues('#new_user_form', currentData.newuser);
		checkOpinionNewUser();
		
		

	}
	else if (currentStep == 4) {
		if (currentData.companyid != null) {
			ajaxGetItem('finalcompanyinfo', currentPagename, currentData.companyid);
		}
		else {
			document.getElementById('finalcompanyinfo').innerHTML = '<b>Nazwa:</b> ' + currentData.newcustomer['new_company_name'];
		}		
	}
	defaultAjaxGetItemCallback();
}


function nextStep(pagename, param) {
	currentPagename = pagename;
	if (currentStep == 1) {
		if (currentData.disableCompany) {
		}
		else {
			if (param != null) {
				currentData.companyid = param;
				delete currentData.newcustomer;
			}
			else {
				delete currentData.companyid;
				
				if (!validateForm('#new_company_form')) {
					showMessage('Proszę wybrać firmę z listy lub wypełnić poprawnie formularz', 3);
					return;
				}
					
				currentData.newcustomer = getFormValues('#new_company_form');
			}
		}
	}
	else if (currentStep == 2) {
		for (var i=0; i<5; i++) {
			if (currentData['question' + i] == null) {
				showMessage('Proszę wypełnić ankietę', 3);
				return;
			}
		}
		currentData.opinniontext = document.getElementById('opinniontext').value;
	}
	else if (currentStep == 4) {
		if (param != null)
			return;
	}
	resetMessage();
	ajaxGetItem('oppinnioncnt', pagename, 's' + (currentStep+1), null, newOpinnionCallback);
	currentStep++;
}
	
function previousStep(pagename) {
	currentPagename = pagename;
	if (currentStep == 3) {
/*		if (document.getElementById('new_user_usernick') != null)
			currentData.new_user_usernick = document.getElementById('new_user_usernick').value;
		if (document.getElementById('new_user_useremail') != null)
			currentData.new_user_useremail = document.getElementById('new_user_useremail').value;
		if (document.getElementById('new_user_agreement') != null)
			currentData.new_user_agreement = document.getElementById('new_user_agreement').checked;
*/
		currentData.newuser = getFormValues('#new_user_form');
	}
	else if (currentStep == 2) {
		currentData.opinniontext = document.getElementById('opinniontext').value;
	}
	
	if (currentStep > 1) {
		resetMessage();
		ajaxGetItem('oppinnioncnt', pagename, 's' + (currentStep-1), null, newOpinnionCallback);
		currentStep--;
	}
}

function faceOver(imgobj) {
	imgobj.src = '/images/face' + imgobj.id.substring(6) + '.jpg';
	var qnumber = imgobj.id.substring(4,5);
	var qvalue = imgobj.id.substring(6);
	
	for (var i=0; i<5; i++)
		document.getElementById('desc_' + qnumber + '_' + i).style.display = 'none';

	document.getElementById('desc_' + qnumber + '_' + qvalue).style.display = 'block';
}

function faceOut(imgobj) {
	var qnumber = imgobj.id.substring(4,5);
	var qvalue = imgobj.id.substring(6);
	if (qvalue != currentData['question' + qnumber]) {
		imgobj.src = '/images/face' + imgobj.id.substring(6) + '_grey.jpg';
		document.getElementById('desc_' + qnumber + '_' + qvalue).style.display = 'none';
		if (currentData['question' + qnumber] >= 0)
			document.getElementById('desc_' + qnumber + '_' + currentData['question' + qnumber]).style.display = 'block';
	}
}

function faceClick(imgobj) {
	var qnumber = imgobj.id.substring(4,5);
	var qvalue = imgobj.id.substring(6);
	if (currentData['question' + qnumber] != qvalue && currentData['question' + qnumber] != null) {
		document.getElementById('img_' + qnumber + '_' + currentData['question' + qnumber]).src = '/images/face' + currentData['question' + qnumber] + '_grey.jpg';
	}
	imgobj.src = '/images/face' + imgobj.id.substring(6) + '.jpg';
	currentData['question' + qnumber] = qvalue;
	if (currentData['question' + qnumber] >= 0)
		document.getElementById('desc_' + qnumber + '_' + currentData['question' + qnumber]).style.display = 'block';
}

function typeOnChange() {
	document.getElementById('new_company_type_inp').value = document.new_company_form.new_company_type.value;
	document.getElementById('new_company_trade_inp').value = document.new_company_form.new_company_trade.value;
//	document.getElementById('new_company_trade').innerHTML = '<img src="/images/ajaxload.gif"/>';
	document.getElementById('new_company_trade_load').style.display = 'inline';
	helpItems = new Array();
}

function tradeOnChange() {
	var val = document.getElementById('new_company_trade').value;
	if (val == '')
		val = 0;
	if (helpItems[val] != null && helpItems[val] != '') {
		document.getElementById('new_company_trade_help').innerHTML = ' ' + helpItems[val];
		document.getElementById('new_company_trade_help').style.display = 'block';
	}
	else {
		document.getElementById('new_company_trade_help').innerHTML = helpItems[val];
		document.getElementById('new_company_trade_help').style.display = 'none';
	}
}

function typeSearchOnChange() {
//	document.getElementById('new_company_type_inp').value = document.new_company_form.new_company_type.value;
//	document.getElementById('new_company_trade_inp').value = document.new_company_form.new_company_trade.value;
//	document.getElementById('new_company_trade').innerHTML = '<img src="/images/ajaxload.gif"/>';
	document.getElementById('search_company_trade_load').style.display = 'inline';
}



var activebookmarkid = '';

function activateTab(obj, name) {
	obj.className = 'topsearchheadersactivediv';
	document.getElementById('topsearchdown' + name).style.display = 'block';
	
	if (name == 'region') {
		document.getElementById('topsearchheaderstype').className = 'topsearchheadersinactivediv';
		document.getElementById('topsearchheaderstrade').className = 'topsearchheadersinactivediv';
		document.getElementById('topsearchdowntype').style.display = 'none';
		document.getElementById('topsearchdowntrade').style.display = 'none';
	}
	else if (name == 'type') {
		document.getElementById('topsearchheadersregion').className = 'topsearchheadersinactivediv';
		document.getElementById('topsearchheaderstrade').className = 'topsearchheadersinactivediv';
		document.getElementById('topsearchdownregion').style.display = 'none';
		document.getElementById('topsearchdowntrade').style.display = 'none';
	}
	else if (name == 'trade') {
		document.getElementById('topsearchheaderstype').className = 'topsearchheadersinactivediv';
		document.getElementById('topsearchheadersregion').className = 'topsearchheadersinactivediv';
		document.getElementById('topsearchdowntype').style.display = 'none';
		document.getElementById('topsearchdownregion').style.display = 'none';
	}
}

function activateBookmarkTab(obj) {
	if (obj.className == 'wizardbookmarkactivediv')
		return false;

	obj.className = 'wizardbookmarkactivediv';
	document.getElementById(obj.id + 'form').style.display = 'block';
	
	if (activebookmarkid == '') {
		if (obj.id == 'searchbookmark')
			activebookmarkid = 'newcompanybookmark';
		else
			activebookmarkid = 'searchbookmark';
	}
		
	if (activebookmarkid != '') {
		document.getElementById(activebookmarkid).className = 'wizardbookmarkinactivediv';
		document.getElementById(activebookmarkid + 'form').style.display = 'none';
	}
	
	activebookmarkid = obj.id;
}


/**
*
*  URL encode / decode
*  http://www.webtoolkit.info/
*
**/

var Url = {

    // public method for url encoding
    encode : function (string) {
        return escape(this._utf8_encode(string.replace(/\+/g, '%2B').replace(/\"/g,'%22').replace(/\'/g, '%27')));
    },
    
    // public method for url decoding
    decode : function (string) {
        return this._utf8_decode(unescape(string));
    },
    
    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

}

function hideWindows() {
	resetMessage();
	$('#mask').hide();
	$('.window').hide();
}

function showwindow(e, id) {
	hideWindows();

	if (e != null)
		e.stopPropagation();

	//Get the screen height and width
	var maskHeight = $(document).height();
	var maskWidth = $(window).width();
	
	window.location.href='#top';

	$('#mask').css({'width':maskWidth,'height':maskHeight});
		
	$('#mask').show();

	var winH = $(window).height();
	var winW = $(window).width();

	var x = winW/2-$(id).width()/2
	var y = winH/2-$(id).height()/2

	$(id).css('top',  y);
	$(id).css('left', x);
	$(id).fadeIn(500); 
}


function showadvice(e, id, objid) {
	refreshCaptcha();
	
	$('#advice_email')[0].value = '';
	$('#advice_description')[0].value = '';
	$('#advice_companyid')[0].value = (objid != null ? objid : '');
	var enteredname = $('#advice_enteredname');
	if (enteredname.length > 0) {
		enteredname[0].value = '';
		var captchas = $('#captcha');
		for (var i=0; i<captchas.length; i++)
			captchas[i].value = '';
	}
	$('#advice_form').valid();
	showwindow(e, id);
}

function showmoderation(e, id, objectid) {
	refreshCaptcha();

	$('#moderation_id')[0].value = objectid;
	
	if ($('#moderation_email').length > 0)
		$('#moderation_email')[0].value = '';
	$('#moderation_description')[0].value = '';
	var enteredname = $('#moderation_enteredname');
	if (enteredname.length > 0) {
		enteredname[0].value = '';
		var captchas = $('#captcha');
		for (var i=0; i<captchas.length; i++)
			captchas[i].value = '';
	}
	$('#moderation_form').valid();
	showwindow(e, id);
}

function showsuggestion(e, id) {
	refreshCaptcha();

//	$('#moderation_id')[0].value = objectid;
	
	if ($('#suggest_email').length > 0)
		$('#suggest_email')[0].value = '';
	$('#suggest_description')[0].value = '';
	var enteredname = $('#suggest_enteredname');
	if (enteredname.length > 0) {
		enteredname[0].value = '';
		var captchas = $('#captcha');
		for (var i=0; i<captchas.length; i++)
			captchas[i].value = '';
	}
	$('#suggest_form').valid();
	showwindow(e, id);
}


function moderationCommit() {
	ajaxSendForm('/ajax/all', $('#moderation_form'), 'moderate');
}

function suggestCommit() {
	ajaxSendForm('/ajax/all', $('#suggest_form'), 'suggest');
}

function showchangepass(e, id) {
	$('#current_password')[0].value = '';
	$('#new_user_password')[0].value = '';
	$('#new_user_password2')[0].value = '';
	showwindow(e, id);	
}

function showchangeemail(e, id) {
	$('#email_current_password')[0].value = '';
	$('#new_user_email')[0].value = '';
	$('#new_user_email2')[0].value = '';
	showwindow(e, id);	
}


$(document).ready(function() {
	
	$('div.moderationbuttondiv').click(function (e) {
		showmoderation(e, '#moderationwindow', this.id);
	});

	$('#suggestbtn').click(function (e) {
		showsuggestion(e, '#suggestwindow');
	});

	$('#advicebtn').click(function (e) {
		showadvice(e, '#advicewindow', this.firstChild.id);
	});
	
	$('.advicePortal').click(function (e) {
		showadvice(e, '#advicewindow');
	});

	$('.logout').click(function (e) {
		logout();
	});
	
	$('#changepassbtn').click(function (e) {
		showchangepass(e, '#changepasswindow');
	});

	$('#changeemailbtn').click(function (e) {
		showchangeemail(e, '#changeemailwindow');
	});
	

	$('.window').click(function (e) {
		e.stopPropagation();
	});
	
	$('#mask').click(function (e) {
		hideWindows();
		e.stopPropagation();
	});

	$('#waitmask').click(function (e) {
		e.stopPropagation();
	});

	$("#refreshcaptcha").click(function(){
		refreshCaptcha();
	});
	refreshCaptcha();
});

$(document).click(function () {
	$('.window').hide();	
//$('.window').hide();
});


function adviceCompanyCommit() {
	ajaxSendForm('/ajax/all', $('#advice_form'), 'advicecompany');
}

function refreshCaptcha() {
	var d = new Date();
	var captcha = $(".captchaimage");
	if (captcha.length > 0)
		for (var i=0; i<captcha.length; i++)
			$(".captchaimage")[i].src = '/captcha/images/image.php?' + d.getTime();
}

function newOpinnion_StartSearch(pagename) {
	activateBookmarkTab(document.getElementById('searchbookmark')); 
	ajaxGetListItems('newoppinioncompanylist', pagename, 'NewOppinion', { displayname: document.getElementById('search_displayname').value, region: document.getElementById('search_region').value, trade: document.getElementById('search_trade').value, type: document.getElementById('search_type').value});
}

function ajaxGetListItemsOnLoad(listresultid) {
	$('#' + listresultid + ' div.moderationbuttondiv').click(function (e) {
		showmoderation(e, '#moderationwindow', this.id);
	});
}

function advclick(id) {
//	ajaxCall('LeftAdvertisements', 'click', null, null, function() {
//			alert(1);
//		});

	$.ajax({
	  type: "POST",
	  url: "/ajax/call",
	  dataType: "script",
	  async: false,
	  data: {cmp: 'LeftAdvertisements', func: 'click', id: id}
	});

}

function checkOpinionNewUser() {
	if (document.getElementById('new_account_agreement') != null && document.getElementById('new_account_agreement').checked) {
		if (document.getElementById('registerdiv') != null) {
			document.getElementById('registerdiv').style.display = 'block';
			document.getElementById('nicklabel').innerHTML = 'Nazwa (Nick)*:';
			document.getElementById('emaillabel').innerHTML = 'Adres e-mail*:';
		}
	}
	else {
		if (document.getElementById('registerdiv') != null) {
			document.getElementById('registerdiv').style.display = 'none';
			document.getElementById('nicklabel').innerHTML = 'Nazwa (Nick):';
			document.getElementById('emaillabel').innerHTML = 'Adres e-mail:';
		}
	}
}

function logout() {
	ajaxSendForm('/ajax/all', $('#logout_form'), 'logout');
}

function advicePortal(e) {
	showadvice(e, '#advicewindow');
}

function changeImage(key, name) {
	if (name == 'newspaper')
		document.getElementById('medialogotypesnewspapercolumndivid').style.backgroundImage = (key == 0 ? 'url(\'/images/wyborcza_noactiv.gif\')' : 'url(\'/images/wyborcza_activ.gif\')');
	else if (name == 'tvp')
		document.getElementById('medialogotypestvpcolumndivid').style.backgroundImage = (key == 0 ? 'url(\'/images/tvp_noactiv.gif\')' : 'url(\'/images/tvp_activ.gif\')');
	else if (name == 'toya')
		document.getElementById('medialogotypestoyacolumndivid').style.backgroundImage = (key == 0 ? 'url(\'/images/toya_noactiv.gif\')' : 'url(\'/images/toya_activ.gif\')');
	else if (name == 'pb')
		document.getElementById('medialogotypespbcolumndivid').style.backgroundImage = (key == 0 ? 'url(\'/images/pb_noactiv.gif\')' : 'url(\'/images/pb_activ.gif\')');
}


function startCount(categoryid) {
	var time = document.getElementById('reviewrotationsvalue').value;
	t = setTimeout("changeReviewContent()", time);
}

function stopCount() {
	clearTimeout(t);
}

function showContentManagementCredibility() {
	document.getElementById('contentmanagementcredibilitycontentid').style.display = 'block';
	document.getElementById('contentmanagementcredibilitybutton').className = "contentmanagementcredibilitybuttonactive";
}

function hideContentManagementCredibility() {
	document.getElementById('contentmanagementcredibilitycontentid').style.display = 'none';
	document.getElementById('contentmanagementcredibilitybutton').className = "contentmanagementcredibilitybuttonnoactive";
}

function showContentManagementCompany() {
	document.getElementById('contentmanagementcompanycontentid').style.display = 'block';
	document.getElementById('contentmanagementnewcompanybutton').className = "contentmanagementnewcompanybuttonactive";
}

function hideContentManagementCompany() {
	document.getElementById('contentmanagementcompanycontentid').style.display = 'none';
	document.getElementById('contentmanagementnewcompanybutton').className = "contentmanagementnewcompanybuttonnoactive";
}

function showContentManagementOpinion() {
	document.getElementById('contentmanagementopinioncontentid').style.display = 'block';
	document.getElementById('contentmanagementnewopinionbutton').className = "contentmanagementnewopinionbuttonactive";
}

function hideContentManagementOpinion() {
	document.getElementById('contentmanagementopinioncontentid').style.display = 'none';
	document.getElementById('contentmanagementnewopinionbutton').className = "contentmanagementnewopinionbuttonnoactive";
}

function changeReviewContent() {
	var objectid = '';
	var currentvalue = document.getElementById('reviewrandomvalue').value;
	
	if (currentvalue == 'credibility') {
		objectid = 'company';
		hideContentManagementCredibility();
		showContentManagementCompany();
	}
	else if (currentvalue == 'company') {
		objectid = 'opinion';
		hideContentManagementCompany();
		showContentManagementOpinion();
	}
	else if (currentvalue == 'opinion') {
		objectid = 'credibility';
		hideContentManagementOpinion();
		showContentManagementCredibility();
	}
	
	document.getElementById('reviewrandomvalue').value = objectid;
	stopCount();
	startCount();	
}


function showContentManagementContent(name) {
	stopCount();
	
	if (document.getElementById('reviewrandomvalue').value != name) {
		if (name == 'credibility')
			document.getElementById('contentmanagementcredibilitybutton').className = "contentmanagementcredibilitybuttonactive";
		else if (name == 'company')
			document.getElementById('contentmanagementnewcompanybutton').className = "contentmanagementnewcompanybuttonactive";
		else if (name == 'opinion')
			document.getElementById('contentmanagementnewopinionbutton').className = "contentmanagementnewopinionbuttonactive";
	}
	
/*
	document.getElementById('contentmanagementopinioncontentid').style.display = 'none';
	document.getElementById('contentmanagementcredibilitycontentid').style.display = 'none';
	document.getElementById('contentmanagementcompanycontentid').style.display = 'none';
	
	document.getElementById('contentmanagementnewopinionbutton').className = "contentmanagementnewopinionbuttonnoactive";
	document.getElementById('contentmanagementcredibilitybutton').className = "contentmanagementcredibilitybuttonnoactive";
	document.getElementById('contentmanagementnewcompanybutton').className = "contentmanagementnewcompanybuttonnoactive";
							
	if (name == 'credibility') {
		document.getElementById('contentmanagementcredibilitycontentid').style.display = 'block';
		document.getElementById('contentmanagementcredibilitybutton').className = "contentmanagementcredibilitybuttonactive";
	}
	else if (name == 'company') {
		document.getElementById('contentmanagementcompanycontentid').style.display = 'block';
		document.getElementById('contentmanagementnewcompanybutton').className = "contentmanagementnewcompanybuttonactive";
	}
	else if (name == 'opinion') {
		document.getElementById('contentmanagementopinioncontentid').style.display = 'block';
		document.getElementById('contentmanagementnewopinionbutton').className = "contentmanagementnewopinionbuttonactive";
	}
*/	
}

function hideContentManagementContent(name) {	
	if (document.getElementById('reviewrandomvalue').value != name) {
		if (name == 'credibility')
			document.getElementById('contentmanagementcredibilitybutton').className = "contentmanagementcredibilitybuttonnoactive";
		else if (name == 'company')
			document.getElementById('contentmanagementnewcompanybutton').className = "contentmanagementnewcompanybuttonnoactive";
		else if (name == 'opinion')
			document.getElementById('contentmanagementnewopinionbutton').className = "contentmanagementnewopinionbuttonnoactive";
	}
	
	startCount();
}

function changeContentManagementContent(name) {
	if (name == 'credibility') {
		hideContentManagementOpinion();
		hideContentManagementCompany();
		showContentManagementCredibility();		
	}
	else if (name == 'company') {
		hideContentManagementOpinion();
		hideContentManagementCredibility();
		showContentManagementCompany();	
	}
	else if (name == 'opinion') {
		hideContentManagementCompany();
		hideContentManagementCredibility();
		showContentManagementOpinion();
	}
	
	document.getElementById('reviewrandomvalue').value = name;
}