<!--
//*******************************************************
//*                Comment Card Engine                  *
//* This product and other products of OpinionLab, Inc. *
//* are protected by U.S. Patent No. US 6,397,192 B1    *
//* and other patents pending.                          *
//*******************************************************

// Cross frame vulnerabity fix (live)
/*
if (top != self ) 
    {
        top.location=self.location;
    }
*/


var qReq = new Array();
var alreadyCleared = new Array();
var alreadysubmitted = false;
var O_Op6=((navigator.userAgent.toLowerCase().indexOf('opera 6')>-1)||(navigator.userAgent.toLowerCase().indexOf('opera/6')>-1))?true:false;
var O_Op7=((navigator.userAgent.toLowerCase().indexOf('opera 7')>-1)||(navigator.userAgent.toLowerCase().indexOf('opera/7')>-1))?true:false;
var O_Op8=((navigator.userAgent.toLowerCase().indexOf('opera 8')>-1)||(navigator.userAgent.toLowerCase().indexOf('opera/8')>-1))?true:false;
var O_Op9=((navigator.userAgent.toLowerCase().indexOf('opera 9')>-1)||(navigator.userAgent.toLowerCase().indexOf('opera/9')>-1))?true:false;
var O_FF15=(navigator.userAgent.toLowerCase().indexOf('firefox/1.5')>-1)?true:false;
var O_FF20=(navigator.userAgent.toLowerCase().indexOf('firefox/2.')>-1)?true:false;
var O_GChrome=(navigator.userAgent.toLowerCase().indexOf('chrome/0.')>-1)?true:false;
var O_NS5up=((navigator.userAgent.toLowerCase().indexOf('mozilla')!=-1)&&(parseInt(navigator.appVersion)>=5))||O_Op6||O_Op7||O_Op8||O_Op9;
var O_NS4=(document.layers)&&(!O_Op6)&&(!O_Op7)&&(!O_Op8)&&(!O_Op9)?1:0;
var O_IE4=(document.all)&&(!O_Op6)&&(!O_Op7)&&(!O_Op8)&&(!O_Op9)?1:0;
var O_IE6=O_IE4&&navigator.userAgent.toLowerCase().indexOf('msie 6.')>-1;
var O_MAC=(navigator.appVersion.indexOf("Macintosh")>-1);
var O_IE45=(navigator.userAgent.toLowerCase().indexOf('msie 4.')>-1)&&O_MAC&&(!O_Op6)&&(!O_Op7)&&(!O_Op8)&&(!O_Op9);
var O_IE5=(navigator.userAgent.toLowerCase().indexOf('msie 5.0')>-1)&&O_MAC&&(!O_Op6)&&(!O_Op7)&&(!O_Op8)&&(!O_Op9);
var st="";var _d=document;var _w=window;
var topic_selection_mandatory = 0;
var question_required_text = '';
var ts_required_text = '';

var _vH=(O_IE4)?"none":"hidden";var _vS=(O_IE4)?"block":"visible";
var quesNum = 0;
var notClicked = false;
var notClicked2 = false;
var ny_offset=0;
var comment_category;
var qs = document.location.href;
var fields_to_clear_on_submit = new Array();
var f_i = 0;
	
function _GPs(l){var g=(O_IE4)?eval("_d.all('o"+l+"')"):(O_NS5up||O_Op6)?eval("document.getElementById('o"+l+"')"):eval("_d.layers.o"+l);if(O_NS4&&g){return g.pageY}if(O_IE4&&g){return g.offsetTop}if(O_NS5up&&g){return g.offsetTop}}

function _Sh(l,s){var g=(O_IE4)?eval("_d.all('o"+l+"')"):eval("_d.o"+l);g=(O_NS5up)?eval("document.getElementById('o"+l+"')"):g;if(O_NS4&&g)g.visibility=(s)?_vS:_vH;if(O_IE4&&g){g.style.display=(s)?_vS:_vH;g.style.visibility=s?"visible":"hidden";}if(O_NS5up&&g)g.style.visibility=(s)?_vS:_vH}

function _Ps(l,x,y){var g=(O_IE4)?eval("_d.all('o"+l+"')"):eval("_d.o"+l);g=(O_NS5up)?eval("document.getElementById('o"+l+"')"):g;if(O_NS4&&g){g.left=x;g.top=y}if(O_IE4&&g){g.style.left=x;g.style.top=y}if(O_NS5up&&g){g.style.left=x+'px';g.style.top=y+'px'}}

function fR(n){i=0;while(i<qs.length){j=i+n.length;if(qs.substring(i,j)==n){k=qs.indexOf('&',j);return unescape(qs.substring(j+1,(k==-1)?qs.length:k))}i++}return ''}

var firsttry = 1;

function aolresize()
{
firsttry = 0;
var myJSWindow;
var isClientBrowser = false;
var authState = 1;  // set to true initially.  for browsing, can only ever be false for aol 9.1 or above.
var isTarana = false;
if(navigator.userAgent.toLowerCase().indexOf('aol 9.1')>-1) {
    isTarana = true;
}

try{
	if (window != 0) {
		if (typeof window.external != "undefined") {
			if (typeof window.external.jsWindow != "undefined") {
				myJSWindow = window.external.jsWindow;
				   
				// following test is for AOL 9.1 only to determine authentication state.
				if (isTarana) {
					authState = myJSWindow.authState();
					//if (authState == 0){
						//document.write('User is unauthenticated.');
					//}
					//else {
						//document.write('User is authenticated.');
					//}
				}
				isClientBrowser = true;
			}
		}
		if (isClientBrowser) {
			var parentTop = window.top.screenTop;
			var parentLeft = window.top.screenLeft;
			var top = window.screenTop;
			var left = window.screenLeft;
			var xx = parentLeft - left - 80;// + 54;
			var yy = parentTop - top; // + 150;
			window.external.jsWindow.moveBy(xx,yy);
			if (authState != 0){
				var sURL = "aol://1391:48-34291";
				window.navigate(sURL);  // set width using FDO to override browser 86% size
			}
		}
		else  {
			resize(_GPs('_bottom'));
		}
	}
} catch(e) {
	resize(_GPs('_bottom'));
}
}





function resize(card_h){
	walkAnchors(document.body, 10)

	if(fR('resize')=='false' || window.opener==null) return false;

	/*
	if(navigator.userAgent.toLowerCase().indexOf('aol 9.')>-1 && navigator.userAgent.toLowerCase().indexOf('aol 9.0')==-1 && firsttry==1){aolresize();return false}
	*/
	if(navigator.userAgent.toLowerCase().indexOf('aol')>-1 && firsttry==1){aolresize();return false}


	self.setResizable = true;	

	if( (navigator.userAgent.toLowerCase().indexOf('aol')==-1) && (navigator.userAgent.toLowerCase().indexOf('avant')==-1) ){
		self.moveTo((screen.width-535)/2, (screen.height-card_h-100)/2 );
	}
	
	if(O_IE4&&!O_Op6){
		self.resizeTo(535+10,192+10+10+10+5);
		var yPos = 192 - document.body.clientHeight; 
		var xPos = 535 - document.body.clientWidth; 
		var outerHeight = yPos + card_h; 
		var outerWidth = xPos + 535 + 10; 
		if(navigator.userAgent.toLowerCase().indexOf('msie 4.')>-1){outerHeight+=62;}
		if(navigator.userAgent.toLowerCase().indexOf('america online browser')>-1){outerHeight+=100;outerWidth+=-10;}
		if(navigator.userAgent.toLowerCase().indexOf('aol 9.')>-1){outerHeight+=200;outerWidth+=-10;}
		if(navigator.userAgent.toLowerCase().indexOf('aol 8.0')>-1){outerHeight+=-34;outerWidth+=-10}
		if(navigator.userAgent.toLowerCase().indexOf('aol 7.0')>-1){outerHeight+=-34;outerWidth+=-10}
		if(navigator.userAgent.toLowerCase().indexOf('aol 6.0')>-1){outerHeight+=15;outerWidth+=0}
		if(navigator.userAgent.toLowerCase().indexOf('aol 5.0')>-1){outerHeight+=-45;outerWidth+=0}
		
		if(navigator.userAgent.toLowerCase().indexOf('aol 9.')>-1){
			resizeTo(outerWidth,outerHeight+15);
		}
		if(navigator.userAgent.toLowerCase().indexOf('aol 10.')>-1){
			resizeTo(outerWidth,outerHeight+15);
		}
		self.resizeTo(outerWidth,outerHeight+15);
	} else {
		var yPos = 192-window.innerHeight;
		var xPos = 535-window.innerWidth;
		if(O_NS4&&!O_Op6){
			var outerWidth = 535;
			self.resizeTo(outerWidth,card_h-20);
		} else {
			var outerHeight = card_h + window.outerHeight-window.innerHeight;
			var outerWidth = 535 + window.outerWidth-window.innerWidth;
			if(navigator.userAgent.toLowerCase().indexOf('camino')>-1){outerWidth+=15}
			if(O_Op7){outerHeight+=0}
			if(O_Op8||O_Op9){outerHeight+=0}
			if(O_FF15||O_FF20){outerHeight-=12}
			if(O_GChrome){outerHeight+=45;outerWidth+=15;}
			self.resizeTo(outerWidth,outerHeight);
		}
	}
	self.setResizable = false;
	self.focus();
	p_rating=fR('rating');
	if(p_rating==1)document.CommentCard.overall[0].checked=true;
	if(p_rating==2)document.CommentCard.overall[1].checked=true;
	if(p_rating==3)document.CommentCard.overall[2].checked=true;
	if(p_rating==4)document.CommentCard.overall[3].checked=true;
	if(p_rating==5)document.CommentCard.overall[4].checked=true;

	setupClearList();
	
}


function walkAnchors(node, depth) {
	var MAX_NODES = 1000;	// Constant to avoid taking too long
	var count = 0;
	while (node && depth > 0) {
		count ++;
		if (count >= MAX_NODES) {
			var handler = function() {
				walkAnchors(node, depth);
			};
			setTimeout(handler, 50);
			return;
		}
		//console.log(node.tagName);
		if(node.tagName=="TEXTAREA" || node.tagName=="INPUT"){
			// second textareas
			if(typeof node.onfocus=='function') {
				if (/(clearbox)/g.test(node.onfocus) ) {
					fields_to_clear_on_submit[f_i++] = node.id + "|" + node.value;
				}
			} else if (/(answer_[0123456789]+_oth)/g.test(node.id)){
				fields_to_clear_on_submit[f_i++] = node.id + "|" + node.value;
			}
		}

		if (node.nodeType == 1) { // ELEMENT_NODE
			var skipre = /^(script|style|textarea)/i;
			if (!skipre.test(node.tagName) && node.childNodes.length > 0) {
				node = node.childNodes[0];
				depth ++;
				continue;
			}
		}
		if (node.nextSibling) {
			node = node.nextSibling;
		} else {
			while (depth > 0) {
				node = node.parentNode;
				depth --;
				if(node==null)break;
				if (node.nextSibling) {
					node = node.nextSibling;
					break;
				}
			}
		}
	}
}         


function check() {

 // Clear fields that need to be cleared!
 
 for(i=0; i<fields_to_clear_on_submit.length; i++){
 	
 	var fields_to_clear = fields_to_clear_on_submit[i].split("|")
 	if (document.getElementById(fields_to_clear[0])!= null) { 
		if (document.getElementById(fields_to_clear[0]).value == fields_to_clear[1]) document.getElementById(fields_to_clear[0]).value = '';
 	}
 	};

 // Required Custom Questions
 for(i=0; i<qReq.length; i++){

    ArId = document.getElementsByName('answer_'+ qReq[i])
    question_is_answered = false;
    //console.log(ArId);
    for(j=0; j<ArId.length; j++) {
        if (ArId[j].value!='' && ArId[j].type=='textarea'){
            question_is_answered = true;
            break;
        }
        if (ArId[j].value!='' && ArId[j].value!=0 && ArId[j].type!='radio') {
            question_is_answered = true;
            break;
        }
        if (ArId[j].checked!='' && ArId[j].type=='radio') {
            question_is_answered = true;
            break;
        }
    }
    //console.log(qReq[i] + ":" + question_is_answered);
    
    if (!question_is_answered) {
        document.getElementById('qid_'+ qReq[i]).className = 'reqHilite';
        alert(question_required_text==''?'Please answer any questions highlighted in red before you submit your feedback.\nThank you.':question_required_text);
        return false;
    } else {
        document.getElementById('qid_'+ qReq[i]).className = '';
    }
 }




 var DesignValue = "";
 var ContentValue = "";
 var UsabilityValue = "";
 var OverallValue = "";
 if (alreadysubmitted) return false;
 
  //Test if we have an required email category field
 if(comment_category==1&&document.CommentCard.email_address.value==''){
 	alert('Please choose a feedback category before submitting.');
	return false;
 }
 
 //Test if we have an required topic selector field
if(typeof document.CommentCard.topic_selection!='undefined' && topic_selection_mandatory==1){
	var ts = eval('document.CommentCard.answer_'+document.CommentCard.topic_selection.value);
	if(ts.value=='' || ts.value==0){
	    if (ts_required_text!='') {
	        alert(ts_required_text);
	    } else {
		    alert('Please choose a topic for your comments before submitting.');
		}
	return false;
 	}
 }
if(typeof document.CommentCard.topic_selection!='undefined' && topic_selection_mandatory==2){
	var ts = eval('document.CommentCard.answer_'+document.CommentCard.topic_selection.value);
	if(ts.value=='' || ts.value==0){
		alert('Per favore seleziona un argomento prima di inviare.');
	return false;
 	}
 }
 
 //If screen_res are eq to 0 then set it here on the card (for O-mail links mainly)
 if(document.CommentCard.width.value=='0'){
 	document.CommentCard.width.value = screen.width;
 }
 
 if(document.CommentCard.height.value=='0'){
	document.CommentCard.height.value = screen.height;
 }
 
 
 // Make sure the comment is not longer than 1000 chars
 if(typeof document.CommentCard.comments!='undefined') {
	 if (document.CommentCard.comments.value.length>1000) {
	  document.CommentCard.comments.select();
	  document.CommentCard.comments.focus();
	  alert(comment_message);
	  return false;
	 }
 }
 
  var globalRating = 0.0, totalRating = 0.0;
  
  // Checking if we have CDU section	
  if(typeof document.CommentCard.content!='undefined'){
 
// Checking the Content Rating
if(typeof document.CommentCard.content[0]!='undefined'){
	 for (i=0; i<5; i++) {
	  if (document.CommentCard.content[i].checked=="1") {
	   ContentValue=document.CommentCard.content[i].value;
	   globalRating += parseInt(ContentValue);
	   totalRating += 1;
	  }
	 }
 } else {
	 ContentValue=document.CommentCard.content.value;
	 globalRating += parseInt(ContentValue);
	 totalRating += 1; 
 }
	 
// Checking the Design Rating
if(typeof document.CommentCard.design[0]!='undefined'){
 for (i=0; i<5; i++) {
  if (document.CommentCard.design[i].checked=="1") {
   DesignValue=document.CommentCard.design[i].value;
    globalRating += parseInt(DesignValue);
    totalRating += 1;
  }
 }
} else {
   DesignValue=document.CommentCard.design.value;
   globalRating += parseInt(DesignValue);
   totalRating += 1;
}

 // Checking the Usability Rating
if(typeof document.CommentCard.usability[0]!='undefined'){
 for (i=0; i<5; i++) {
  if (document.CommentCard.usability[i].checked=="1") {
   UsabilityValue=document.CommentCard.usability[i].value;
    globalRating += parseInt(UsabilityValue);
    totalRating += 1;
  }
 }
} else {
  UsabilityValue=document.CommentCard.usability.value;
  globalRating += parseInt(UsabilityValue);
  totalRating += 1;
}
 
 } else {DesignValue=""; ContentValue=""; UsabilityValue="";}
 // Checking the OverAll Rating
 
 
if(typeof document.CommentCard.overall!='undefined') {
 
 
if(typeof document.CommentCard.overall.value!='undefined'){
	OverallValue = document.CommentCard.overall.value;
} else {
 for (i=0; i<5; i++) {
  if(typeof document.CommentCard.overall[i]!='undefined'){
	  if(document.CommentCard.overall[i].checked=="1"){
		OverallValue=document.CommentCard.overall[i].value;
	  }
  }else{OverallValue="0"}
 }
}

} else { OverallValue="0" }

 if (DesignValue=="" && ContentValue=="" && UsabilityValue=="" & OverallValue =="") { 
  alert(submit_message);
  document.getElementById('ovText').className = "alert";
  return false;
 } else {
 	// Check added 5/11/04, make sure global rating is integer otherwise ask again
	var avgRating = Math.round(globalRating/totalRating);
 	if (avgRating != (globalRating/totalRating) && OverallValue=="") {
 		alert(submit_message);
		document.getElementById('ovText').className = "alert";
 		return false;
 	}
 	
  // Make the comment blank is not modified
  if(typeof document.CommentCard.comments!='undefined'){if(!notClicked)document.CommentCard.comments.value=''};
  alreadysubmitted = true;
  return true;
 }
}
function openabout() {
var _rW=screen.width;
var _rH=screen.height;
var lang = window.location.href.substring(window.location.href.indexOf('lang=')+5, window.location.href.indexOf('&time1='));
if(lang==0||lang=="0"||lang==""||lang.length>2){
	window.open('http://www.opinionlab.com/about_this_system.asp')
}else{
	window.open('http://ccc01.opinionlab.com/about20.asp?lang='+lang,'AboutOnlineOpinion','width=330,height=248,screenX='+((_rW-330)/2)+',screenY='+((_rH-248)/2)+',top='+((_rH-248)/2)+',left='+((_rW-330)/2));
}
}

function clearbox(obj){
	if(!notClicked){obj.value='';notClicked=true}
}

function clearbox2(obj){
	if(!notClicked2){obj.value='';notClicked2=true}
}

function clearother(thisobj){
if(thisobj.value=='other response')thisobj.value='';
}

var clicked = false;

function dropdown_other(l, n, v){
	if(O_NS4){
		return false;
	}else{
		if(v.toLowerCase()=='other'){
			eval("document.CommentCard."+n+"_oth.style.visibility='visible';")
		}else{
			eval("document.CommentCard."+n+"_oth.style.visibility='hidden';")
		}
		return false;
	}
}

function dropdown_other_v2(l, n, v, deftxt){
	if(O_NS4){
		return false;
	}else{
		if(v.toLowerCase()=='other'){
			eval("document.CommentCard."+n+"_oth.value='"+deftxt+"';");
			eval("document.CommentCard."+n+"_oth.style.visibility='visible';")
		}else{
			eval("document.CommentCard."+n+"_oth.value='';");
			eval("document.CommentCard."+n+"_oth.style.visibility='hidden';")
		}
		return false;
	}
}

function dropdown_other_display(l, n, v){
	if(O_NS4){
		return false;
	}else{
		if(v.toLowerCase()=='other'){
			eval("document.CommentCard."+n+"_oth.style.display='inline';")
		}else{
			eval("document.CommentCard."+n+"_oth.style.display='none';")
		}
		return false;
	}
}

function dropdown_yes(l, n, v){
	if(O_NS4){
		return false;
	}else{
		if(v.toLowerCase()=='yes'){
			eval("document.CommentCard."+n+"_oth.style.visibility='visible';")
		}else{
			eval("document.CommentCard."+n+"_oth.style.visibility='hidden';")
		}
		return false;
	}
}

function dropdown_yes_display(l, n, v, deftxt){
	if(O_NS4){
		return false;
	}else{
		if(v.toLowerCase()=='yes'){
			eval("document.CommentCard."+n+"_oth.value='"+deftxt+"';");
			eval("document.CommentCard."+n+"_oth.style.display='inline';")
		}else{
			eval("document.CommentCard."+n+"_oth.value='';");
			eval("document.CommentCard."+n+"_oth.style.display='none';")
		}
		return false;
	}
}

function dropdown_no(l, n, v){
	if(O_NS4){
		return false;
	}else{
		if(v.toLowerCase()=='no'){
			eval("document.CommentCard."+n+"_oth.style.visibility='visible';")
		}else{
			eval("document.CommentCard."+n+"_oth.style.visibility='hidden';")
		}
		return false;
	}
}

function dropdown_no_display(l, n, v, deftxt){
	if(O_NS4){
		return false;
	}else{
		if(v.toLowerCase()=='no'){
			eval("document.CommentCard."+n+"_oth.value='"+deftxt+"';");
			eval("document.CommentCard."+n+"_oth.style.display='inline';")
		}else{
			eval("document.CommentCard."+n+"_oth.value='';");
			eval("document.CommentCard."+n+"_oth.style.display='none';")
		}
		return false;
	}
}

function oth_reset(n){
	if(alreadyCleared[n]==1)
		return;
	eval("document.CommentCard."+n+"_oth.value='';");
	return false;
}

function setupClearList() {
	var i=1;
	if(i <= quesNum ) {
		alreadyCleared["answer_"+document.CommentCard.question1.value]=0;
		i++;
	}
	if(i <= quesNum ) {
		alreadyCleared["answer_"+document.CommentCard.question2.value]=0;
		i++;
	}
	if(i <= quesNum ) {
		alreadyCleared["answer_"+document.CommentCard.question3.value]=0;
		i++
	}
	if(i <= quesNum ) {
		alreadyCleared["answer_"+document.CommentCard.question4.value]=0;
		i++;
	}
	if(i <= quesNum ) {
		alreadyCleared["answer_"+document.CommentCard.question5.value]=0;
		i++;
	}
	if(i <= quesNum ) {
		alreadyCleared["answer_"+document.CommentCard.question6.value]=0;
		i++;
	}
	if(i <= quesNum ) {
		alreadyCleared["answer_"+document.CommentCard.question7.value]=0;
		i++;
	}
	if(i <= quesNum ) {
		alreadyCleared["answer_"+document.CommentCard.question8.value]=0;
		i++;
	}
	if(i <= quesNum ) {
		alreadyCleared["answer_"+document.CommentCard.question9.value]=0;
		i++;
	}
	if(i <= quesNum ) {
		alreadyCleared["answer_"+document.CommentCard.question10.value]=0;
		i++;
	}
	if(i <= quesNum ) {
		alreadyCleared["answer_"+document.CommentCard.question11.value]=0;
		i++;
	}
	if(i <= quesNum ) {
		alreadyCleared["answer_"+document.CommentCard.question12.value]=0;
		i++;
	}
}
//-->
