// Myaccount Javascript routines
// $Id: myaccount.js 23 2009-01-14 14:02:06Z pglh $


function print_r(theObj){
  if(theObj.constructor == Array ||
     theObj.constructor == Object){
    document.write("<ul>")
    for(var p in theObj){
      if(theObj[p].constructor == Array||
         theObj[p].constructor == Object){
document.write("<li>["+p+"] => "+typeof(theObj)+"</li>");
        document.write("<ul>")
        print_r(theObj[p]);
        document.write("</ul>")
      } else {
document.write("<li>["+p+"] => "+theObj[p]+"</li>");
      }
    }
    document.write("</ul>")
  }
}


$(document).ready( function()
{
	fixRecaptcha();
	var config = {
		toolbar:
		[
			['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink'],
			['UIColor']
		]
	};

	$('.wysiwyg textarea').ckeditor(config);
	$('.wysiwyg-full textarea').ckeditor().each( function()
	{
		CKFinder.SetupCKEditor( $(this).ckeditorGet(), '/ckfinder/' );
	});

     $('#newsletter_sending_date').datepicker({  
         duration: '',  
         showTime: true,  
         constrainInput: false,  
         stepMinutes: 10,  
         stepHours: 1,  
         altTimeField: '',  
         time24h: true  
      });

     $('#date_selector').datepicker({  
         duration: '',  
         showTime: false,  

		 changeYear: true,
         yearRange: '1910:2010'
      });

	/*The ajax uploading tool*/
	if( $("#uploadify").length > 0 )
	{
		$("#uploadify").uploadify({
			'uploader'       : '/uploadify/uploadify.swf',
			'script'         : '/uploadify/uploadify.php',
			'cancelImg'      : '/uploadify/cancel.png',
			'folder'         : '/uploads',
			'queueID'        : 'fileQueue',
			'auto'           : true,
			'multi'          : true
		});
	}

/*
$("ul#topnav li").hover(function() { //Hover over event on list item
	$(this).css({ 'background' : '#1376c9 url(/images/nav/topnav_active.gif) repeat-x'}); //Add background color + image on hovered list item
	$(this).find("span").show(); //Show the subnav
} , function() { //on hover out...
	$(this).css({ 'background' : 'none'}); //Ditch the background
	// $(this).find("span").hide(); //Hide the subnav
});
*/
} );

function switchnavs(theid){ 
var thearray= new Array("home_span","content_span", "website_span", "marketing_span", "help_span", "developer_span", "cinema_span","management_span"); 
for(i=0; i<thearray.length; i++){ 
      if(thearray[i] == theid){ 
            document.getElementById(theid).style.display="block"; 
      }else{ 
            document.getElementById(thearray[i]).style.display="none"; 
      } 
   } 
}
function fixRecaptcha()
{
	// This fixes an anomaly in which the recaptcha field disappears when the user has
	// Firefox, has NoScript installed, has allowed tpad.com and forbidden recaptcha.net.
	// Recaptcha's Javascript doesn't execute, but because the <noscript> tag is on our
	// page neither does the non-JS alternative! This piece of JS takes the content of
	// the <noscript> tag and dumps it into the paragraph outside, so we get to see the
	// para in this case.
	
	var recaptchaParagraph = document.getElementById("recaptchaContainer")
	if( recaptchaParagraph )
	{
		// Make sure the user is not executing scripts from recaptcha.net.
		// We don't want to display recaptcha twice!
		if( typeof(RecaptchaState) == "undefined" )
		{
			var recaptchaNoscriptTag = recaptchaParagraph.getElementsByTagName("noscript")[0];
			var recaptchaHTML = recaptchaNoscriptTag.innerHTML;
			recaptchaHTML = recaptchaHTML.replace(/&lt;/g, "<");
			recaptchaHTML = recaptchaHTML.replace(/&gt;/g, ">");
			recaptchaHTML = recaptchaHTML.replace(/&amp;/g, "&");
			recaptchaParagraph.innerHTML = recaptchaHTML;

			var explNode = document.createTextNode("You are seeing this message because you are running Firefox, you have the NoScript extension and have forbidden recaptcha.net but allowed tpad.com. To make your experience smoother Tpad recommends you allow recaptcha.net to execute Javascript in future. Tpad uses Recaptcha in multiple places on its site.");
			recaptchaParagraph.appendChild(explNode);
		}
	}
}

