/**

@author : Harish Kumar
@date : 6/12/2006

*/
var lastPage;

/*function addPolicy()
{
	obj = document.getElementById("addNew");
	
	html = '<form method="POST" action="" onsubmit="return savePolicy(this)">';
	html+='<table width="100%"  border="0" cellspacing="0" cellpadding="0">';
	html+="<tr><td width='39%'><input name='title' class='input-box' value='Policy Title...' style='width:650px'></strong></td>";
	html+='<td width="61%"></td>';
	html+='</tr><tr><td colspan="2"><textarea name="desc" class="input-box" style="width:650px;height:50px;">Policy description...</textarea>';
	html+="</td></tr><tr><Td><input type='submit' name='save' class='button' value='Save'></td></tr>"; 
	html+="<tr><Td>&nbsp;</td></tr></table></form>"; 

	obj.innerHTML+=html;
}*/

function addPolicy(policy_id)
{
	var win = window.open("admin/addpolicy.php?policy_id",'_self','toolbar=0,status=0,height=500,width=750,resizable=1');
	win.focus();
}

function editPolicy(policy_id)
{
	var win = window.open("admin/addpolicy.php?policy_id="+policy_id,'_self','toolbar=0,status=0,height=500,width=750,resizable=1');
	win.focus();
}


function savePolicy(theForm)
{
	theForm.title.disabled = true;
	theForm.desc.disabled = true;
	theForm.save.value = "Saving...";
	theForm.save.disabled = true;
	
	postvar = new Array('title','desc');
	postvalue = new Array(theForm.title.value,theForm.desc.value);

	sndReq("admin/addpolicy.php",postvar,postvalue,theForm,"handleResponse");

	return false;
}

function showPolicy(theForm)
{
	obj = document.getElementById("showNew");
	
	html = '<form method="POST" action="" onsubmit="return savePolicy(this)">';
	html+='<table width="100%"  border="0" cellspacing="0" cellpadding="0">';
	html+="<tr><td width='39%'><input name='title' class='input-box' value='Policy Title...' style='width:650px'></strong></td>";
	html+='<td width="61%"></td>';
	html+='</tr><tr><td colspan="2"><textarea name="desc" class="input-box" style="width:650px;height:50px;">Policy description...</textarea>';
	html+="</td></tr><tr><Td><input type='submit' name='save' class='button' value='Save'></td></tr>"; 
	html+="<tr><Td>&nbsp;</td></tr></table></form>"; 

	obj.innerHTML+=html;
}

function addChamp(policy_id)
{
	var win = window.open("admin/add_policy_champ.php?policy_id="+policy_id,'_self','toolbar=0,status=0,height=600,width=750,resizable=1');
	win.focus();
}

function addAffil(policy_id)
{
	var win = window.open("admin/add_policy_affil.php?policy_id="+policy_id,'_self','toolbar=0,status=0,height=600,width=750,resizable=1');
	win.focus();
}

function addBook(policy_id,type)
{
	var win = window.open("admin/add_book.php?policy_id="+policy_id+"&book_type="+type,'newwin','toolbar=0,status=0,height=600,width=750,resizable=1');
	win.focus();
}

function editBook(policy_id,book_id)
{
	var win = window.open("admin/add_book.php?policy_id="+policy_id+"&book_id="+book_id,'newwin','toolbar=0,status=0,height=600,width=750,resizable=1');
	win.focus();
}

function sortList(field)
{
	var str = "http://192.168.0.105/test/test/vp/policy_homepage.php?policy=2&section=2&field=adaf";
	result  = location.href.replace(/&field=.*/,'');

	location.href=result+"&field="+field;
}

function changePwd()
{
	var win = window.open("admin/change_pwd.php",'_self','toolbar=0,status=0,height=600,width=750,resizable=1');
	win.focus();
}

function editChamp(policy_id,cmp_id)
{
	var win = window.open("admin/add_policy_champ.php?policy_id="+policy_id+"&cmp_id="+cmp_id,'_self','toolbar=0,status=0,height=600,width=750,resizable=1');
	win.focus();
}

function editAffil(policy_id,affil_id)
{
	var win = window.open("admin/add_policy_affil.php?policy_id="+policy_id+"&affil_id="+affil_id,'_self','toolbar=0,status=0,height=600,width=750,resizable=1');
	win.focus();
}
