var SITE_URL = 'http://www.famouswhy.com/';



function famous_lists_vote(id,status,section) {

  new Ajax.Request(SITE_URL + 'ddd/' + 'famous_lists_vote.php',

		{

		 method:'post',

		 parameters: {id: id, action: status},

		 onSuccess: function(transport){

		  var response = transport.responseText;

			

			if ( response != "" ) {

				$('' + section + '_votes_' + id + '').update(response);

			}

		 },

		 onFailure: function(){ alert('Error retriving list points.') }

		});

}



function displayMoviesSection(section){



	var arrayTabs = new Array(5);



	arrayTabs[0] = 'directors_section';

	arrayTabs[1] = 'writers_section';

	arrayTabs[2] = 'cast_section';

	arrayTabs[3] = 'relatedMovies_section';

	arrayTabs[4] = 'relatedLinks_section';



  var arrayButtons = new Array(5);



  arrayButtons[0] = 'directors';

	arrayButtons[1] = 'writers';

	arrayButtons[2] = 'cast';

	arrayButtons[3] = 'movies';

	arrayButtons[4] = 'links';



for ( var i = 0; i <= 4 ; i++) {

    if(arrayTabs[i] == section) {

      $(arrayTabs[i]).style.display = 'block';

      $(arrayButtons[i]).className = 'Highlight';

      $(arrayButtons[i]).removeAttribute('onmouseover');

      $(arrayButtons[i]).removeAttribute('onmouseout');

    } else {

      $(arrayTabs[i]).style.display = 'none';

      $(arrayButtons[i]).className = 'Normal';

      $(arrayButtons[i]).setAttribute('onmouseover', 'this.className="Highlight"');

			$(arrayButtons[i]).setAttribute('onmouseout', 'this.className="Normal"');

    }

	}

}



function reportBrokenVideo(targetMovieCode,movieId) { //create cookie and check if cookie exists , only allow one bad report per cooie, per name, per year, per superman, per batman, per captain planet

  new Ajax.Request(SITE_URL + 'ddd/' + 'reportBrokenVideo.php',

		{

		 method:'post',

		 parameters: {targetMovieCode:targetMovieCode, movieId:movieId},

		 onSuccess: function(transport){

		  var response = transport.responseText || "no response text";

      alert(response);

		 },

		 onFailure: function(){ alert('Something went wrong...') }

		});

}



function birthLocations(category) {

	if(category == 'city') {

		$('city').className = "class_font born_link_right_selected";

		$('country').className = "";

		$('state').className = "";

		$('locationContent').style.display = "block";

		$('stateContent').style.display = "none";

		$('countryContent').style.display = "none";

	} else if (category == 'country') {

		$('city').className = "";

		$('country').className = "class_font born_link_right_selected";

		$('state').className = "";

		$('locationContent').style.display = "none";

		$('stateContent').style.display = "none";

		$('countryContent').style.display = "block";

	} else if (category == 'state') {

		$('city').className = "";

		$('country').className = "";

		$('state').className = "class_font born_link_right_selected";

		$('locationContent').style.display = "none";

		$('stateContent').style.display = "block";

		$('countryContent').style.display = "none";

	}

}



function changeMovie(targetMovieCode) {



  $('videoCode').value = targetMovieCode;



  new Ajax.Request(SITE_URL + 'ddd/' + 'changeMovie.php',

		{

		 method:'post',

		 parameters: {targetMovieCode: targetMovieCode},

		 onSuccess: function(transport){

		  var response = transport.responseText || "no response text";



			$('videoPlayer').update(response);

		   },

		 onFailure: function(){ alert('Something went wrong...') }

		});

	}



function yearJumper(year) {

	if (isNaN(year)) {

		$('jump_messages').update("<span style='color: red'>Wrong year format</span>");

	} else {

		new Ajax.Request(SITE_URL + 'ddd/' + 'checkYearExistentz.php',

		{

		 method:'post',

		 parameters: {year: year},

		 onSuccess: function(transport){

		  	 var response = transport.responseText;

				 if (response == 'ok') {

					window.location= SITE_URL + "Born_Today/Year/" + year + ".html";

				 } else {

				 	$('jump_messages').update("<span style='color: red'>Year is not in our database</span>");

				}

		   },

		 onFailure: function(){ alert('Something went wrong...') }

		});

	}

}


function yearJumper2(year) {

	if (isNaN(year)) {

		$('jump_messages').update("<span style='color: red'>Wrong year format</span>");

	} else {

	new Ajax.Request(SITE_URL + 'ddd/' + 'checkYearExistentz.php?tip=couples',

		{

		 method:'post',

		 parameters: {year: year},

		 onSuccess: function(transport){

		  	 var response = transport.responseText;

				 if (response == 'ok') {

					window.location= SITE_URL + "couples/" + year + "/";

				 } else {

				 	$('jump_messages').update("<span style='color: red'>Year is not in our database</span>");

				}

		   },

		 onFailure: function(){ alert('Something went wrong...') }

		});

	}

}



function switchSchoolType(type) {



	if(type == 'highschools') {

		$('highschool').className = 'link_blue_high_school_selected';

		$('university').className = '';

		$('latest_highschool').style.display = 'block';

		$('latest_university').style.display = 'none';

	} else if (type == 'university'){

		$('university').className = 'link_blue_high_school_selected';

		$('highschool').className = '';

		$('latest_highschool').style.display = 'none';

		$('latest_university').style.display = 'block';

	}

}



function pressButton(button) { //menul selected buttons

	var array = new Array();

	array[0] = 'bt';

	array[1] = 'bw';

	array[2] = 'fs';

	array[3] = 'm';

	array[4] = 'fl';

	array[5] = 's';

	array[6] = 'bo';

	array[7] = 'z';

	array[8] = 'sb';
	
	array[9] = 'couple';



	for ( var i in array ) {

	    if(array[i] == button) {

				$(array[i]).className = "class_another_font menu_selected";

			} else {

				$(array[i]).className = "";

			}

	}

}



function toogleGoogleCheck( checkboxId ){

	var imgFalse = SITE_URL + 'ddd/images/checkbox.jpg';

	var imgTrue = SITE_URL + 'ddd/images/checkbox_selected.jpg';



	var checkboxs = new Array(2);

	checkboxs[0] = "checkbox11";

	checkboxs[1] = "checkbox22";



	if ( checkboxId != "" ) {

		for ( i = 0; i < checkboxs.length; i++ ) {

			if ( checkboxs[i] != checkboxId ) {

				$(checkboxs[i]).src = imgFalse;

			}

		}



		if ( $(checkboxId).src == imgTrue ) {

			$(checkboxId).src = imgFalse;

			$('checkbox_value_2').value = 'Highschool';

			$('checkbox11').src = imgTrue;

		} else {

			$(checkboxId).src = imgTrue;

			$('checkbox_value_2').value = 'University';

		}

	}

}



function site_blogs_vote(id,status) {

  new Ajax.Request(SITE_URL + 'ddd/' + 'site_blogs_vote.php',

		{

		 method:'post',

		 parameters: {id: id, status: status},

		 onSuccess: function(transport){

		   var response = transport.responseText || "no response text";

		 	 $('points').update(response); 

		 },

		 onFailure: function(){ alert('Something went wrong...') }

		});

}



function bestOf(tab) {

  

  var array = new Array(8);

	array[0] = 'famous_people';

	array[1] = 'movies';

	array[2] = 'software';

	array[3] = 'music';

	array[4] = 'highschools';

	array[5] = 'universities';

	array[6] = 'regions';

	array[7] = 'site_blogs';



  for ( var i = 0; i <= 7 ; i++) {

    if(array[i] == tab) {

      $(array[i]).style.display = 'block';

      $(array[i] + '_link' + '').className = 'class_font best_of_link_left_selected';

       $(array[i] + '_link' + '').removeAttribute('onmouseover');

       $(array[i] + '_link' + '').removeAttribute('onmouseout');

    } else {

      $(array[i]).style.display = 'none';

      $(array[i] + '_link' + '').className = 'class_font best_of_link_left';

      $(array[i] + '_link' + '').setAttribute('onmouseover', 'this.className="class_font best_of_link_left_selected"');

			$(array[i] + '_link' + '').setAttribute('onmouseout', 'this.className="class_font best_of_link_left"');

    }

	}

}



function bringToFrontShockTypes(divId) {

  if(divId == "recent") {

    $('recent').style.display = "block";

    $('weak').style.display = "none";



    $('recentLink').className = "class_font shock_tab_selected";

    $('weakLink').className = "class_font shock_tab";

  } else {

    $('recent').style.display = "none";

    $('weak').style.display = "block";



    $('recentLink').className = "class_font shock_tab";

    $('weakLink').className = "class_font shock_tab_selected";

  }

}



function alterShockVote(shockId,action,section) {

  new Ajax.Request(SITE_URL + 'ddd/' + 'alterShockVotes.php',

		{

		 method:'post',

		 parameters: {action: action, shockId: shockId},

		 onSuccess: function(transport){

		   var response = transport.responseText || "no response text";

       $('' + section + '_votes_' + shockId + '').update(response);

		   },

		 onFailure: function(){ alert('Something went wrong...') }

		});

}



function changeWeekDay(day){

  var array = new Array(7);



	array[0] = 'Monday';

	array[1] = 'Tuesday';

	array[2] = 'Wednesday';

	array[3] = 'Thursday';

	array[4] = 'Friday';

	array[5] = 'Saturday';

	array[6] = 'Sunday';



  for ( var i = 0; i <= 6 ; i++) {

    if(array[i] == day) {

      window.location = SITE_URL + "Shocks.html#" + day;

      $(array[i]).className = 'class_font shock_link_up_selected';

       

      new Ajax.Request(SITE_URL + 'ddd/' + 'getShocksForDay.php',

        {

         method:'post',

         parameters: {day: day},

         onSuccess: function(transport){

           var response = transport.responseText;

           $('daySwitch').update(response);

           },

         onFailure: function(){ alert('Something went wrong...') }

        });

    } else {

       $(array[i]).className = '';

    }

	}

}



function searchCelebSign(){

	var celebName = $('search_name').value;

	

  if( celebName != "" ) {

    new Ajax.Request(SITE_URL + 'ddd/' + 'getCelebSign.php',

      {

       method:'post',

       parameters: {celebName: celebName},

       onSuccess: function(transport){

       	var response = transport.responseText;

				if ( response != "" ) {

					$('search_div').style.display = 'block';

	      	$('search_content_div').update(response);

				}

       },

       onFailure: function(){ alert('Something went wrong...') }

      });

  }

}



function switchMovieCateg(category) {

	if(category == 'movies_related') {

		$('movies_related').className = "class_font movie_link_right_selected";

		$('movies_popular').className = "";

		$('movies_boxoffice').className = "";

		$('__movies_related').style.display = "block";

		$('__movies_popular').style.display = "none";

		$('__movies_boxoffice').style.display = "none";

	} else if (category == 'movies_popular') {

		$('movies_related').className = "";

		$('movies_popular').className = "class_font movie_link_right_selected";

		$('movies_boxoffice').className = "";

		$('__movies_related').style.display = "none";

		$('__movies_popular').style.display = "none";

		$('__movies_boxoffice').style.display = "block";

	} else if (category == 'movies_boxoffice') {

		$('movies_related').className = "";

		$('movies_popular').className = "";

		$('movies_boxoffice').className = "class_font movie_link_right_selected";

		$('__movies_related').style.display = "none";

		$('__movies_popular').style.display = "block";

		$('__movies_boxoffice').style.display = "none";

	}

}



function switchMoviePageCateg(category) {

	if(category == 'movie_page_reviews') {

		$('movie_page_reviews').className = "class_font movie_link_right_selected";

		$('movie_page_popular').className = "";

		$('movie_page_boxoffice').className = "";

		$('__movie_page_reviews').style.display = "block";

		$('__movie_page_popular').style.display = "none";

		$('__movie_page_boxoffice').style.display = "none";

	} else if (category == 'movie_page_popular') {

		$('movie_page_reviews').className = "";

		$('movie_page_popular').className = "class_font movie_link_right_selected";

		$('movie_page_boxoffice').className = "";

		$('__movie_page_reviews').style.display = "none";

		$('__movie_page_popular').style.display = "none";

		$('__movie_page_boxoffice').style.display = "block";

	} else if (category == 'movie_page_boxoffice') {

		$('movie_page_reviews').className = "";

		$('movie_page_popular').className = "";

		$('movie_page_boxoffice').className = "class_font movie_link_right_selected";

		$('__movie_page_reviews').style.display = "none";

		$('__movie_page_popular').style.display = "block";

		$('__movie_page_boxoffice').style.display = "none";

	}

}



function switchListCateg(category) {

	if(category == 'list_recent') {

		$('list_recent').className = "class_font link_recent_list_selected";

		$('list_popular').className = "class_font link_most_popular";

		$('list_commented').className = "class_font link_most_commented";

		$('__list_recent').style.display = "block";

		$('__list_popular').style.display = "none";

		$('__list_commented').style.display = "none";

	} else if (category == 'list_popular') {

		$('list_recent').className = "class_font link_recent_list";

		$('list_popular').className = "class_font link_most_popular_selected";

		$('list_commented').className = "class_font link_most_commented";

		$('__list_recent').style.display = "none";

		$('__list_popular').style.display = "none";

		$('__list_commented').style.display = "block";

	} else if (category == 'list_commented') {

		$('list_recent').className = "class_font link_recent_list";

		$('list_popular').className = "class_font link_most_popular";

		$('list_commented').className = "class_font link_most_commented_selected";

		$('__list_recent').style.display = "none";

		$('__list_popular').style.display = "block";

		$('__list_commented').style.display = "none";

	}

}



function switchListPageCateg(category) {

	if(category == 'list_page_related') {

		$('list_page_related').className = "list_page_link_related_selected";

		$('list_page_popular').className = "";

		$('list_page_newest').className = "";

		$('__list_page_related').style.display = "block";

		$('__list_page_popular').style.display = "none";

		$('__list_page_newest').style.display = "none";

	} else if (category == 'list_page_popular') {

		$('list_page_related').className = "";

		$('list_page_popular').className = "list_page_link_related_selected";

		$('list_page_newest').className = "";

		$('__list_page_related').style.display = "none";

		$('__list_page_popular').style.display = "none";

		$('__list_page_newest').style.display = "block";

	} else if (category == 'list_page_newest') {

		$('list_page_related').className = "";

		$('list_page_popular').className = "";

		$('list_page_newest').className = "list_page_link_related_selected";

		$('__list_page_related').style.display = "none";

		$('__list_page_popular').style.display = "block";

		$('__list_page_newest').style.display = "none";

	}

}



function switchSiteCateg(category) {

	if(category == 'site_related') {

		$('site_related').className = "class_font movie_link_right_selected";

		$('site_popular').className = "";

		$('site_newest').className = "";

		$('__site_related').style.display = "block";

		$('__site_popular').style.display = "none";

		$('__site_newest').style.display = "none";

	} else if (category == 'site_popular') {

		$('site_related').className = "";

		$('site_popular').className = "class_font movie_link_right_selected";

		$('site_newest').className = "";

		$('__site_related').style.display = "none";

		$('__site_popular').style.display = "none";

		$('__site_newest').style.display = "block";

	} else if (category == 'site_newest') {

		$('site_related').className = "";

		$('site_popular').className = "";

		$('site_newest').className = "class_font movie_link_right_selected";

		$('__site_related').style.display = "none";

		$('__site_popular').style.display = "block";

		$('__site_newest').style.display = "none";

	}

}



function switchSitesCateg(category) {

	if(category == 'sites_related') {

		$('sites_related').className = "class_font sites_blogs_link_recently_added_selected";

		$('sites_popular').className = "";

		$('sites_newest').className = "";

		$('__sites_related').style.display = "block";

		$('__sites_popular').style.display = "none";

		$('__sites_newest').style.display = "none";

	} else if (category == 'sites_popular') {

		$('sites_related').className = "";

		$('sites_popular').className = "class_font sites_blogs_link_recently_added_selected";

		$('sites_newest').className = "";

		$('__sites_related').style.display = "none";

		$('__sites_popular').style.display = "none";

		$('__sites_newest').style.display = "block";

	} else if (category == 'sites_newest') {

		$('sites_related').className = "";

		$('sites_popular').className = "";

		$('sites_newest').className = "class_font sites_blogs_link_recently_added_selected";

		$('__sites_related').style.display = "none";

		$('__sites_popular').style.display = "block";

		$('__sites_newest').style.display = "none";

	}

}



function getXMLHttp()
{
  var xmlHttp
  try { xmlHttp = new XMLHttpRequest(); }
  catch(e)
  {
    try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); }
    catch(e)
    {
      try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); }
      catch(e) { alert("Your browser does not support AJAX!"); return false; }
    }
  }
  return xmlHttp;
}

function vote(id,rate) {

var http = false;
if(navigator.appName == "Microsoft Internet Explorer") { http = new ActiveXObject("Microsoft.XMLHTTP"); } else { http = new XMLHttpRequest(); }

  http.open("GET", "/ddd/rating.php?id="+id+"&rate="+rate, true);
  http.onreadystatechange=function() { if(http.readyState == 4) { document.getElementById(rate).innerHTML = http.responseText;  } }
  http.send(null);
}

