﻿
var	Padding;
var	BPadding;
var	SurveyHolder;
var	HideEnabled;
var	DescTable;
var	SurveyVoted;
var	rImage		        = null;
var	oid			        = "unK1ZM0w2mQ%3d";
var	uid			        = null;
var	sid			        = "yhlkRbE%24%24%24ptOc%3d";
var	sido		        = "5YH5ylJrXJU%3d";
var	qid			        = "vS5wqHPoFK8%3d";
var	pn			        = null;
var	pv			        = null;
var	infotxt		        = "Anketimize katıldığınız için teşekkür ederiz."

if(window.attachEvent)
	window.attachEvent("onload", LoadPage);
else
	window.addEventListener("load", LoadPage, false);

function LoadPage(){

    CreateObjects();
	InitSurvey();
}

function InitSurvey(uID, Dim1){

	uid				= uID;
	pn				= "Sayfa";
	
	if(uID && uID != null)
		uid	= uID;
	else{
		
		var	RDate	= new Date();
		uid	= RDate.getFullYear() + "-" + RDate.getMonth() + "-" + RDate.getDay() + "T" + RDate.getHours() + ":" + RDate.getMinutes() + ":" + RDate.getSeconds() + "MS" + RDate.getMilliseconds()
	}
	
	if(Dim1 && Dim1 != null)
		pv	= Dim1;
	else
		pv	= window.location;
	
	SurveyVoted		= false;
	HideEnabled		= false;
	Padding			= 40;
	BPadding		= 4;
	BTopPadding		= 30;
	SurveyHolder	= document.getElementById("SurveyHolder");
	DescTable		= document.getElementById("DescTable"); 

	for(var i=1; i<6; i++){
	
		if(window.attachEvent)
			document.getElementById("P_" +i.toString()).attachEvent("onmouseover", SelectPoint);
		else
			document.getElementById("P_" +i.toString()).addEventListener("mouseover", SelectPoint, false);
	}

	PositionObjects();
	
	if(window.attachEvent){
	
		window.attachEvent("onscroll", PositionObjects);
		window.attachEvent("onresize", PositionObjects);
	}
	else{
	
		window.addEventListener("scroll", PositionObjects, false);
		window.addEventListener("onscroll", PositionObjects, false);
		window.addEventListener("resize", PositionObjects, false);
	}
	
	for(var i=1; i<=5; i++){
	
		if(window.attachEvent)
			document.getElementById("P_" +i.toString()).attachEvent("onclick", HideLikeLightning);
		else
			document.getElementById("P_" +i.toString()).addEventListener("click", HideLikeLightning, false);
	}
	
	if(window.attachEvent)
		document.getElementById("HDetailed").attachEvent("onclick", OpenSurvey);
	else
		document.getElementById("HDetailed").addEventListener("click", OpenSurvey, false);
}

function PositionObjects(){

	SurveyHolder.style.left	= (document.documentElement.clientWidth - SurveyHolder.clientWidth - Padding).toString() + "px";
	SurveyHolder.style.top	= (document.documentElement.clientHeight + document.documentElement.scrollTop - Padding - SurveyHolder.clientHeight).toString() + "px";
	
	DescTable.style.left	= (document.documentElement.clientWidth - SurveyHolder.clientWidth - Padding - BPadding - DescTable.clientWidth).toString() + "px";
	DescTable.style.top		= (document.documentElement.clientHeight + document.documentElement.scrollTop - Padding - DescTable.clientHeight).toString() + "px";
}

function ShowPointer(){

	if(!SurveyVoted){
	
		HideEnabled	= false;

		for(var i=1; i<6; i++){
		
			document.getElementById("P_" +i.toString()).style.display	= "";
		}
		
		DescTable.style.display	= "";

		PositionObjects();
		PositionObjects();
	}
}

function ShowDescTable(){

	SurveyVoted	= true;
	HideEnabled	= false;
	DescTable.style.display	= "";
	
	PositionObjects();
	PositionObjects();
}

function HideDescTableTimeout(){

	setTimeout(HideDescTable, 2000);
}

function HideDescTable(){

	DescTable.style.display	= "none";
}

function HideLikeLightning(e){
		
	var	Selected	= null;
	var	Vote		= 0;

	if(e && e.target){
	
		Selected	= e.target;
	}
	else{
	
		Selected	= event.srcElement;
	}
	
	Vote	= Selected.id.split("_")[1];
		
	SendRequest(Vote);
	
	for(var i=1; i<6; i++){
	
		document.getElementById("P_" +i.toString()).style.display	= "none";
	}
	
	DescTable.style.display	= "none";
	
	PositionObjects();
	PositionObjects();
}

function HidePointer(){

	if(HideEnabled){
	
		for(var i=1; i<6; i++){
		
			document.getElementById("P_" +i.toString()).style.display	= "none";
		}
		
		DescTable.style.display	= "none";
		
		PositionObjects();
		PositionObjects();
	}
}

function HidePointerByTimeout(){
	
	HideEnabled	= true;
	setTimeout("HidePointer()", 1000);
}

function SelectPoint(e){

	var	Selected	= null;

	if(e && e.target){
	
		Selected	= e.target;
	}
	else{
	
		Selected	= event.srcElement;
	}
	
	for(var i=1; i<=Number(Selected.id.split("_")[1]); i++){
	
		document.getElementById("I_" +i.toString()).src	= "Images/Survey/FS.gif"
	}
	
	for(var i=Number(Selected.id.split("_")[1])+1; i<=5; i++){
	
		document.getElementById("I_" +i.toString()).src	= "Images/Survey/ES.gif"
	}
}

function CreateObjects(){

	var	SurveyHolder;
	var	DescTable;
	var HTML;
	
	HTML     = "<table onmouseover=\"ShowPointer()\" onmouseout=\"HidePointerByTimeout()\" id=\"SurveyHolder\" style=\"position:absolute\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">";
	    HTML    += "<tr>";
	        HTML    += "<td title=\"Çok İyi\" id=\"P_5\" style=\"cursor:pointer;display:none;width:20px;height:20px;text-align:center\"><img id=\"I_5\" alt=\"Çok iyi\" src=\"Images/Survey/ES.gif\"/></td>";
	    HTML    += "</tr>";
	    HTML    += "<tr>";
	        HTML    += "<td title=\"İyi\" id=\"P_4\" style=\"cursor:pointer;display:none;width:20px;height:20px;text-align:center\"><img id=\"I_4\" alt=\"İyi\" src=\"Images/Survey/ES.gif\"/></td>";
	    HTML    += "</tr>";
	    HTML    += "<tr>";
	        HTML    += "<td title=\"Orta\" id=\"P_3\" style=\"cursor:pointer;display:none;width:20px;height:20px;text-align:center\"><img id=\"I_3\" alt=\"Orta\" src=\"Images/Survey/ES.gif\"/></td>";
	    HTML    += "</tr>";
	    HTML    += "<tr>";
	        HTML    += "<td title=\"Kötü\" id=\"P_2\" style=\"cursor:pointer;display:none;width:20px;height:20px;text-align:center\"><img id=\"I_2\" alt=\"Kötü\" src=\"Images/Survey/ES.gif\"/></td>";
	    HTML    += "</tr>";
	    HTML    += "<tr>";
	        HTML    += "<td title=\"Çok Kötü\" id=\"P_1\" style=\"cursor:pointer;display:none;width:20px;height:20px;text-align:center\"><img id=\"I_1\" alt=\"Çok Kötü\" src=\"Images/Survey/ES.gif\"/></td>";
	    HTML    += "</tr>";
	    HTML    += "<tr>";
	        HTML    += "<td style=\"cursor:pointer;width:20px;height:20px;text-align:center\"><img alt=\"\" src=\"Images/Survey/SM.gif\"/></td>";
	    HTML    += "</tr>";
	HTML    += "</table>";
	
	HTML    += "<table onmouseover=\"ShowPointer()\" onmouseout=\"HidePointerByTimeout()\" id=\"DescTable\" style=\"display:none;position:absolute;\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\">";
	     HTML    += "<tr>";
	        HTML    += "<td style=\"font-size:1px;width:8px; height:8px;vertical-align:bottom;\"><img alt=\"\" src=\"Images/Survey/TL.gif\"/></td>";
	        HTML    += "<td style=\"font-size:1px;height:8px;background-image:url(Images/Survey/TT.gif); background-repeat:repeat-x;\">&nbsp;</td>";
	        HTML    += "<td style=\"font-size:1px;width:17px;height:8px;vertical-align:bottom;\"><img alt=\"\" src=\"Images/Survey/TR.gif\"/></td>";
	    HTML    += "</tr>";
	   HTML    += "<tr>";
	        HTML    += "<td style=\"font-size:1px;width:6px;background-image:url(Images/Survey/LL.gif); background-repeat:repeat-y;\">&nbsp;</td>";
	        HTML    += "<td id=\"BContent\" style=\"font-size:10px; font-family:Tahoma; width:100px; height:100px; background-color:#ffffff; text-align:center;\">";
	            HTML    += "<span id=\"Message\">Yıldızları kullanarak bu sayfayı değerlendirebilirsiniz.</span><br /><br />";
	            HTML    += "<a id=\"HDetailed\" style=\"cursor:pointer; color:#ff0000; text-decoration:underline;\">Daha ayrıntılı değerlendirmek istiyorum.</a>";
	        HTML    += "</td>";
	        HTML    += "<td style=\"font-size:1px;width:17px;background-image:url(Images/Survey/RR.gif); background-repeat:repeat-y; vertical-align:bottom\"><img alt=\"\" src=\"Images/Survey/AA.gif\"/>&nbsp;</td>";
	    HTML    += "</tr>";
	    HTML    += "<tr>";
	        HTML    += "<td style=\"font-size:1px;width:8px; height:7px;vertical-align:top;\"><img alt=\"\" src=\"Images/Survey/BL.gif\"/></td>";
	        HTML    += "<td style=\"font-size:1px;height:7px;background-image:url(Images/Survey/BB.gif); background-repeat:repeat-x;\">&nbsp;</td>";
	        HTML    += "<td style=\"font-size:1px;width:17px; height:7px;vertical-align:top;\"><img alt=\"\" src=\"Images/Survey/BR.gif\"/></td>";
	    HTML    += "</tr>";
	HTML    += "</table>";
	
	document.body.innerHTML += HTML;
}

function SendRequest(VT){

	var	Params	= "";

	Params	+= "d="+ Date();
	Params	+= "&oid="+ oid;
	Params	+= "&uid="+ uid;
	Params	+= "&sid="+ sid;
	Params	+= "&qid="+ qid;
	Params	+= "&so="+ VT;
	Params	+= "&pn="+ pn;
	Params	+= "&pv="+ pv;

	rImage					= new Image();
	rImage.onload			= ParseValues;
	rImage.src				= "http://www.anketport.com/public/WebPageScore.aspx?" + Params;	
}

function ParseValues(){
	
	if(rImage.width > 0){
			
		document.getElementById("Message").innerHTML		= infotxt;
		document.getElementById("HDetailed").style.display	= "none";
		
		ShowDescTable();
		HideDescTableTimeout();
	}	
}

function OpenSurvey(){

	var	Params	= "";
	
	oid="fXuivQta/OM=";//9
	sid="CiSkAT8kmX0%3d";//149

	Params	+= "d="+ Date();
	Params	+= "&oid="+ oid;
	Params	+= "&uid="+ uid;
	Params	+= "&sid="+ sid;
	//	Params	+= "&qid="+ qid;
	//	Params	+= "&pn="+ pn;
	Params	+= "&pv="+ pv;
	Params	+= "&w=a1lmG7qw9g4%3d";

	window.open("http://www.anketport.com/SurveyRedirect.aspx?" + Params,"","width=600,height=515","toolbar=0, resize=0, scrollbars=0, status=1");
}