
$(document).ready( function(){
	/* Slide show */
	$('.slideshow').cycle('fade');
	/* input init */
	var inp2 = $(".updates-form input").eq(0);
	inp2.val('SIGN UP FOR EMAIL UPDATES');
	var val2 = inp2.val();
	var inp1 = $(".search-form input").eq(0);
	inp1.val('SEARCH SITE');
	var val1 = inp1.val();
	var inp3 = $(".form input").eq(0);
	inp3.val('ENTER YOUR EMAIL ADDRESS');
	var val3 = inp3.val();
	/* input focus on */
	inp1.focus(function(){
		if(inp1.val() == val1){
			inp1.val('');
		} 
	});
	inp2.focus(function(){
		if(inp2.val() == val2){
			inp2.val('');
		} 
	});
	inp3.focus(function(){
		if(inp3.val() == val3){
			inp3.val('');
		} 
	});
	/* input focus off */
	inp1.blur(function(){
		if(inp1.val() == ""){
			inp1.val(val1);
		} 
	});
	inp2.blur(function(){
		if(inp2.val() == ""){
			inp2.val(val2);
		} 
	});
	inp3.blur(function(){
		if(inp3.val() == ""){
			inp3.val(val3);
		} 
	});
	/* slideshow  onClick  */
	$(".image ").cycle({ 
	    fx:     'fade', 
	    speed:  'slow', 
	    timeout: 5000, 
	    pager:  '.number ul',
	    pause: 1
	});
	/* slideshow  onClick   init*/
	$(".number ul li").remove();	
	$(".number ul a").wrap('<li></li>')
	$(".number ul a").eq(0).addClass(' activeSlide');
	$(".number ul a").click(function(){
		$(".number ul a").removeClass(' activeSlide');
		$(this).addClass(' activeSlide');	
	});	
	
    if(readCookie('popup')!='hide')
    {
        $('#ModalPopup').click();
        createCookie('popup','hide',700);
    }
    $('a[href*=ube.com]').click(function(){
        return(exitMsg());
    });

    
    HackIssues();
$(".size p").click(function(){
	size_id = $(".size p").index(this);
	change_to();
	$("body").addClass('size'+size_id);
});

SeedSignup();

$('input:visible').css('position','relative');

});

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}


function change_to(){
	for(var i = 0;i<3;i++){
		$("body").removeClass('size'+i);
	}	
}	

function HackIssues()
{
    $('.pageTitle[id*=IssueTitle] ~ br').remove();
    $('.pageTitle[id*=IssueTitle]').remove(); 
    //$('table[id*=SocialTagsTable]').remove();
}

function exitMsg(){
     var answer = confirm("You are now leaving the Congressman Scott Murphy website. Thank you for visiting. Neither my office nor the U.S. House of Representatives is responsible for the content of the non-House site you are about to access.")

    if (!answer)
    return false;

    return true;
}

function SeedSignup()
{
    //var homePageEmail = $('#HomeEmailInput').val();
    //if (homePageEmail != null)
    //{
    //    $('#HomeEmailInput').val(homePageEmail.replace(/%40/g,'@'));
    //}
    
    //$('#HomeEmailInput').val($('#HomeEmailInput').val().replace(/%40/g,"@"));
    var formID = jQuery.url.param('ID');
//    if(formID == '526')
//    {
//        var email = jQuery.url.param('email');
//        email = email.replace(/%40/,"@");
//        $('#aspnetForm input[id*=EmailControl]').val(email);        
//        //$('#ctl00_ctl00_ctl03_MyText').val(jQuery.url.param('lastname').replace(/\+/," "));
//        //$('#ctl00_ctl00_ctl02_MyText').val(jQuery.url.param('firstname').replace(/\+/," "));
//    }
    if (formID == '526')
    {
        $('input#ctl00_ctl09_ctl08_MyText').replaceWith('<textarea id="ctl00_ctl09_ctl08_MyText" name="ctl00$ctl09$ctl08$MyText" rows="6" cols="40">'+$('input#ctl00_ctl09_ctl08_MyText').val()+'</textarea>');
    }
}
