function getElem(id) { return document.getElementById(id); }
  
  
function newSurvey(surveyId) {
	newWindow('http://survey.termedia.pl/survey.php?subpage=sendSurvey&surveyId='+surveyId, 'Ranking', 700, 600, 'YES');
}

function newWindow(src, title ,w,h,r) {
   var t = (screen.availHeight-h)/2;
   var l = (screen.availWidth-w)/2;
   var popup= window.open(src,title,"TOOLBAR=NULL,RESIZABLE="+r+",STATUS=YES,SCROLLBARS=YES, WIDTH="+w+",HEIGHT="+h+",LEFT="+l+",TOP="+t+"");
   popup.focus();
}

function myScrollTo(divId){
	$.scrollTo( $("#"+divId), {easing:'easeOutQuad',duration:700, offset:-30});
}


function showDiv(divId){
	var divToShow = getElem(divId);
	if(divToShow){
		divToShow.style.display = "block";
	}
}

function hideDiv(divId) {
	var divToHide = getElem(divId);
	if (divToHide){
		if (divToHide.style.display != 'none')
			divToHide.style.display = 'none';
	}
}

function showOrHide(id) {
	var elem = getElem(id);
	if (elem){
		if (elem.style.display != 'none'){
			elem.style.display = 'none';
		}
		else{
			elem.style.display = 'block';
			elem.style.width = '100%';
		}
	}
}

function disableSubmitButton(id) {
	submitB = document.getElementById(id);
	submitB.disabled = true;
}

var c = 0;
function refreshImage(imageId, inputFieldId, color) {
	img = getElem(imageId);
	if(color)
		img.src= '/randomImage.php?color='+color+'&c='+c ;
	else
		img.src= '/randomImage.php?c='+c ;
	c++;

	field = getElem(inputFieldId);
	field.focus();
}
