// JavaScript Document


function HideCreationForm() 
 {
 document.getElementById('div_item_crtn').style.display='none';
 document.getElementById('temp_item').style.display='none'; // hiding temp expand table
 IeHolyHack();
 }
 
function IeHolyHack() 
 {
 	//----- Holy hack for IE6 as per http://www.codingforums.com/showthread.php?t=118118 -----	
	if(document.getElementById('footer').style.backgroundPosition =='1px 1px')
		document.getElementById('footer').style.backgroundPosition = '0 0';
	else
		document.getElementById('footer').style.backgroundPosition='1px 1px';
	//----------------------------------------------------------------------------------------			
 }
function ShowCreationForm()
 {
	//alert(document.getElementById('usr_id').value);
	if(document.getElementById('IsActive_navigate').value == 'S')
		{
		alert("Your account is currently in suspended mode, which means you can't participate/ post in any of the forums.Please have a look at your account for more details, Thank you! ");// ');
		return false;
		}

	if(document.getElementById('usr_id').value=="")
		{
		var a =window.document.location.toString();
		document.getElementById('from_navigate').value=a;
		document.getElementById('Purpose_navigate').value='create';
		document.forms['navigate'].action='InfcLogin.php';
		document.forms['navigate'].submit();
		return;
		}
//alert(document.getElementById('usr_id').value);		
if(document.getElementById('div_item_crtn').style.display=='block'  )
	document.getElementById('div_item_crtn').style.display='none';
else
	{
	document.getElementById('div_item_crtn').style.display='block';
	//alert(document.body.scrollHeight);
	window.scroll(0,document.body.scrollHeight+300);		
	document.getElementById('Title').focus();
	}

IeHolyHack();  
 
 } 
  


function ExpandItem(LevelNo,e)
 {
	
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	
	if (e.pageX || e.pageY) 	{
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) 	{
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
	
	var headtext= document.getElementById('head'+LevelNo).innerHTML.substr(1,document.getElementById('head'+LevelNo).innerHTML.length);
    //alert(headtext);
	//alert('div_'+LevelNo);
	if(document.getElementById('div_'+LevelNo).style.display=='block')
		{
		document.getElementById('head'+LevelNo).innerHTML='+'+headtext;
		document.getElementById('div_'+LevelNo).style.display='none';
		}
	else
		{
		document.getElementById('head'+LevelNo).innerHTML='-'+headtext;
		document.getElementById('div_'+LevelNo).style.display='block';

		/*
		pos_x = event.offsetX?(event.offsetX):event.pageX-document.getElementById(LevelNo).offsetLeft;
		pos_y = event.offsetY?(event.offsetY):event.pageY-document.getElementById(LevelNo).offsetTop;
		alert(pos_y);
		*/
		}
	//alert(document.getElementById(LevelNo+'head').innerHTML);	
	//alert(posy);	
	window.scroll(0,posy-10);
	IeHolyHack();
 }


function ShowReplyForm(LevelNo)
{
	
		if(document.getElementById('IsActive_navigate').value == 'S')
		{
		alert("Your account is currently in suspended mode, which means you can't participate/ post in any of the forums.Please have a look at your account for more details, Thank you! ");// ');
		return false;
		}

	document.getElementById('LevelNo_navigate').value=LevelNo;
	document.getElementById('Purpose_navigate').value='reply';

	if(document.getElementById('usr_id').value=="")
		{
		var a =window.document.location.toString();
		document.getElementById('from_navigate').value=a;
		document.forms['navigate'].action='InfcLogin.php';
		document.forms['navigate'].submit();
		return;
		}
 //alert(LevelNo);
	 document.forms['navigate'].submit();
	 return 0;
	//window.location="InfcItemListing.php?LevelNo="+LevelNo+"&type=reply";
} 

function ShowAttachmentDiv()
 {
 	document.getElementById('attach_id').style.display='block';	
	window.scroll(0,document.body.clientHeight);			
	IeHolyHack();	
 } 
/*
function OpenMal() 
 {
 var windowname='English to Malayalam Converter';
 theChild=window.open('./malayalam/malayalam.html','windowname','toolbar=no,status=no,diretories=no,menubar=no,location=0,width=700,height=550',true);
 theChild.moveTo(100,50);
 }
*/
function OpenMal(mylink, windowname)
{
//alert('hai');
//mylink='malayalam/malayalam.htm';

if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
theChild=window.open(href, windowname, 'toolbar=no,status=no,diretories=no,menubar=no,scollbars=yes;location=0,width=750,height=550');
theChild.moveTo(100,50);
return false;
}
//################################################################################
function Navigate(LevelNo,offset,SearchKey,SearchLocation)
 {
 //alert(SearchKey); 
 // alert(LevelNo); 
 var pre='0-',i=0,temp;

 temp=LevelNo.substr(2,LevelNo.length-1);
 while(temp.charAt(i)!='-')
 	{
	x=temp.charAt(i++);
	pre+=x;
	//alert(temp);
	if(!x)
		break;
		
	}
 
 
 //alert(pre);
 switch(pre)
 	{
	case '0-0':document.forms['navigate'].action ="index.php";
				break;
	case '0-1':document.forms['navigate'].action ="InfcAbout.php";
				break;
	
	case '0-4': document.forms['navigate'].action ="InfcContactUs.php";
				break;
	case '0-5': document.forms['navigate'].action ="InfcWhatsNew.php";
				break;
	
	case '0-6': 
					switch(LevelNo)
					{
						case '0-6-0': document.forms['navigate'].action ="InfcMyHome.php";
									break;
						case '0-6-9': document.forms['navigate'].action ="InfcAsanArtist.php";
									break;
						case '0-6-10': document.forms['navigate'].action ="InfcPictureGallery.php";
									break;
						default		: document.forms['navigate'].action ="InfcMySongs.php";		
						
					}
				break;
							
	case '0-7': document.forms['navigate'].action ="InfcTellKaithapram.php";
				break;
	case '0-8': document.forms['navigate'].action ="InfcInteractiveForum.php";
				break;
	case '0-9': document.forms['navigate'].action ="InfcMusicTherapy.php";
				break;
	case '0-10': if(document.getElementById('usr_id').value=="")
					document.forms['navigate'].action ="InfcLogin.php";
				 else		
					document.forms['navigate'].action ="InfcProfile.php";
				 break;
	case '0-12': document.forms['navigate'].action ="InfcAnnouncements.php";
				break;
	case '0-13': document.forms['navigate'].action ="InfcSearch.php";
				break;
	case '0-14': document.forms['navigate'].action ="InfcSiteMap.php";
				break;
	case '0-15': document.forms['navigate'].action ="InfcLogin.php";
				break;
	case '0-16': document.forms['navigate'].action ="InfcReminder.php";
				break;
	case '0-17': document.forms['navigate'].action ="InfcUserRegistration.php";
				break;			
	default:	document.forms['navigate'].action ="InfcMySongs.php";
				break;			
	//default:
									
	}
	
 document.getElementById('LevelNo_navigate').value=LevelNo;
 document.getElementById('offset_navigate').value=offset;
 
 document.getElementById('SearchKey_navigate').value=SearchKey;
 //alert(SearchLocation);
 document.getElementById('SearchLocation_navigate').value=SearchLocation;

 document.forms['navigate'].submit();
	
// window.location="InfcItemListing.php?LevelNo="+LevelNo+"&type=view";	
 }
function ViewComments(LevelNo)
{
	
	document.getElementById('LevelNo_navigate').value=LevelNo;
 //alert(LevelNo);
	document.getElementById('Purpose_navigate').value='view';
	document.forms['navigate'].submit();
	//alert(LevelNo);
	
	//window.location="InfcItemListing.php?LevelNo="+LevelNo+"&type=view";
} 
function EditItem(LevelNo)
{
		if(document.getElementById('IsActive_navigate').value == 'S')
		{
		alert("Your account is currently in suspended mode, which means you can't participate/ post in any of the forums.Please have a look at your account for more details, Thank you! ");// ');
		return false;
		}

	document.getElementById('LevelNo_navigate').value=LevelNo;
	document.getElementById('Purpose_navigate').value='edit';
	
	if(document.getElementById('usr_id').value=="")
		{
		var a =window.document.location.toString();
		document.getElementById('from_navigate').value=a;
		//alert(LevelNo);
		document.forms['navigate'].submit();
		return;
		}
	document.forms['navigate'].submit();
	return 0;
	
// window.location="InfcItemListing.php?LevelNo="+LevelNo+"&type=edit";
}
/*
function DeleteItem(LevelNo,ParentLevelNo)
 {
// alert(ParentLevelNo);
  var OK= confirm("Are you sure you want to delete this entry,subentries and related documents?");
  
  if(OK)
   {
   x_DeleteItem(LevelNo,ParentLevelNo,DeletionResult)
   }
 }
 
function DeletionResult(ParentLevelNo)
 {
	 alert(ParentLevelNo);
	 //window.location.reload( false );
	 Navigate(ParentLevelNo);

 }  
*/ 

function popupDownload(id) {
  //alert(id);
  POP=window.open('download.php?doc_id='+id,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+200+',height='+150+',screenX=250,screenY=200,top=150,left=150')
  //POP.close();
}

function popupWindowImage(url,file_name,width,height) {
  //alert(width+','+height);
  POP=window.open('InfcImagePreview.php?image='+url+'&file_name='+file_name,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+width+',height='+height+',screenX=150,screenY=150,top=150,left=150')
  //POP.document.title=file_name;
}
function popupWindowMedia(url,file_name,type) {
 
  //alert(type);
  if(type =='audio')
  	{
	width=300;
	height=30;
	}
  else
    {
	width=500;
	height=400;
	}
		
  POP=window.open('InfcPlayMedia.php?file_path='+url+'&file_name='+file_name+'&type='+type,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width='+width+',height='+height+',screenX=150,screenY=150,top=150,left=150')
  POP.document.title=file_name;
}