// JavaScript Document

function makeConfirm(page,postid)
{
	var ans = confirm('Are you sure want to delete this post ?');
	if(ans)
	{
		window.location = 'deletepost.php?page='+page+'&postid='+postid;
	}
}

function deletePage(page,pageid)
{
	var ans = confirm('Are you sure want to delete this page ?');
	if(ans)
	{
		window.location = 'deletepage.php?page='+page+'&pageid='+pageid;
	}	
}
function redirect(page)
{

	window.location = 'home.php?page='+page;
}
function redirectTab(tab)
{

	window.location = 'home.php?tab='+tab;
}

function makeArchive(page,pageid)
{
	var ans = confirm('Are you sure want to move this page to Archive?');
	if(ans)
	{
		window.location = 'makeArchive.php?page='+page+'&pageid='+pageid;
	}
}
function popitup(url)
{
		newwindow=window.open(url,'Download File','height=400,width=500');
	if (window.focus) {newwindow.focus()}
	return false;

}
function deleteDownload(downid,action)
{
	var ans = confirm('Are you sure want to delete this ?');
	if(ans)
	{
		window.location = 'deleteDownload.php?downid='+downid;
	}	
}
function manageUser(userid,op)
{
		if(op == 1)
		{
			var ans = confirm('Are you sure want to block/unblock this subscriber?');
			if(ans)
			{
				window.location = 'manageUser.php?userid='+userid+'&op=1';
			}			
		}
		/*if(op == 2)
		{
			var ans = confirm('Are you sure want to make this subscriber as user?');
			if(ans)
			{
				window.location = 'manageUser.php?userid='+userid+'&op=2';
			}			
		}*/
		if(op == 4)
		{
			var ans = confirm('Are you sure want to delete this subscriber?');
			if(ans)
			{
				window.location = 'manageUser.php?userid='+userid+'&op=4';
			}			
		}
}

function ValidatePassword()
{
	  
	  var op = document.getElementById('txtOPassword').value;
	  var np = document.getElementById('txtNPassword').value;
	  var rp = document.getElementById('txtRPassword').value;
	  
	  if(op =="" || np == "" || rp =="")
	  {
		  	alert('All fields are required....!');
			return false;
	  }
	  if(np != rp)
	  {
		  alert("Retype Password doesn't match....!");
		  return false;
	  }
	  return true;
	  
		
}

function ValidateSubscriber()
{
	  
	  var user = document.getElementById('txtUsername').value;
	  var pwd = document.getElementById('txtPassword').value;
	  var email = document.getElementById('txtEmail').value;
	  var fname = document.getElementById('txtFname').value;
	  var lname = document.getElementById('txtLname').value;
	  var city = document.getElementById('txtCity').value;
	  var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
	  
	  if(user =="" || pwd == "" || email =="" || fname == "" || lname =="" || city =="")
	  {
		  	alert('Fields with * are required....!');
			return false;
  	  }
	  
	  if(reg.test(email) == false) 
	  {
			alert('Invalid Email Address');
			return false;
	  }
  
	  
	  return true;
	  
		
}

function ValidateHomePage()
{
	  
	  var title = document.getElementById('txtTitle').value;
	  var sd = document.getElementById('FCKeditor1').value;
	  
	  if(title =="" || sd == "")
	  {
		  	alert('Title and Short Description are fields required....!');
			return false;
	  }
	  
	  return true;
	  
		
}

function ValidatePages()
{
	  
	  var title = document.getElementById('txtTitle').value;
	  var fd = document.getElementById('FCKeditor2').value;
	  
	  if(title =="" || fd == "")
	  {
		  	alert('Title and Full Description are fields required....!');
			return false;
	  }
	  
	  return true;
}

function ValidateDownloadZone()
{
	  
	  var cat = document.getElementById('txtCategory').value;
	  var scat = document.getElementById('txtSubCategory').value;
	  var title = document.getElementById('txtTitle').value;
	  var browse = document.getElementById('fbrowse').value;
	  
	  if(cat =="" || scat == "" || title =="" || browse =="")
	  {
		  	alert('All fields are required....!');
			return false;
	  }
	  return true;
	  
		
}

function setFocus(control)
{	
		document.getElementById(control).focus();
}

function manageComment(id,action)
{
	if(action == 1)
	{
		var ans = confirm('Are you sure want to activate/block this comment?');
		if(ans)
		{
			window.location = 'manageComment.php?id='+id+'&op=1';
		}		
	}
	
	if(action == 4)
	{
		var ans = confirm('Are you sure want to delete this comment?');
		if(ans)
		{
			window.location = 'manageComment.php?id='+id+'&op=4';
		}		
	}
	
}
/*For The Pages of Funds*/
function redirectForFund(optype,fundidp)
{
	/*
		opttype=which type of operation insert new fund detail or update existing fund detail
		fundidp=Primary key , it is set when fund is to be updated, if new then set it to 0 or less than 0
	*/
	var o=optype;
	var f=fundidp;
	var felement=document.getElementById('fndtype');
	var ftype=felement[felement.selectedIndex].value;
		if(o=="d")
		{
			var confirmdel = confirm('Are you sure want to delete this ?');
			if(confirmdel)
			{
				window.location="deleteFund.php?op="+o+"&fid="+f;
			}
		}
		else
		{
			var str="home.php?page=203&op="+ o +"&fid="+f+"&fundtype="+ftype;
//		alert(str);
			window.location=str;
		}
}
function redirectManageFundDetails(fundtyp)
{
	var f=fundtyp;
	var str='home.php?page=203&fundtype='  + f;//+funtyp;
	window.location=str;//"home.php?page=203&fundtype="+f;
}
function gotohome()
{
	window.location="home.php";
}
function gotomanagefund(fundtype)
{
	f=fundtype;
	window.location="home.php?page=203&fundtype="+f;
}
function redirectforQuickMenu(optype,id)
{
	var op=optype;
	var qckmnuid=id;
		if(op=="d")
		{
			var confirmdel = confirm('Are you sure want to delete this ?');
			if(confirmdel)
			{
				window.location="deleteQckMnuLnk.php?op="+op+"&qckmnuid="+qckmnuid;
			}
		}
		else
		{
			window.location="home.php?page=204&op="+op+"&qckmnuid="+qckmnuid;
		}	
}
function SetTitle(menuvalue)
{
	var	m=menuvalue;
	if(m!=undefined)
	{
		document.getElementById('txttitle').value=m;
	}	
	else
	{
			document.getElementById('txttitle').value="";
	}
}
function CheckMenu()
{
	if(document.getElementById('txtmenuname').value=="")
	{
		alert("Menu Name is Empty");
		return false;
	}
	return true;
}
function redirecttoRegister(acttype)
{
	var a=acttype;
	
	if(a=="n")
	{
		window.location="createaccount.php?act="+a;		
	}
}

function redirectForLogin()
{
	var txtusername=document.getElementById('txtUserName').value;
	var txtpassword=document.getElementById('txtPassword').value;
		if(txtusername=="" || txtpassword=="")
		{
			alert("Please Fill The Details!!!");			
		}
		else
		{
		    document.forms["frmUserLogin"].submit();		
		}
}
function openFormForLogin(act)
{
	var dvLogin=document.getElementById('dvLogin');
	//alert(dvLogin.id);
	//alert(dvLogin.style.display);
	if(act==1)
	{
		if(dvLogin.style.display=='none')
		{
			dvLogin.style.display='block';
		}
		else
		{
			dvLogin.style.display='none';		
		}
	}
	else if(act==0)
	{
		dvLogin.style.display='none';
	}
	
}

function redirectForIndex()
{
	window.location="index.php";
}
function redirectToPage()
{
//	alert("hello");
	window.location="ServicesPlatform.php";
}


