function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function getPrint(){
document.getElementById("top").style.display="none";
document.getElementById("leftPanel").style.display="none";
document.getElementById("rightPanel").style.display="none";
document.getElementById("leftPanelDot").style.display="none";
document.getElementById("bottom").style.display="none";
document.getElementById("emaiLogo").style.display="none";
document.getElementById("PrintLogo").style.display="none";
document.getElementById("logo").innerHTML='<a href="index.php"><img src="../images/financial_objects.gif" vspace="12" border="0"></a>';
window.print();
}
var xmlHttp;
function ShowMailBox(){
document.getElementById("fResult").style.display="none";
document.getElementById("maiBox").style.display="block";
document.getElementById("sName").focus();
return false;
}
function HideBox(){
document.getElementById("maiBox").style.display="none";
document.getElementById("sName").value='';
document.getElementById("fName").value='';
document.getElementById("sEmail").value='';
document.getElementById("fEmail").value='';
return false;
}
function CheckForm(){
if(!document.getElementById("sName").value){
alert('Please Enter Your Name!');
document.getElementById("sName").focus();
return false;
}
if(!document.getElementById("sEmail").value){
alert('Please Enter Your Email');
document.getElementById("sEmail").focus();
return false;
}else{
	var emailStr=document.getElementById("sEmail").value;
	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
	if (!(!reg1.test(emailStr) && reg2.test(emailStr))) 
	{
	alert("Please check Your Email Address.");
	document.getElementById("sEmail").focus();
	return false;   
	}
}
if(!document.getElementById("fName").value){
alert('Please Enter Friend Name');
document.getElementById("fName").focus();
return false;
}
if(!document.getElementById("fEmail").value){
alert('Please Enter Friend Email');
document.getElementById("fEmail").focus();
return false;
}else{
	var emailStr=document.getElementById("fEmail").value;
	var reg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
	var reg2 = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/; // valid
	if (!(!reg1.test(emailStr) && reg2.test(emailStr))) 
	{
	alert("Please check Friend Email Address.");
	document.getElementById("fEmail").focus();
	return false;   
	}
}


xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	 var url="mail.php?sName="+document.getElementById("sName").value+"&fName="+document.getElementById("fName").value+"&sMail="+document.getElementById("sEmail").value+"&fMail="+document.getElementById("fEmail").value+"&fileName="+document.getElementById("fileName").value+"&folderName="+document.getElementById("folderName").value+"&verify="+document.getElementById("verify").value;
	
	xmlHttp.onreadystatechange=staChanged
	//alert(url);
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)


}

function staChanged() 
	{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
		document.getElementById("sResult").style.display="none";
	//alert(xmlHttp.responseText);
//return false;
		if(xmlHttp.responseText!='error'){
	document.getElementById("sName").value='';
	document.getElementById("fName").value='';
	document.getElementById("sEmail").value='';
	document.getElementById("fEmail").value='';
	document.getElementById("sResult").style.display="none";
	document.getElementById("fResult").style.display="block";
	}else{
	alert("Verification code does not match!");
	
	document.getElementById("maiBox").style.display="block";
	return false;
	}
		
}else{
document.getElementById("maiBox").style.display="none";
document.getElementById("sResult").style.display="block";
}
}

function GetXmlHttpObject()
	{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
	objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
	objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
	}
	
	function CheckUser(){
	if(!document.getElementById("userName").value){
	alert('Please Enter UserName!');
	document.getElementById("userName").focus();
	return false;
	}
	if(!document.getElementById("Password").value){
	alert('Please Enter Password!');
	document.getElementById("Password").focus();
	return false;
	}
	
	}
	
	function backOnPressEditor(goto){
		if(goto=='returnBack'){
		var msg="Do you want to edit ?";
		}else{
		var msg="Do you want to publish this page on live site ?";
		}
	if(confirm(msg)){
		if(goto=='returnBack'){
		document.contForm.action="add_new_press_release.php";
		}else{
		document.contForm.action="confirmPress.php";
		}
		document.contForm.submit();
		
	}
	}
 function backOnMediaEditor(goto){
	
		if(goto=='returnBack'){
		var msg="Do you want to edit ?";
		}else{
		var msg="Do you want to publish this page on live site ?";
		}
	if(confirm(msg)){
		if(goto=='returnBack'){
		document.contForm.action="add_news.php";
		}else{
		document.contForm.action="news_confirm.php";
		}
		document.contForm.submit();
		
	}

	}
	
	function backEditor(goto){
		if(goto=='returnBack'){
		var msg="Do you want to edit ?";
		}else{
		var msg="Do you want to publish this page on live site ?";
		}
	if(confirm(msg)){
		if(goto=='returnBack'){
		document.contForm.action="corporate_announcements.php";
		}else{
		document.contForm.action="confirm.php";
		}
		document.contForm.submit();
		
	}
		
	}
function chomePublish(id,hstatus){
		var k=0;
var totAnnounce=0;
totAnnounce=document.getElementById("totAnnounce1").value;
var gid="c"+id;
var hstatus1=document.getElementById(gid).value;
if(totAnnounce==4 && hstatus1==0){
alert('You can not set more than two press releases on child home page. \n To do this please remove one press release from child home page!\n \n To see both press releases Please click on View All Press Releases');
return false;
}
xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	if(hstatus1==1){
	if(confirm('Would you like to remove this article from the child home page?')){
	}else{
	document.fr1.id.checked=true;
	return false;
	}
	}else{
	if(confirm('Would you like to add this article to the child home page?')){
	}else{
	document.fr1.id.checked=false;
	return false;
	}
	}
	//return false;
	var url="cpage.php?contentId="+id+"&hStatus="+hstatus1;
	xmlHttp.onreadystatechange=chomeChanged
	xmlHttp.open("POST",url,true)
	xmlHttp.send(null)

}
function chomeChanged() 
	{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
	document.getElementById("loding").style.display="none";
	var av=xmlHttp.responseText;
	av= av.split("@");
	document.getElementById("totAnnounce1").value=av[1];
	var ff="c"+av[2];
	document.getElementById(ff).value=av[3];
	alert(av[0]);
}else{
	document.getElementById("loding").style.display="block";
}
	
}


function news_childhome(id,hstatus){
		var k=0;
var totAnnounce=0;
totAnnounce=document.getElementById("totAnnounce1").value;
var gid="c"+id;
var hstatus1=document.getElementById(gid).value;
if(totAnnounce==4 && hstatus1==0){
alert('You can not set more than two news on child home page. \n To do this please remove one news from child home page!\n \n To see both news click on View All News');
return false;
}
xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	if(hstatus1==1){
	if(confirm('Would you like to remove this article from the child home page?')){
	}else{
	document.fr1.id.checked=true;
	return false;
	}
	}else{
	if(confirm('Would you like to add this article to the child home page?')){
	}else{
	document.fr1.id.checked=false;
	return false;
	}
	}
	//return false;
	var url="news_child_home.php?contentId="+id+"&hStatus="+hstatus1;
	xmlHttp.onreadystatechange=chomeChanged
	xmlHttp.open("POST",url,true)
	xmlHttp.send(null)

}
function chomeChanged() 
	{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
	document.getElementById("loding").style.display="none";
	var av=xmlHttp.responseText;
	av= av.split("@");
	document.getElementById("totAnnounce1").value=av[1];
	var ff="c"+av[2];
	document.getElementById(ff).value=av[3];
	alert(av[0]);
}else{
	document.getElementById("loding").style.display="block";
}
	
}




function homePublish(id,hstatus){
var k=0;
var totAnnounce=0;
totAnnounce=document.getElementById("totAnnounce").value;
var hstatus1=document.getElementById(id).value;
if(totAnnounce==2 && hstatus1==0){
alert('You can not set more than two annoucements on home page. \n To do this please remove one announcement from home list!\n \n To see both anouncements Please click on View all announcements');
return false;
}
xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	if(hstatus1==1){
	if(confirm('Would you like to remove this article from the home page ?')){
	}else{
	document.fr1.id.checked=true;
	return false;
	}
	}else{
	if(confirm('Would you like to add this article to the home page ?')){
	}else{
	document.fr1.id.checked=false;
	return false;
	}
	}
	var url="hpage.php?contentId="+id+"&hStatus="+hstatus1;
	xmlHttp.onreadystatechange=homeChanged
	xmlHttp.open("POST",url,true)
	xmlHttp.send(null)

}
function homeChanged() 
	{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
	document.getElementById("loding").style.display="none";
	var av=xmlHttp.responseText;
	av= av.split("@");
	document.getElementById("totAnnounce").value=av[1];
	document.getElementById(av[2]).value=av[3];
	alert(av[0]);
}else{
	document.getElementById("loding").style.display="block";
}
	
}
//////////////////////////////////////////////////////////////////
function homePublishPress(id,hstatus){
//alert(hstatus);
var k=0;
var totAnnounce=document.getElementById("totAnnounce").value;

	var hstatus1=document.getElementById(id).value;

if(totAnnounce==4 && hstatus1==0){
alert('You can not set more than two press releases on home page. \n To do this please remove one press release from home list!\n \n To see both press releases Please click on View all press releases');
return false;
}
xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	if(hstatus1==1){
	if(confirm('Would you like to remove this article from the home page?')){
	}else{
	document.fr1.id.checked=true;
	return false;
	}
	}else{
	if(confirm('Would you like to add this article to home page ?')){
	}else{
	document.fr1.id.checked=false;
	return false;
	}
	}
	//alert(hstatus);
	var url="hpage.php?contentId="+id+"&hStatus="+hstatus1;
	xmlHttp.onreadystatechange=homeChangedPress
	xmlHttp.open("POST",url,true)
	xmlHttp.send(null)

}
function homeChangedPress() 
	{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
	document.getElementById("loding").style.display="none";
	var av=xmlHttp.responseText;
	av= av.split("@");
	document.getElementById("totAnnounce").value=av[1];
	document.getElementById(av[2]).value=av[3];
	alert(av[0]);
}else{
	document.getElementById("loding").style.display="block";
}
	
}

//............................media coverage.............................


function media_homePublish(id,hstatus){
	

var k=0;
var totAnnounce=document.getElementById("totAnnounce").value;

	var hstatus1=document.getElementById(id).value;

if(totAnnounce==2 && hstatus1==0){
alert('You can not set more than two News on home page. \n To do this please remove one News from home list!\n \n To see both News Please click on View all News');
return false;
}
xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	if(hstatus1==1){
	if(confirm('Would you like to remove this article from the home page?')){
	}else{
	document.fr1.id.checked=true;
	return false;
	}
	}else{
	if(confirm('Would you like to add this article to home page?')){
	}else{
	document.fr1.id.checked=false;
	return false;
	}
	}
	//alert(hstatus);
	var url="news_page.php?contentId="+id+"&home_status="+hstatus1;
	//alert(url);
	xmlHttp.onreadystatechange=homeChangedmedia
	xmlHttp.open("POST",url,true)
	xmlHttp.send(null)

}
function homeChangedmedia() 
	{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
	document.getElementById("loding").style.display="none";
	var av=xmlHttp.responseText;
	av= av.split("@");
	document.getElementById("totAnnounce").value=av[1];
	document.getElementById(av[2]).value=av[3];
	alert(av[0]);
}else{
	document.getElementById("loding").style.display="block";
}
	
}

//..........................media coverage end............................................

/////////////////////////////////////////////////////////////////

function CheckTitle(){
	if(document.getElementById("title").value=='Announcement Title' || !document.getElementById("title").value ){
		alert('Please Enter Announcement Title');
		document.getElementById("title").value='';
		document.getElementById("title").focus();
		return false;
	
	}
}
function CheckPressTitle(){
	if(document.getElementById("title").value=='Press Release Title' || !document.getElementById("title").value ){
		alert('Please Enter Press Release Title');
		document.getElementById("title").value='';
		document.getElementById("title").focus();
		return false;
	
	}
}
function CheckMediaTitle(){
	if(document.getElementById("title").value=='News Title' || !document.getElementById("title").value ){
		alert('Please Enter News Title');
		document.getElementById("title").value='';
		document.getElementById("title").focus();
		return false;
	
	}
}

function makeItBlank(){
document.getElementById("title").value='';
document.getElementById("title").focus();
return false;
	
}

function OpenAllList(id){
	var childList1="childList"+id
	//alert(childList1);
	document.getElementById(childList1).style.display="block";
}

function changeCurrentStatus(id,forwhich,status){
	//alert(id);
	//alert(forwhich);
	//alert(status);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	if(status=='1'){
		var msg="Would you like to remove this Press Release?";
		var c=true;
	}else{
		var msg="Would you like to add this Press Release?";
		var c=false;
	}
	if(confirm(msg)){
		
	var url="ajaxpage.php?token="+'p'+"&id="+id+"&Status="+status+"&forwhich="+forwhich;
	xmlHttp.onreadystatechange=CurrentChildWeb
	xmlHttp.open("POST",url,true)
	xmlHttp.send(null)
	
	}else{
		document.getElementById(forwhich+id).checked=c;
		return false;
		
	}
	
}
function CurrentChildWeb(){
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
	document.getElementById("loding").style.display="none";
	alert(xmlHttp.responseText);
}else{
	document.getElementById("loding").style.display="block";
}
}

// for media coverage
function changeMediaStatus(id,forwhich,status){
	//alert(id);
	//alert(forwhich);
	//alert(status);
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	if(status=='1'){
		var msg="Would you like to remove this News?";
		var c=true;
	}else{
		var msg="Would you like to add this News?";
		var c=false;
	}
	if(confirm(msg)){
		
	var url="ajaxpage.php?token="+'m'+"&id="+id+"&Status="+status+"&forwhich="+forwhich;
	//alert(url);
	xmlHttp.onreadystatechange=CurrentChildWeb
	xmlHttp.open("POST",url,true)
	xmlHttp.send(null)
	
	}else{
		document.getElementById(forwhich+id).checked=c;
		return false;
		
	}
	
}
function CurrentChildWeb(){
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{
	document.getElementById("loding").style.display="none";
	alert(xmlHttp.responseText);
}else{
	document.getElementById("loding").style.display="block";
}
}

function blankIt(){
	document.getElementById("d").value="";
	document.getElementById("d").focus();
	return false;
	
}

function Show_Reg_Box(id){
//alert(id);
	xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null){
			alert ("Browser does not support HTTP Request")
			return
		} 
		//document.getElementById("centredata").style.display="block"
		document.getElementById("centre_data").style.display="none"
		var url="event_register_show.php?contentId="+id;
		xmlHttp.onreadystatechange=ShowRegBox
		xmlHttp.open("POST",url,true)
		xmlHttp.send(null)
		//return false;
}
function ShowRegBox() 
	{ 
		if(xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{
		var kk=xmlHttp.responseText;
		//alert(kk);
		document.getElementById("centredata").innerHTML=kk ;

		}
	
}
