﻿function feedback_hide_all() {
document.getElementById('r_q1_other_1').style.display='none';
document.getElementById('r_q1_other_2').style.display='none';
//document.getElementById('r_q11_other_1').style.display='none';
//document.getElementById('r_q13_other_1').style.display='none';
//document.getElementById('r_q13_other_2').style.display='none';
document.getElementById('r_q16_other_1').style.display='none';
document.getElementById('r_q16_other_2').style.display='none';
document.getElementById('r_q18_other_1').style.display='none';
document.getElementById('r_q18_other_2').style.display='none';
}

function check(el_name,show_number,hide_number)
{
    var selected_value=get_radio_value (document.getElementsByName(el_name));
    var show_element="r_"+el_name+"_other_"+show_number;
    var hide_element="r_"+el_name+"_other_"+hide_number;
    
    if(typeof(show_number)=="undefined" && typeof(hide_number)=="undefined") {

        var re= new RegExp(el_name+'_other','g')
        var el = document.getElementsByTagName('*');
            for(var i=0;i<el.length;i++)
            {
                if(el[i].id.match(re)){
                //alert(el[i].id)
                document.getElementById(el[i].id).style.display='none';
                }
            }
}else {
if (typeof(hide_number)!="undefined"){
    document.getElementById(hide_element).style.display='none';
    }
    document.getElementById(show_element).style.display='';
}
}

function get_radio_value(radioar) {
 for(i = 0; i < radioar.length; i++)
 {          
    if(radioar[i].checked) {return radioar[i].value;}
}
return '';
}


function calendar(t,fromyear,toyear,GW)
{
elementname=t.name;
alert(elementname)
currdate=window.document.getElementsByName(elementname)[0].value;
tmpCurrdate = ValidDate (currdate,false)
if (tmpCurrdate!=currdate) {
window.document.getElementsByName(elementname)[0].value=tmpCurrdate;
currdate = tmpCurrdate;
}
wnd = window.open('/MakeCalendar.asp?elementname='+elementname+'&fromyear='+fromyear+'&toyear='+toyear+'&currdate='+currdate+'&quest='+GW,'Calendar','toolbar=no,width=410,height=250,resizable=yes',true);

if (!wnd.closed) {wnd.focus();}
}

function ValidDate (currdate, toAlert) {
veryTmp=currdate
var tmpDate = currdate.split("/");
	if ((tmpDate.length < 3 && currdate !="") || tmpDate.length > 3) {
	currdate = "";}
	else if (isNaN(tmpDate[0]) || isNaN(tmpDate[1]) || isNaN(tmpDate[2])) {
		currdate = "";}
	else { 
		tmpDate[0] = GetNumFromStr (tmpDate[0])
		tmpDate[1] = GetNumFromStr (tmpDate[1])
		
		if (!(parseInt(tmpDate[1]) >0 && parseInt(tmpDate[1])<13 && parseInt(tmpDate[0]) >0 && parseInt(tmpDate[0]) <32 && 	parseInt(tmpDate[2])>1900 && parseInt(tmpDate[2])<2050 && ValidDateForMonth (tmpDate[0], tmpDate[1],tmpDate[2]))) {
			currdate = "";
		}
		else {			
			var r1,r2;
			r1=""; r2=""
			if (parseInt(tmpDate[0]) < 10) {r1 = "0";}
			if (parseInt(tmpDate[1]) < 10) {r2 = "0";}
			currdate = r1+parseInt(tmpDate[0]) + "/" + r2 + parseInt(tmpDate[1]) + "/" + parseInt(tmpDate[2])
			var f=ValidDateForMonth(parseInt(tmpDate[0]),parseInt(tmpDate[1]),parseInt(tmpDate[2]))		
		}
	}
	if (currdate == "" && toAlert) {alert("You must enter a valid date format: DD/MM/YYYY. Please, go back and try again. Thank you!")
	}
return currdate;
}

function ValidDateForMonth (dayIs, monthIs,yearIs) {
var mDays= new Array (31,28,31,30,31,30,31,31,30,31,30,31)
if (parseInt(yearIs) % 400 == 0 ) {mDays[1]=29;}
if (parseInt(yearIs) % 4 == 0 && parseInt(yearIs) % 100 != 0) {mDays[1]=29;}

if (parseInt(dayIs)>mDays[parseInt(monthIs)-1]) {return false;}
else {return true;}
}	
function calendar(t,fromyear,toyear,GW)
{
elementname=t.name;

currdate=window.document.getElementsByName(elementname)[0].value;
tmpCurrdate = ValidDate (currdate,false)
if (tmpCurrdate!=currdate) {
window.document.getElementsByName(elementname)[0].value=tmpCurrdate;
currdate = tmpCurrdate;
}
wnd = window.open('/MakeCalendar.asp?elementname='+elementname+'&fromyear='+fromyear+'&toyear='+toyear+'&currdate='+currdate+'&quest='+GW,'Calendar','toolbar=no,width=410,height=250,resizable=yes',true);

if (!wnd.closed) {wnd.focus();}
}

function GetNumFromStr (str) {
	var pos=str.indexOf("0")
	if (pos == 0 ) {str = str.substring(1,str.length);}
return str;
}

function OnOver(img,type) {
img.src = img.src.substring(0,img.src.length-5)+'2.'+type;
}

function OnOut(img,type) {
img.src = img.src.substring(0,img.src.length-5)+'1.'+type;
}

function check_fields(form_data) {
 for(i = 0; i < form_data.elements.length; i++)
 {
  atPos = form_data.elements(i).name.indexOf("__",1)
  if(atPos != -1)
   {
    if(form_data.elements(i).value=="")
    {alert("Ooops, we cannot accept your registration as you have not completed all of the mandatory fields (these are marked in red asterix). Please, go back and try again. Thank you!"); return false}
   }
 }
return true
}

function validEmail(email) {
  email1=email.value;
  wrong=0;
  atPos = email1.indexOf("@",1)
  if (atPos == -1){wrong=1}
  if (email1.indexOf("@",atPos+1) > -1){wrong=1}
  periodPos = email1.indexOf(".",atPos)
  if (periodPos == -1){wrong=1}
  if (periodPos+3 > email1.length){wrong=1}
if (wrong != 0){alert("You must enter a valid e-mail address. Please, go back and try again. Thank you!"); return false}
return true
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//from template

function changeImages() {
	if (document.images) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
                        //ie7
                        tmp = document[changeImages.arguments[i]];
                        if (tmp!=null) {
                                document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
                        }
		}
	}
}


