var form='';


doPopUpX = (screen.width/2)-350;
var doPopUpY = (screen.height/2)-270;
var pos = "left="+doPopUpX+",top="+doPopUpY;

function popUp(url){
doPopUpWindow = window.open(url,"11_ChatBox","scrollbars=yes,width=700,height=500,"+pos);
}



function popUpWin(url){
doPopUpWindow = window.open(url);
}


function popUpSmall(url){

doPopUpX = (screen.width/2)-350;
doPopUpY = (screen.height/2)-270;
pos = "left="+doPopUpX+",top="+doPopUpY;


doPopUpWindow = window.open(url,"Leave_Records","width=400,height=200,"+pos);
}


function checkMail1()
{ 
	form=document.mail;

	if(form.message.value=='')
	{
		alert("Message field is empty");
		form.message.focus();
		return false;
	}

	if(form.subject.value=='')
	{
		alert("Please enter the subject for the message");
		form.subject.focus();
		return false;
	}

}

function changeDate(){
  var dt_arr,tmp_date;
  dt_arr=document.frm.curr_date.value.split("-");
  tmp_date=dt_arr[2]+"-"+dt_arr[1]+"-"+dt_arr[0]; 
  document.frm.today.value=tmp_date;
  document.frm.submit();
}


function chkPhoto()
{
	var form= document.photo;

	if(form.heading.value=="")
	{
		alert ('Enter Heading');
		form.heading.focus();
		return false;

	}
	if( form.body.value=="" )
	{
		if(form.cat.value!="S")
		{
			alert ('Enter Text');
			form.body.focus();
			return false;

		}
	}



	if(form.link.value=="http://")
	{
		form.link.value="";


	}


}



function selAdd()
{
	var form=document.form1;


	var sellist_len= form.photolist.length;

	if (sellist_len >= parseInt(form.total.value))
	{
		alert("You can display only "+sellist_len+" photograph(s).");
		return false;
	}

//	alert(sellist_len);
	
	if(form.photo.value)
	{
		form.photolist.length=sellist_len+1;
		
		var i = form.photo.selectedIndex
		form.photolist.options[sellist_len].text=form.photo.options[i].text;
		form.photolist.options[sellist_len].value=form.photo.value;
		
		form.photo.options[i].text="";
		form.photo.options[i].value="";

		for(var x=i;x<(form.photo.length-1);x++)
		{
			form.photo.options[x].text=form.photo.options[x+1].text;
			form.photo.options[x].value= form.photo.options[x+1].value;

		}
		form.photo.options[x].text="";
		form.photo.options[x].value="";

		form.photo.length--;
	}

}

function selDel()
{
	var form=document.form1;


	var sellist_len= form.photo.length;
//	alert(sellist_len);
	
	if(form.photolist.value)
	{
		form.photo.length=sellist_len+1;
		
		var i = form.photolist.selectedIndex
		form.photo.options[sellist_len].text=form.photolist.options[i].text;
		form.photo.options[sellist_len].value=form.photolist.value;
		
		form.photolist.options[i].text="";
		form.photolist.options[i].value="";

		for(var x=i;x<(form.photolist.length-1);x++)
		{
			form.photolist.options[x].text=form.photolist.options[x+1].text;
			form.photolist.options[x].value= form.photolist.options[x+1].value;

		}
		form.photolist.options[x].text="";
		form.photolist.options[x].value="";

		form.photolist.length--;
	}

}


function selectAll(cbList,bSelect) {
  for (var i=0; i<cbList.length; i++) 
    cbList[i].selected = cbList[i].checked = bSelect;
	
}

var arSelected = new Array(); 
function getMultiple(ob) 
{ 
	while (ob.selectedIndex != -1) 
	{ 
		if (ob.selectedIndex != 0) 
			arSelected.push(ob.options[ob.selectedIndex].value); 
		ob.options[ob.selectedIndex].selected = false; 
	} // You can use the arSelected array for further processing. 
}




function chk()
{

	
	form= document.form1;
	var cbList= form.photolist;
	//selectAll(cbList,true);
	var str="";

	for (var i=0; i<cbList.length; i++) 
	{
		str=str+","+cbList.options[i].value;
		//alert(str);

	}
/*
	if(parseInt(form.total.value)< cbList.length)
	{
		alert("More no. of photographs in the list" );
		cbList.focus();
		return false;
	}*/

	
	form.plist.value=str;



	var cbList1= form.sponsorlist;
	str=''
	for (var i=0; i<cbList1.length; i++) 
	{
		str=str+","+cbList1.options[i].value;

	}
/*
	if(parseInt(form.total_spons.value)< cbList1.length)
	{
		alert("More no. of sponsor in the list" );
		cbList1.focus();
		return false;
	}
*/
	form.slist.value=str;



	var cbList2= form.stoppress;
	str= '';
	for (var i=0; i<cbList2.length; i++) 
	{
		str=str+","+cbList2.options[i].value;

	}

	form.stoplist.value=str;



}

function selUp()
{
	var form=document.form1;


	var sellist_len= form.photolist.length;
//alert(sellist_len);
	
	var k= form.photolist.selectedIndex;

	var temptxt='';
	var tempval='';
	
	if(form.photolist.selectedIndex>0 && sellist_len>0)
	{
		
		temptxt= form.photolist.options[k-1].text;
		tempval= form.photolist.options[k-1].value;
		
		form.photolist.options[k-1].text=form.photolist.options[k].text;
		form.photolist.options[k-1].value=form.photolist.options[k].value;

		form.photolist.options[k].text= temptxt;
		form.photolist.options[k].value= tempval;



	}

}

function selUpNews()
{
	var form=document.form1;
alert("news");

	var sellist_len= form.newslist.length;
//alert(sellist_len);
	
	var k= form.newslist.selectedIndex;
alert(k);

	var temptxt='';
	var tempval='';
	
	if(form.newslist.selectedIndex>0 && sellist_len>0)
	{
		
		temptxt= form.newslist.options[k-1].text;
		tempval= form.newslist.options[k-1].value;
		
		form.newslist.options[k-1].text=form.newslist.options[k].text;
		form.newslist.options[k-1].value=form.newslist.options[k].value;

		form.newslist.options[k].text= temptxt;
		form.newslist.options[k].value= tempval;

	}

}

function selDown()
{
	var form=document.form1;


	var sellist_len= form.photolist.length;
//	alert(sellist_len);
	
	var k= form.photolist.selectedIndex;

	var temptxt='';
	var tempval='';
//	alert(temptxt);
	if(form.photolist.selectedIndex< (sellist_len-1) && sellist_len>0)
	{
		
		temptxt= form.photolist.options[k+1].text;
		tempval= form.photolist.options[k+1].value;
	
		form.photolist.options[k+1].text=form.photolist.options[k].text;
		form.photolist.options[k+1].value=form.photolist.options[k].value;

		form.photolist.options[k].text= temptxt;
		form.photolist.options[k].value= tempval;



	}

}

function selDownNews()
{
	var form=document.form1;

	var sellist_len= form.newslist.length;
//	alert(sellist_len);
	
	var k= form.newslist.selectedIndex;

	var temptxt='';
	var tempval='';
//	alert(temptxt);
	if(form.newslist.selectedIndex< (sellist_len-1) && sellist_len>0)
	{
		
		temptxt= form.newslist.options[k+1].text;
		tempval= form.newslist.options[k+1].value;
	
		form.newslist.options[k+1].text=form.newslist.options[k].text;
		form.newslist.options[k+1].value=form.newslist.options[k].value;

		form.newslist.options[k].text= temptxt;
		form.newslist.options[k].value= tempval;

	}
}




function checkMail()
{ 
	form=document.mail;
	
	if(form.to.value=='')
	{
		alert("To email field is empty");
		form.to.focus();
		return false;
	}
	if(form.file_text.value=='')
	{
		alert("Message field is empty");
		form.file_text.focus();
		return false;
	}

	if(form.subject.value=='')
	{
		alert("Please enter a subject for the message");
		form.subject.focus();
		return false;
	}
	
	if(form.to.value.indexOf('@',0)==-1 || form.to.value.indexOf('.',0)==-1)
	{
		alert("Please enter a valid email-id in To field.");
		form.to.focus();
		form.to.select();
		return false;
	}

	if(form.cc.value)
	{
		if(form.cc.value.indexOf('@',0)==-1 || form.cc.value.indexOf('.',0)==-1)
		{
			alert("Please enter a valid email-id in Cc field.");
			form.cc.focus();
			form.cc.select();
			return false;
		}
	}
}





//******************************** sponsors


function selUpSpon()
{
	var form=document.form1;


	var sellist_len= form.sponsorlist.length;
//	alert(sellist_len);
	
	var k= form.sponsorlist.selectedIndex;

	var temptxt='';
	var tempval='';
	
	if(form.sponsorlist.selectedIndex>0 && sellist_len>0)
	{
		
		temptxt= form.sponsorlist.options[k-1].text;
		tempval= form.sponsorlist.options[k-1].value;
		
		form.sponsorlist.options[k-1].text=form.sponsorlist.options[k].text;
		form.sponsorlist.options[k-1].value=form.sponsorlist.options[k].value;

		form.sponsorlist.options[k].text= temptxt;
		form.sponsorlist.options[k].value= tempval;



	}

}

function selDownSpon()
{
	var form=document.form1;

	var sellist_len= form.sponsorlist.length;
//	alert(sellist_len);
	
	var k= form.sponsorlist.selectedIndex;

	var temptxt='';
	var tempval='';
//	alert(temptxt);
	if(form.sponsorlist.value)
	{
		if(form.sponsorlist.selectedIndex< (sellist_len-1) && sellist_len>0)
		{
			
			temptxt= form.sponsorlist.options[k+1].text;
			tempval= form.sponsorlist.options[k+1].value;
		
			form.sponsorlist.options[k+1].text=form.sponsorlist.options[k].text;
			form.sponsorlist.options[k+1].value=form.sponsorlist.options[k].value;

			form.sponsorlist.options[k].text= temptxt;
			form.sponsorlist.options[k].value= tempval;



		}
	}
}




function selAddSpon()
{
	var form=document.form1;


	var sellist_len= form.sponsorlist.length;

	if (sellist_len >= parseInt(form.total_spons.value))
	{
		alert("You can display only "+sellist_len+" sponsorgraph(s).");
		return false;
	}

//	alert(sellist_len);
	
	if(form.sponsor.value)
	{
		form.sponsorlist.length=sellist_len+1;
		
		var i = form.sponsor.selectedIndex
		form.sponsorlist.options[sellist_len].text=form.sponsor.options[i].text;
		form.sponsorlist.options[sellist_len].value=form.sponsor.value;
		
		form.sponsor.options[i].text="";
		form.sponsor.options[i].value="";

		for(var x=i;x<(form.sponsor.length-1);x++)
		{
			form.sponsor.options[x].text=form.sponsor.options[x+1].text;
			form.sponsor.options[x].value= form.sponsor.options[x+1].value;

		}
		form.sponsor.options[x].text="";
		form.sponsor.options[x].value="";

		form.sponsor.length--; 
	}

}

function selDelSpon()
{
	var form=document.form1;


	var sellist_len= form.sponsor.length;
//	alert(sellist_len);
	
	if(form.sponsorlist.value)
	{
		form.sponsor.length=sellist_len+1;
		
		var i = form.sponsorlist.selectedIndex
		form.sponsor.options[sellist_len].text=form.sponsorlist.options[i].text;
		form.sponsor.options[sellist_len].value=form.sponsorlist.value;
		
		form.sponsorlist.options[i].text="";
		form.sponsorlist.options[i].value="";

		for(var x=i;x<(form.sponsorlist.length-1);x++)
		{
			form.sponsorlist.options[x].text=form.sponsorlist.options[x+1].text;
			form.sponsorlist.options[x].value= form.sponsorlist.options[x+1].value;

		}
		form.sponsorlist.options[x].text="";
		form.sponsorlist.options[x].value="";

		form.sponsorlist.length--;
	}

}
//*********************************



function chkNews()
{
	
 form=document.form1;

	if(form.headline.value=="")
	{
		alert("Headline field is compulsary");
		form.headline.focus();
		return false;
	}

/*	if(form.cat(0).checked==true && form.day.selectedIndex==0)
	{
		alert("Select the day of the week");
		form.day.focus();
		return false;

	}
*/
	if(form.link.value=='http://')
	{
		form.link.value="";
	}




}

function chkNewsletter()
{
	
 form=document.form1;

	if(form.calendar.value<=Date())
	{
		alert("Date should be greater than todays date. Check date");
		form.calendar.focus();
		return false;
	}

/*	if(form.cat(0).checked==true && form.day.selectedIndex==0)
	{
		alert("Select the day of the week");
		form.day.focus();
		return false;

	}
*/
	if(form.link.value=='http://')
	{
		form.link.value="";
	}




}



//********** STOP PRESS *************
function selDownStop()
{
	var form=document.form1;

	var sellist_len= form.stoppress.length;
//	alert(sellist_len);
	
	var k= form.stoppress.selectedIndex;

	var temptxt='';
	var tempval='';
//	alert(temptxt);
	if(form.stoppress.value)
	{

		if(form.stoppress.selectedIndex< (sellist_len-1) && sellist_len>0)
		{
			
			temptxt= form.stoppress.options[k+1].text;
			tempval= form.stoppress.options[k+1].value;
		
			form.stoppress.options[k+1].text=form.stoppress.options[k].text;
			form.stoppress.options[k+1].value=form.stoppress.options[k].value;

			form.stoppress.options[k].text= temptxt;
			form.stoppress.options[k].value= tempval;



		}
	}
}



function selUpStop()
{
	var form=document.form1;


	var sellist_len= form.stoppress.length;
//	alert(sellist_len);
	
	var k= form.stoppress.selectedIndex;

	var temptxt='';
	var tempval='';
	
	if(form.stoppress.selectedIndex>0 && sellist_len>0 && form.stoppress.value!="")
	{
		
		temptxt= form.stoppress.options[k-1].text;
		tempval= form.stoppress.options[k-1].value;
		
		form.stoppress.options[k-1].text=form.stoppress.options[k].text;
		form.stoppress.options[k-1].value=form.stoppress.options[k].value;

		form.stoppress.options[k].text= temptxt;
		form.stoppress.options[k].value= tempval;



	}

}


function chkSponsor()
{
	var form= document.photo;

	if(form.heading.value=="")
	{
		alert ('Enter Heading');
		form.heading.focus();
		return false;

	}
	
	if (form.photo.value=="Y")
	{
		/*if(form.body.value && !form.remove.checked)
		{
			alert("You cannot add both photograph and the text.\n If you want to remove the photograph select the check box" );
			form.remove.focus();
			return false;

		}

		
	//alert(form.body.value+ "  " +form.remove.checked);

		if(form.body.value=='' && form.remove.checked)
		{
			alert("To remove the present photograph you have to enter the text" );
			form.body.focus();
			return false;

		}
*/
	}

	if(form.cat.value!="S")
	{
		alert ('Enter Text');
		form.body.focus();
		return false;

	}




	if(form.link.value=="http://")
	{
		form.link.value="";


	}


}


function check()

{

	if(document.form1.email.value.indexOf('@',0)==-1 || document.form1.email.value.indexOf('.',0)==-1 )
	{

		alert("Enter a valid email ID");

		document.form1.email.focus();

		return false;

	}



	return true;

}