// JavaScript Document
function StrikeTxt(id){
var textToStrike = document.getElementById(id).innerHTML;
//alert(textToStrike);
      document.getElementById(id).innerHTML = textToStrike.strike(); 
      return true;
}
function clearField(name){
	var str =document.getElementById(name).value;
	//alert(str.substr(1,13));
		if(str.substr(0,13) == "Provider Name" || str.substr(0,10) == "Movie Link"){
				document.getElementById(name).value="";
		}
	}
function formSubmit_movie_details(id){
	//document.getLinksForm.submit();
	document.location.href="admin.php?page=add-movie-details&id="+id;
}
function formSubmit_edit_links(id){
//	alert("arunasdsdsad");
document.location.href="admin.php?page=edit-movie-links&id="+id;
}
function wp_user_movie_links_toggle(form_name, postID)
	{
		jQuery(form_name).slideToggle(400);
		return false;
	}
	function wp_user_movie_links_report(form)
	{
		// get POST DATA
		var post_ID=form.post.value;
		//alert(post_ID);
		var providername=form.providername.value;
		var name1=form.name1.value;
		var name2=form.name2.value;
		var name3=form.name3.value;
		var name4=form.name4.value;
		var name5=form.name5.value;
		var name6=form.name6.value;
		// Hide All Other than Message
		jQuery('#wp_user_movie_links_'+post_ID).hide();
		jQuery('#wp_user_movie_linksForm'+post_ID).hide();
		jQuery('#wp_user_movie_links_message_'+post_ID).fadeIn(100);
		//alert(<?php echo path_join(WP_PLUGIN_URL, basename( dirname( __FILE__ ) ).'/wp-movie-links-Post.php'); ?>);
		// Send Ajax
		var hn = window.location.hostname;
		
		if(hn=="localhost" || hn=="192.168.1.42"){
		hn = hn+"/mybestmoviesonline";
		}
		var url1="http://"+hn+"/wp-content/plugins/movie-management/wp-movie-links-Post.php";
		//alert(url1);
		jQuery.post(url1, { postID: post_ID, providername:providername, name1: name1,name2: name2,name3: name3,name4: name4,name5: name5,name6: name6, do_ajax_report:"true" },
		  function(data){
			// Display the Return
			jQuery('#wp_user_movie_links_message_'+post_ID).html(data);
			form.name1.value="";
			form.name2.value="";
			form.name3.value="";
			form.name4.value="";
			form.name5.value="";
			form.name6.value="";
			form.providername.value="";
			jQuery('#wp_user_movie_links_'+post_ID).show();
			//jQuery('#wp_user_movie_linksForm'+post_ID).hide();
		  });
		
		return false;
	}
	function GetXmlHttpObject()
	{
	var xmlHttp=null;
	try
	  {
	  // Firefox, Opera 8.0+, Safari
	  xmlHttp=new XMLHttpRequest();
	  }
	catch (e)
	  {
	  // Internet Explorer
	  try
		{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	  catch (e)
		{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	  }
	return xmlHttp;
	}
	var xmlHttp;
	function reportLink(lid,mid){
		xmlHttp=GetXmlHttpObject();
		var hn = window.location.hostname;
		
		if(hn=="localhost" || hn=="192.168.1.42"){
		hn = hn+"/mybestmoviesonline";
		}
		//alert(hn);
		document.getElementById(lid).innerHTML='<img src="http://'+hn+'/wp-content/plugins/movie-management/loading.gif" alt="loading" />';
		var url="http://"+hn+"/wp-content/plugins/movie-management/report_links.php";
		var parameters = "lid="+lid+"&mid="+mid;
		xmlHttp.onreadystatechange = function(){
			if (xmlHttp.readyState==4)
			{ 
			//document.getElementById('msg').innerHTML=xmlHttp.responseText;
			//setTimeout ("callback()",1500);
			//alert(xmlHttp.responseText);
				if(xmlHttp.responseText=="Login before reporting..."){
					document.getElementById(lid).innerHTML="<font color='red'>"+xmlHttp.responseText+"</font>";
				}else{
					document.getElementById(lid).innerHTML="<font color='green'>"+xmlHttp.responseText+"</font>";
				}
			}
		}
		xmlHttp.open('POST', url, true);
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", parameters.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.send(parameters);
		//alert(lid+" , "+mid);
	}
	
	function RemoveFromArrangeTool(mid){
		if(confirm("Are you sure you want to Remove this movie from the List?")){
		xmlHttp=GetXmlHttpObject();
		var hn = window.location.hostname;
		
		if(hn=="localhost" || hn=="192.168.1.42"){
		hn = hn+"/mybestmoviesonline";
		}
		var url="http://"+hn+"/wp-content/plugins/movie-management/delete_arrange_tool.php";
		//alert(url);
		var parameters = "mid="+mid;
		xmlHttp.onreadystatechange = function(){
			if (xmlHttp.readyState==4)
			{ 
			//document.getElementById('msg').innerHTML=xmlHttp.responseText;
			//setTimeout ("callback()",1500);
			//alert(xmlHttp.responseText);
				if(xmlHttp.responseText=="success"){
					
					location.href="admin.php?page=add-imdb-top250";
					//saveArrangableNodes();
				}
			}
		}
		xmlHttp.open('POST', url, true);
		xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlHttp.setRequestHeader("Content-length", parameters.length);
		xmlHttp.setRequestHeader("Connection", "close");
		xmlHttp.send(parameters);
		}
	}
	
	