function fnshift(src,des)
{
 $("#tblhdr_"+src).css("display","none");
 $("#divmainissues_"+src).css("display","none");
$("#divdbrd1_"+src).css("display","none");
$("#tblhdr_"+des).css("display","block");
$("#divdbrd1_"+des).css("display","block");
$("#divmainissues_"+des).css("display","block");

}
function fnshowissues(idval,typeval)
{
  $("#divissues_"+idval+"_"+typeval).css("display","block");	
}
function fnAddentry(idval,typeval,mrows,vid,mode)
{
	var tplname="/public/dashboard_integration/";
	
	var tttt="<table align='center' border=0><tr><td valign='middle'><BR><img src='/ps_sources/img/load.gif'></td><td ><BR><b>Loading Please Wait</b></td></tr><tr><td colspan=2><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR></td></tr></table>";	
	$("#divdbrd1_"+idval).html(tttt);
	if(mode=='add')
	{
		//alert("save functionality has to be done w.r.t type "+typeval+" dashboard "+idval);
		$.post(tplname,{PASS_FROM:'valid',psdbrdid:idval,typeid:typeval,UPID:vid,TOTROWS:mrows,ACT_MODE:'add'},
		function(data){
		$("#divdbrd1_"+idval).html(data);});
	}
	if(mode=='remove')
	{
		//alert("save functionality has to be done w.r.t type "+typeval+" dashboard "+idval);
		$.post(tplname,{PASS_FROM:'valid',psdbrdid:idval,typeid:typeval,UPID:vid,TOTROWS:mrows,ACT_MODE:'remove'},function(data){
		$("#divdbrd1_"+idval).html(data);});
	}
}
function fnAddPageentry(idval,typeval,mrows,vid,mode)
{
	var tplname="/public/dashboard_integration/";
	
	var tttt="<table align='center' border=0><tr><td valign='middle'><BR><img src='/ps_sources/img/load.gif'></td><td ><BR><b>Loading Please Wait</b></td></tr><tr><td colspan=2><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR></td></tr></table>";	
	$("#divdbrd1_"+idval).html(tttt);
	if(mode=='add')
	{
		//alert("save functionality has to be done w.r.t type "+typeval+" dashboard "+idval);
		$.post(tplname,{PASS_FROM:'validpage',psdbrdid:idval,typeid:typeval,UPID:vid,TOTROWS:mrows,ACT_MODE:'add'},
		function(data){
		$("#divdbrd1_"+idval).html(data);});
	}
	if(mode=='remove')
	{
		//alert("save functionality has to be done w.r.t type "+typeval+" dashboard "+idval);
		$.post(tplname,{PASS_FROM:'validpage',psdbrdid:idval,typeid:typeval,UPID:vid,TOTROWS:mrows,ACT_MODE:'remove'},function(data){
		$("#divdbrd1_"+idval).html(data);});
	}
}
function fnAddentryevent(idval,mrows,vid,mode)
{
	var tplname="/public/dashboard_integration/";
	
	var tttt="<table align='center' border=0><tr><td valign='middle'><BR><img src='/ps_sources/img/load.gif'></td><td ><BR><b>Loading Please Wait</b></td></tr><tr><td colspan=2><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR></td></tr></table>";	
	$("#divdbrd1_"+idval).html(tttt);
	if(mode=='add')
	{
		//alert("save functionality has to be done w.r.t type "+typeval+" dashboard "+idval);
		$.post(tplname,{PASS_FROM:'validevents',psdbrdid:idval,UPID:vid,TOTROWS:mrows,ACT_MODE:'add'},
		function(data){
		$("#divdbrd1_"+idval).html(data);});
	}
	if(mode=='remove')
	{
		//alert("save functionality has to be done w.r.t type "+typeval+" dashboard "+idval);
		$.post(tplname,{PASS_FROM:'validevents',psdbrdid:idval,UPID:vid,TOTROWS:mrows,ACT_MODE:'remove'},function(data){
		$("#divdbrd1_"+idval).html(data);});
	}
}
function fnAddothercontent(idval,mrows,vid,mode)
{
	var tplname="/public/public_othercontent_list/";
	
	var tttt="<table align='center' border=0><tr><td valign='middle'><BR><img src='/ps_sources/img/load.gif'></td><td ><BR><b>Loading Please Wait</b></td></tr><tr><td colspan=2><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR></td></tr></table>";	
	$("#divdbrd1_"+idval).html(tttt);
	if(mode=='add')
	{
		//alert("save functionality has to be done w.r.t type "+typeval+" dashboard "+idval);
		$.post(tplname,{access_from:'validcontent',psdbrdid:idval,UPID:vid,TOTROWS:mrows,ACT_MODE:'add'},
		function(data){
		$("#divdbrd1_"+idval).html(data);});
	}
	if(mode=='remove')
	{
		//alert("save functionality has to be done w.r.t type "+typeval+" dashboard "+idval);
		$.post(tplname,{access_from:'validcontent',psdbrdid:idval,UPID:vid,TOTROWS:mrows,ACT_MODE:'remove'},function(data){
		$("#divdbrd1_"+idval).html(data);
		});
	}
}
function fnSaveissues(idval,typeval,vid,mrows)
{
	var cls="clsissue_"+idval+"_"+vid;
	var issues=new Array();
	issues.length=0;
	var tplname="/public/dashboard_integration/";
		
	
	
	$(":checkbox."+cls).each(function(index){
		var vid=$(this);
	   var tp=vid.attr('id');	
	   if($(this).attr("checked"))
	     issues.push($(this).attr("value")) 
		
	});
	var temp=""+issues;	
	//alert(temp);
	var tttt="<table align='center' border=0><tr><td valign='middle'><BR><img src='/ps_sources/img/load.gif'></td><td ><BR><b>Loading Please Wait</b></td></tr><tr><td colspan=2><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR></td></tr></table>";	
	$("#divdbrd1_"+idval).html(tttt);
	$.post(tplname,{PASS_FROM:'valid',psdbrdid:idval,typeid:typeval,UPID:vid,chklistval:temp,TOTROWS:mrows,ACT_MODE:'issuechecklist'},function(data){
	//alert(data);
	$("#divdbrd1_"+idval).html(data);});
	temp='';
	issues.length=0;
	$("#divissues_"+idval+"_"+vid).css("display","none");
	
}
function fnSavePageissues(idval,typeval,vid,mrows)
{
	var cls="clsissue_"+idval+"_"+vid;
	var issues=new Array();
	issues.length=0;
	var tplname="/public/dashboard_integration/";	
	$(":checkbox."+cls).each(function(index){
		var vid=$(this);
	   var tp=vid.attr('id');	
	   if($(this).attr("checked"))
	     issues.push($(this).attr("value")) 
		
	});
	var temp=""+issues;	
	//alert(temp);
	var tttt="<table align='center' border=0><tr><td valign='middle'><BR><img src='/ps_sources/img/load.gif'></td><td ><BR><b>Loading Please Wait</b></td></tr><tr><td colspan=2><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR></td></tr></table>";	
	$("#divdbrd1_"+idval).html(tttt);
	$.post(tplname,{PASS_FROM:'validpage',psdbrdid:idval,typeid:typeval,UPID:vid,chklistval:temp,TOTROWS:mrows,ACT_MODE:'issuepagechecklist'},function(data){
	//alert(data);
	$("#divdbrd1_"+idval).html(data);});
	temp='';
	issues.length=0;
	$("#divissues_"+idval+"_"+vid).css("display","none");
	
}
function fnCancelissues(idval,typeval,vid)
{
	var cls="clsissue_"+idval+"_"+vid;
	var trp="sessissuelist_"+idval+"_"+vid;
	if($("#"+trp).val())
	{
		var selvals=$("#"+trp).val();	
		var clids1=selvals.split(",");
	
		
	$(":checkbox."+cls).each(function(index){
		var vid=$(this);
	   var tp=vid.attr('id');	 
	   if($.inArray($(this).attr("value"),clids1)>=0)
	   $(this).attr("checked","true");
	   else
	    $(this).attr("checked","");
	   
	});
	}
	else
	{
	 $(":checkbox."+cls).each(function(index){
		
	    $(this).attr("checked","");
	   
	});
	}
	$("#divissues_"+idval+"_"+vid).css("display","none");		
}
function fnLoadrelpages(idval,listissues)
{
   window.location="/public/pages_issues_list/dabrd/"+idval;	
}


/*********dashboard_content_script Template***********/
//For Issue Search
function fhandleResponDoctype_lt() 
{  
   
	if (http.readyState==4 || http.readyState=="complete")
	{   
		ajaxclick='no';
		var str = http.responseText	;
		//document.getElementById("divcontentdisplay").innerHTML=str;
		document.getElementById("showdocs").innerHTML=str;
	}
		
}
function fnIfraIssueSearch_lt(typeid,keyid)
{
   var childid=document.getElementById("childid_lt").value;
    var lefid=document.getElementById("lefid_lt").value;
   var parentid=document.getElementById("parentid_lt").value;
   var child='';
   var leaf='';
   var parent='';
   if(childid.length>0)
   	child="/childid/"+childid;
   	
   if(lefid.length>0)
   	leaf="/leafid/"+lefid;
   	
   if(parentid.length>0)
   	 parent="/parentid/"+parentid;	
   else
     parent="/parentid/0";
    		
   window.location="/public/index_ps"+parent+child+leaf+"/doctypeid/"+typeid+"/keyid/"+keyid;
   
 /* var params = "doctypeid="+typeid+"&keyid="+keyid+"&parentid="+parentid+"&childid="+childid+"&leafid="+lefid+"&contentdisplayhere=valid";
  	document.getElementById("showdocs").style.display="block";
	document.getElementById('showdocs').innerHTML="<table align='center' border=0><tr><td valign='middle'><img src='/sources/img/load.gif'></td><td valign='middle'><b>Loading Please Wait</b></td></tr><tr><td colspan=2><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR></td></tr></table>";	    
	 http.open('POST', "/public/dashboard_content/",true); 
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	http.send(params);
	http.onreadystatechange = fhandleResponDoctype_lt; */
  
}
//For Tag search
function fnIfraTagSearch_lt(typeid,tagid)
{
   var childid=document.getElementById("childid_lt").value;
   var lefid=document.getElementById("lefid_lt").value;
   var parentid=document.getElementById("parentid_lt").value;
  
    var child='';
   var leaf='';
   var parent='';
   if(childid.length>0)
   	child="/childid/"+childid;
   	
   if(lefid.length>0)
   	leaf="/leafid/"+lefid;
   	
   if(parentid.length>0)
   	 parent="/parentid/"+parentid;	
   else
     parent="/parentid/0";
    		
   window.location="/public/index_ps"+parent+child+leaf+"/doctypeid/"+typeid+"/tagid/"+tagid;
  
  /*var params = "doctypeid="+typeid+"&tagid="+tagid+"&parentid="+parentid+"&childid="+childid+"&leafid="+lefid+"&contentdisplayhere='valid'";
  	document.getElementById("showdocs").style.display="block";
	document.getElementById('showdocs').innerHTML="<table align='center' border=0><tr><td valign='middle'><img src='/sources/img/load.gif'></td><td valign='middle'><b>Loading Please Wait</b></td></tr><tr><td colspan=2><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR></td></tr></table>";	    
	 http.open('POST', "/public/dashboard_content/",true); 
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	http.send(params);
	http.onreadystatechange = fhandleResponDoctype_lt; */
  
}

//For sorting
function fnAjaxIfraLibrary_sort_lt(DocTypeID,sortcol)
{
	//var tagvalue=document.getElementById("tagval").value;
	var tagvalue='';
	var keyareavalue='';
   // var keyareavalue=document.getElementById("keyval").value;
   var childid=document.getElementById("childid_lt").value;
   var lefid=document.getElementById("lefid_lt").value;
   var parentid=document.getElementById("parentid_lt").value;
   
    var params = "sortby="+sortcol+"&doctypeid="+DocTypeID+"&tagid="+tagvalue+"&keyid="+keyareavalue+"&parentid="+parentid+"&childid="+childid+"&leafid="+lefid+"&contentdisplayhere=valid";
   
	document.getElementById("showdocs").style.display="block";
	document.getElementById('showdocs').innerHTML="<table align='center' border=0><tr><td valign='middle'><img src='/sources/img/load.gif'></td><td valign='middle'><b>Loading Please Wait</b></td></tr><tr><td colspan=2><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR></td></tr></table>";	    
	 http.open('POST', "/public/dashboard_content/",true); 
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
    http.send(params);
    http.onreadystatechange = fhandleResponDoctype_lt; 
}

function fnAjaxIfraLibrary_pagenr_lt(DocTypeID,pgno,sortcol)
{
	//alert(sortcol);
	var tagvalue=document.getElementById("tagval").value;
    var keyareavalue=document.getElementById("keyval").value;   
     var childid=document.getElementById("childid_lt").value;
     var lefid=document.getElementById("lefid_lt").value;
   var parentid=document.getElementById("parentid_lt").value;
  
    var params = "pagenr="+pgno+"&doctypeid="+DocTypeID+"&sortby="+sortcol+"&tagid="+tagvalue+"&keyid="+keyareavalue+"&parentid="+parentid+"&childid="+childid+"&leafid="+lefid+"&contentdisplayhere=valid";
    document.getElementById("showdocs").style.display="block";
    document.getElementById('showdocs').innerHTML="<table align='center' border=0><tr><td valign='middle'><img src='/sources/img/load.gif'></td><td valign='middle'><b>Loading Please Wait</b></td></tr><tr><td colspan=2><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR></td></tr></table>";
    http.open('POST', "/public/dashboard_content/",true); 
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
    http.send(params);
    http.onreadystatechange = fhandleResponDoctype_lt; 
    
}

function fnAjaxIfraLibrary_pagego_lt(DocTypeID,sortcol)
{
	// Open PHP script for requests 
	//alert(sortcol);
	var tagvalue=document.getElementById("tagval").value;
    var keyareavalue=document.getElementById("keyval").value;
     var childid=document.getElementById("childid_lt").value;
     var lefid=document.getElementById("lefid_lt").value;
   var parentid=document.getElementById("parentid_lt").value;
    if(document.getElementById("gopage").value=="#")
    {
    	alert("Enter the Page Number");
    	return false;
    }
    else
    {
	    var pgno=document.getElementById("gopage").value;
	     document.getElementById("showdocs").style.display="block";
	    document.getElementById('showdocs').innerHTML="<table align='center' border=0><tr><td valign='middle'><img src='/sources/img/load.gif'></td><td valign='middle'><b>Loading Please Wait</b></td></tr><tr><td colspan=2><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR></td></tr></table>";	    
	  	  
		     //Send the proper header information along with the request
	    var params = "pagenr="+pgno+"&doctypeid="+DocTypeID+"&sortby="+sortcol+"&tagid="+tagvalue+"&keyid="+keyareavalue+"&parentid="+parentid+"&childid="+childid+"&leafid="+lefid+"&contentdisplayhere=valid";
		http.open('POST', "/public/dashboard_content/",true); 
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
    http.send(params);
    http.onreadystatechange = fhandleResponDoctype_lt;     
    } 
}
function fnClearGoVal_lt()
{
	document.getElementById("gopage").value="";
}
function fnCheckEnterkeyOnLib_lt(e,UID1,SCOL)
{
	var characterCode; //literal character code will be stored in this variable
	if(e && e.which){ //if which property of event object is supported (NN4)
	e = e;
	characterCode = e.which //character code is contained in NN4's which property
	}
	else{
	e = event;
	characterCode = e.keyCode //character code is contained in IE's keyCode property
	}
	
	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
	   fnAjaxIfraLibrary_pagego_lt(UID1,SCOL)
	   return false;
	}
	else{
	return true;
	}
}


/*********************public_orderfrom_list_script  Template **************/
function fnOrderDocument(docid,chid,leaf)
{
   var vvp='ajax';
    http.open('POST', "/public/public_orderfrom_list/",true); 
    var params = "checkdocid="+docid+"&actfrom="+vvp+"&childid="+chid+"&leaf="+leaf;
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
	http.send(params);
	http.onreadystatechange = fhandleorderRespon; 
}
function fhandleorderRespon() 
{  
   
	if (http.readyState==4 || http.readyState=="complete")
	{   
		ajaxclick='no';
		var str = http.responseText	;
		//document.getElementById("divcontentdisplay").innerHTML=str;
		document.getElementById("showdocs").innerHTML=str;
	}
		
}
function fnordersubmit(cid,lid)
{
	var cls="chkorder11";
	var name='';
	var email='';
	var name=$("#ortxtname").attr("value");
	var email=$("#ortxtemail").attr("value");
	var address=$("#ortxtaddr").attr("value");
	var orders=new Array();
	orders.length=0;
	var tplname="/public/public_orderfrom_submit/";	
	$(":checkbox."+cls).each(function(index){
		var vid=$(this);
	   var tp=vid.attr('id');	
	   if($(this).attr("checked"))
	     orders.push($(this).attr("value")) 
		
	});
	
	//Validateion
	var err='';
	if(orders.length<=0)
	{
		err+='select atleast one item \n';		
	}
	if(name=="")
	{
		err+='Enter your name \n';		
	}
	
	if(email=="")
	{
		err+='Enter your Email \n';			
	}
	if(isValidEmailAddress1(email)==false)
	{
		err+='Enter Valid Email \n';	
	}
	
	if(address=="")
	{
		err+='Enter your Address \n';	
		
	}
	if(err.length>0)
	{
		alert(err);
		return;
	}
	else
	{
		var temp=""+orders;	
       	var tttt="<table align='center' border=0><tr><td valign='middle'><BR><img src='/ps_sources/img/load.gif'></td><td ><BR><b>Loading Please Wait</b></td></tr><tr><td colspan=2><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR></td></tr></table>";	
		$("#showdocs").html(tttt);
		$.post(tplname,{chkdocs:temp,toname:name,tomail:email,toaddr:address,child:cid,leaf:lid},function(data){
		$("#showdocs").html(data);});
	}	

}
function isValidEmailAddress1(emailAddress) {
var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
return pattern.test(emailAddress);
}

/******************dashboard_content_list_script Template************/
function fnshowdesc1(idval)
{
//alert(idval);
var curid="divother_"+idval;
$(".divothercls").each(function(index){
		var vid=$(this).attr('id');  
	   
	   if(curid==vid)
	   {
	        $("#"+vid).css("display","block");
	   }
	   else
	   {
	   	$("#"+vid).css("display","none");
	   }   
		
	});
}

function fnother_pagenr_lt(pgno)
{
	//alert(sortcol);
   var contnetid=document.getElementById("othercontenttypeid").value;
    var params = "pagenr="+pgno+"&contentdisplayhere=true"+"&othercontenttypeid="+contnetid;
    document.getElementById("showdocs").style.display="block";
    document.getElementById('showdocs').innerHTML="<table align='center' border=0><tr><td valign='middle'><img src='/sources/img/load.gif'></td><td valign='middle'><b>Loading Please Wait</b></td></tr><tr><td colspan=2><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR></td></tr></table>";
    http.open('POST', "/public/dashboard_content_list/",true); 
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
    http.send(params);
    http.onreadystatechange = fhandleResponDoctype_lt; 
    
}

function fnother_pagego_lt()
{
	// Open PHP script for requests 
	//alert(sortcol);
    if(document.getElementById("gopage").value=="#")
    {
    	alert("Enter the Page Number");
    	return false;
    }
    else
    {
	    var pgno=document.getElementById("gopage").value;
	    var contnetid=document.getElementById("othercontenttypeid").value;
	     document.getElementById("showdocs").style.display="block";
	    document.getElementById('showdocs').innerHTML="<table align='center' border=0><tr><td valign='middle'><img src='/sources/img/load.gif'></td><td valign='middle'><b>Loading Please Wait</b></td></tr><tr><td colspan=2><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR><BR></td></tr></table>";	    
	  	  
		     //Send the proper header information along with the request
	    var params = "pagenr="+pgno+"&contentdisplayhere=true"+"&othercontenttypeid="+contnetid;
		http.open('POST', "/public/dashboard_content_list/",true); 
	http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	http.setRequestHeader("Content-length", params.length);
	http.setRequestHeader("Connection", "close");
    http.send(params);
    http.onreadystatechange = fhandleResponDoctype_lt;     
    } 
}
function fnotherClearGoVal_lt()
{
	document.getElementById("gopage").value="";
}
function fnotherCheckEnterkeyOnLib_lt(e)
{
	var characterCode; //literal character code will be stored in this variable
	if(e && e.which){ //if which property of event object is supported (NN4)
	e = e;
	characterCode = e.which //character code is contained in NN4's which property
	}
	else{
	e = event;
	characterCode = e.keyCode //character code is contained in IE's keyCode property
	}
	
	if(characterCode == 13){ //if generated character code is equal to ascii 13 (if enter key)
	   fnother_pagego_lt();
	   return false;
	}
	else{
	return true;
	}
}