//ToggleDiv  v 1.7  11/2/11
//Toggle script to slide in/out objects expecially for Mark Dworkin
//This script is specific for http//markdworkin.com/video-store
//Same function but allows for many for containers to be toggled, dependent on the name of the toggle link
//John Mulligan     orig. date July 2011

 
 
 // When the DOM is ready, initialize the scripts.

  
$(document).ready(function() {

//Add hover styling to list items in video store

$(".hoverMe").hover(
function() {
$(this).addClass("overStyle");

},  
function() {
$(this).removeClass("overStyle");
});
 

 
 
 
// Get a reference to the container.
/*
12/2/2011
After seeing how choppy this application has gotten 
as the number of containers
increased overtime, I figured it may be better to:
#1)check each container's visibilty rather than automatically having 
jquery close it nomatter what
#2)have all the containers be contained in one array to make it possible
to loop through each container to check the current visibility of each


--Ok It was sucessful in that it works, but it didnt clean up the choppyness
as much as I hoped.. It is a ton of videos and paypal buttons being moved so 
maybe its just too heavy to be perfectly smooth
*/
container = new Array();
container[1] = $( "#container1" );
container[2] = $( "#container2" );
container[3] = $( "#container3" );
container[4] = $( "#container4" );
container[5] = $( "#container5" );
container[6] = $( "#container6" );
container[7] = $( "#container7" );
container[8] = $( "#container8" );
container[9] = $( "#container9" );
container[10] = $( "#container10" );
container[11] = $( "#container11" );
container[12] = $( "#container12" );
container[13] = $( "#container13" );
container[14] = $( "#container14" );
container[15] = $( "#container15" );
container[16] = $( "#container16" );
//container[17] = $( "#container17" );
//container[18] = $( "#container18" );
//container[19] = $( "#container19" );
//container[20] = $( "#container20" );

 

// Bind the link to toggle the slide. 
$( '.toggle' ).click(
function( event ){
event.preventDefault();  // Prevent the default event


var choice = $(this).text();

if (choice=="The Fight Against Bullying")
{

if (container[1].is(":visible"))
 {
 container[1].slideUp(1000);
 }

 else
 {
container[1].slideDown( 1000 );
// create a loop to check each container
for(var i=1;i<=15;i++)
{
if(i==1)//skip checking this container
{continue;
}
else if(container[i].is(":visible"))
{
container[i].slideUp( 1000 );
}


}
}
}//end if CHOICE

if (choice=="What Makes a Bully?")
{

if (container[2].is(":visible"))
 {
 container[2].slideUp(1000);
 }

 else
 {
container[2].slideDown( 1000 );
// create a loop to check each container
for(var i=1;i<=15;i++)
{
if(i==2)//skip checking this container
{continue;
}
else if(container[i].is(":visible"))
{
container[i].slideUp( 1000 );
}


}
}

}// end if CHOICE

if (choice=="Domestic Violence")
{
if (container[3].is(":visible"))
 {
 container[3].slideUp(1000);
 }

 else
 {
container[3].slideDown( 1000 );
// create a loop to check each container
for(var i=1;i<=15;i++)
{
if(i==3)//skip checking this container
{continue;
}
else if(container[i].is(":visible"))
{
container[i].slideUp( 1000 );
}

}//end FOR LOOP
}//end ELSE
}//end if CHOICE

if (choice=="Compulsive Exercise Disorder")
{
if (container[4].is(":visible"))
 {
 container[4].slideUp(1000);
 }

 else
 {
container[4].slideDown( 1000 );
// create a loop to check each container
for(var i=1;i<=15;i++)
{
if(i==4)//skip checking this container
{continue;
}
else if(container[i].is(":visible"))
{
container[i].slideUp( 1000 );
}

}//end FOR LOOP
}//end ELSE
}//end if CHOICE

if (choice=="Overcoming Bulimia")
{
if (container[5].is(":visible"))
 {
 container[5].slideUp(1000);
 }

else
 {
container[5].slideDown( 1000 );
// create a loop to check each container
for(var i=1;i<=15;i++)
{
if(i==5)//skip checking this container
{
continue;
}
else if(container[i].is(":visible"))
{
container[i].slideUp( 1000 );
}

}//end FOR LOOP
}//end ELSE
}//end if CHOICE

if (choice=="Overcoming Anorexia")
{
if (container[6].is(":visible"))
 {
 container[6].slideUp(1000);
 }

else
 {
container[6].slideDown( 1000 );
// create a loop to check each container
for(var i=1;i<=15;i++)
{
if(i==6)//skip checking this container
{
continue;
}
else if(container[i].is(":visible"))
{
container[i].slideUp( 1000 );
}

}//end FOR LOOP
}//end ELSE
}//end if CHOICE

if (choice=="Stop Binge Eating")
{
if (container[7].is(":visible"))
 {
 container[7].slideUp(1000);
 }

else
 {
container[7].slideDown( 1000 );
// create a loop to check each container
for(var i=1;i<=15;i++)
{
if(i==7)//skip checking this container
{
continue;
}
else if(container[i].is(":visible"))
{
container[i].slideUp( 1000 );
}

}//end FOR LOOP
}//end ELSE
}//end if CHOICE

if (choice=="Cyber Bullying")
{
if (container[8].is(":visible"))
 {
 container[8].slideUp(1000);
 }

else
 {
container[8].slideDown( 1000 );
// create a loop to check each container
for(var i=1;i<=15;i++)
{
if(i==8)//skip checking this container
{
continue;
}
else if(container[i].is(":visible"))
{
container[i].slideUp( 1000 );
}

}//end FOR LOOP
}//end ELSE
}//end if CHOICE

if (choice=="Being the Parent of a Gay Teen")
{
if (container[9].is(":visible"))
 {
 container[9].slideUp(1000);
 }

else
 {
container[9].slideDown( 1000 );
// create a loop to check each container
for(var i=1;i<=15;i++)
{
if(i==9)//skip checking this container
{
continue;
}
else if(container[i].is(":visible"))
{
container[i].slideUp( 1000 );
}

}//end FOR LOOP
}//end ELSE
}//end if CHOICE

if (choice=="Give Your Child Self Esteem")
{
if (container[10].is(":visible"))
 {
 container[10].slideUp(1000);
 }

else
 {
container[10].slideDown( 1000 );
// create a loop to check each container
for(var i=1;i<=15;i++)
{
if(i==10)//skip checking this container
{
continue;
}
else if(container[i].is(":visible"))
{
container[i].slideUp( 1000 );
}

}//end FOR LOOP
}//end ELSE
}//end if CHOICE

if (choice=="Recovering From Emotional and Physical Abuse")
{
if (container[11].is(":visible"))
 {
 container[11].slideUp(1000);
 }

else
 {
container[11].slideDown( 1000 );
// create a loop to check each container
for(var i=1;i<=15;i++)
{
if(i==11)//skip checking this container
{
continue;
}
else if(container[i].is(":visible"))
{
container[i].slideUp( 1000 );
}

}//end FOR LOOP
}//end ELSE
}//end if CHOICE


if (choice=="Dissociation")
{
if (container[12].is(":visible"))
 {
 container[12].slideUp(1000);
 }

else
 {
container[12].slideDown( 1000 );
// create a loop to check each container
for(var i=1;i<=15;i++)
{
if(i==12)//skip checking this container
{
continue;
}
else if(container[i].is(":visible"))
{
container[i].slideUp( 1000 );
}

}//end FOR LOOP
}//end ELSE
}//end if CHOICE

if (choice=="Parental Alienation Syndrome")
{
if (container[13].is(":visible"))
 {
 container[13].slideUp(1000);
 }

else
 {
container[13].slideDown( 1000 );
// create a loop to check each container
for(var i=1;i<=15;i++)
{
if(i==13)//skip checking this container
{
continue;
}
else if(container[i].is(":visible"))
{
container[i].slideUp( 1000 );
}

}//end FOR LOOP
}//end ELSE
}//end if CHOICE

if (choice=="Cell Phone Addiction")
{
if (container[14].is(":visible"))
 {
 container[14].slideUp(1000);
 }

else
 {
container[14].slideDown( 1000 );
// create a loop to check each container
for(var i=1;i<=15;i++)
{
if(i==14)//skip checking this container
{
continue;
}
else if(container[i].is(":visible"))
{
container[i].slideUp( 1000 );
}

}//end FOR LOOP
}//end ELSE
}//end if CHOICE

if (choice=="Recovering From Sexual Abuse")
{
if (container[15].is(":visible"))
 {
 container[15].slideUp(1000);
 }

else
 {
container[15].slideDown( 1000 );
// create a loop to check each container
for(var i=1;i<=15;i++)
{
if(i==15)//skip checking this container
{
continue;
}
else if(container[i].is(":visible"))
{
container[i].slideUp( 1000 );
}

}//end FOR LOOP
}//end ELSE
}//end if CHOICE


if (choice=="Separation Anxiety")
{
if (container[16].is(":visible"))
 {
 container[16].slideUp(1000);
 }

else
 {
container[16].slideDown( 1000 );
// create a loop to check each container
for(var i=1;i<=16;i++)
{
if(i==16)//skip checking this container
{
continue;
}
else if(container[i].is(":visible"))
{
container[i].slideUp( 1000 );
}

}//end FOR LOOP
}//end ELSE
}//end if CHOICE

/*
// Toggle the slide based on its current visibility.
if (container1.is( ":visible" )){ 
// Hide - slide up.
container1.slideUp( 1000 );

} else {
 

// Show - slide down.
container1.slideDown( 1000 );
 }
 
 */
}




 

)}); //end DOM ready functions


