$(document).ready(function(){


		// Initialize Survey Dialog			
		$('#survey').dialog({
			autoOpen: false,
			width: 680,
			height: 530,
			show: ('scale', 500),
			hide: 'scale',
			resizable:false,
			modal: true
		});
		

		// survey button
		$('#surveyLink').click(function(){
			$('#survey').dialog('open');
			setTimeout('loadSurvey()', 50000)
			return false;
		});
		
		
		// Initialize Survey Initializer			
		$('#surveyInitializer').dialog({
			autoOpen: false,
			width: 480,
			height: 287,
			show: 'blind',
			hide: 'blind',
			resizable:false,
			draggable: false,			
			modal: true
		});
		
		//UnStyle Initialize Survey
		$('#ui-dialog-title-surveyInitializer').parent().css("display", "none")
	    $('#ui-dialog-title-surveyInitializer').parent().parent().css({"background": "none", "border": "none" });
		$('.hm #ui-dialog-title-survey').parent().css({"background": "url(images/titlebar.jpg) no-repeat top", "border": "none" , "color": "#000000" })			
		$('.int #ui-dialog-title-survey').parent().css({"background": "url(../images/titlebar.jpg) no-repeat top", "border": "none" , "color": "#000000" })

		//Get cookie function
		function getCookie(c_name)
		{
		if (document.cookie.length>0)
		  {
		  c_start=document.cookie.indexOf(c_name + "=");
		  if (c_start!=-1)
			{
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
			}
		  }
		return false;
		}
		


		//check for cookie
		if(getCookie('antSurvey') == false ){
					
			//create a cookie
			var DayVar = 1; //Set for 1 Day
			var date = new Date();
			date.setTime(date.getTime()+(DayVar*24*60*60*1000));
			var expires = date.toGMTString();
			//Sat, 30 Jul 2011 20:47:11 UTC
			document.cookie = "antSurvey=true; expires=" + expires +"; path=/";
					
			//Ask for survey
			$('#surveyInitializer').dialog('open');
			
			//Take Survey Button
			$('#takeSurvey').click(function(){
				$('#surveyInitializer').dialog('close');
				//window.open('http://vp-nri.com/take?i=160106&h=xG2wyG3t77m3obHkWGKmSQ','mywindow','width=800,height=550,scrollbars=yes')
				setTimeout("$('#survey').dialog('open')", 500);
				return false;									   
			});
			
			//No Thanks Button
			$('#noThanks').click(function(){
				$('#surveyInitializer').dialog('close');
				return false;									   
			});
			
			
		}




	
});


function loadSurvey(){
	//var iframeSrc = $('#iframeSurvey').attr('src')
	//$('#iframeSurvey').attr('src', iframeSrc);
}


