widgetServer = "sibetap01.ext.nokia.com";

var flg=0;
function feedbackwriteJS(feedbackprojLang,feedbackNprojId){

	var feedbacklan="'"+feedbackprojLang+"'";
	
	var str = '';
	str+='		<div id="feedbacknps-sidebar' + feedbackidSuffix + '" class="nps-sidebar nps-sidebar'+feedbackidSuffix+'" style="margin-top:10px;margin-bottom:10px;">';
	str+='			<div id="feedbacknps-recommend' + feedbackidSuffix + '" class="nps-recommend nps-recommend'+feedbackidSuffix+'">';
	
	str+='			<\/div>';
	str+='				<div id="feedbacknps-tabs-box' + feedbackidSuffix + '" class="nps-tabs-box nps-tabs-box'+feedbackidSuffix+'">';
	str+='					<div id="nps-fb-box' + feedbackidSuffix + '" class="nps-fb-box nps-fb-box'+feedbackidSuffix+'">';
	
	
	str+='					<\/div>';
	str+='				<\/div>';
	str+='		<\/div>';

	//document.getElementById('nps_widget_script').innerHTML=str;
	document.write(str);
	document.getElementById('overlay').setAttribute("name",feedbackidSuffix);
	
	
}

function initfeedbackwidget()
{
	var flg=0;
	
	version="";
	projId    = ""; 
	projName  = "";
	bgURL     = "";
	bgTopURL  = "";
	bgBotURL  = "";
	border    = "";
	fontColor = "";
	projLang="";

	var scriptTag=document.getElementsByTagName('script');
	//var feedbackWidgetinsert=document.getElementById('feedbackWidgetDiv');
	//var newtag=document.createElement('a');
	//newtag.name="widgettop";
	//feedbackWidgetinsert.insertBefore(newtag,feedbackWidgetinsert);
	

	for (i=0;i<scriptTag.length ;i++ )
	{
		 var ScriptHTML=scriptTag[i].innerHTML;
		 if (ScriptHTML.indexOf('nps_project_id')!=-1)
		 {
			flg=flg+1;
		
		}
	}


	
	if (flg!=0)
	{
		try
		{

			feedbacknpsInit(flg);
			//feedbackshowWidget();
		
		}
		catch (e)
		{
		  
		}

	}
	else
	{
		alert("No Widget Added");
	}
	

}

function feedbackinitnps()
	{
		
	   var npsbrowver = NPSBrowserDetect.version;
	   document.getElementById('feedbackWidgetDiv').style.textAlign="left";
	   
	if (document.getElementById('overlay'))
	{
	var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}

		
		
		document.getElementById('overlay').style.height=(pageHeight+100)+"px";

		
		if (window.ActiveXObject)
		{
		
			if (npsbrowver>5&&npsbrowver<7)
			{
			
				document.getElementById('feedbackWidgetDiv').style.position="absolute";
				document.getElementById('nps_widget_script').style.position="relative";
				document.getElementById('overlay').style.width=pageWidth+"px";

				document.getElementById('feedbackWidgetDiv').style.top="35%";
				document.getElementById('feedbackWidgetDiv').style.left=((pageWidth-410)/2)+"px";
				
				document.getElementById('feedbackWidgetDiv').style.marginTop="-"+(pageHeight*10/100)+"px";
			}
			else
			{
				
				document.getElementById('feedbackWidgetDiv').style.position="absolute";
				document.getElementById('nps_widget_script').style.position="relative";
				document.getElementById('overlay').style.width="100%";

				document.getElementById('feedbackWidgetDiv').style.top="35%";
				document.getElementById('feedbackWidgetDiv').style.left=((pageWidth-410)/2)+"px";
				
				document.getElementById('feedbackWidgetDiv').style.marginTop="-"+(pageHeight*10/100)+"px";

				
			}
				  
			
		}
		else
		{
			document.getElementById('feedbackWidgetDiv').style.position="absolute";
				document.getElementById('nps_widget_script').style.position="relative";
			document.getElementById('overlay').style.width="100%";
			document.getElementById('feedbackWidgetDiv').style.top="35%";
			document.getElementById('feedbackWidgetDiv').style.left=((pageWidth-410)/2)+"px";
			document.getElementById('feedbackWidgetDiv').style.marginTop="-"+(pageHeight*10/100)+"px";
		}
	}
		var obj=document.getElementById("feedbackWidgetDiv");
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			curleft = obj.offsetLeft
			curtop = obj.offsetTop
			while (obj = obj.offsetParent) {
				curleft += obj.offsetLeft
				curtop += obj.offsetTop
			}
		}
	
	 document.getElementById('nps_widget_script').style.display="block";

	  if (document.getElementById('overlay'))
		 {
		  document.getElementById('overlay').style.display="block";
		 }
	}

window.onresize = resize;

function resize()
{
  var npsbrowver = NPSBrowserDetect.version;
  if(document.getElementById('overlay').style.display=="block")
	{
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		var windowWidth, windowHeight;
		
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}
		if (window.ActiveXObject)
		{
			if (npsbrowver>5&&npsbrowver<7)
			{
			
				document.getElementById('feedbackWidgetDiv').style.left=((pageWidth-410)/2)+"px";
				document.getElementById('overlay').style.width=pageWidth+"px";
			}
			else
			{
				document.getElementById('feedbackWidgetDiv').style.left=((pageWidth-410)/2)+"px";
			}
		}
			
		else
		{
			document.getElementById('feedbackWidgetDiv').style.left=((pageWidth-410)/2)+"px";
		}
		}
  }



initfeedbackwidget();