var verifyval=false;
messageObj = new DHTML_modalMessage();	// We only create one object of this class
messageObj.setShadowOffset(5);	// Large shadow

///////////start div pop up
isIE  = document.all;
isNN  =! document.all && document.getElementById; 
isN4  = document.layers;
isHot = false;
function ddInit(e){
  whichDog = isIE ? document.all.theLayer : document.getElementById("theLayer");  
}
function hideMe(){
  if (isIE||isNN) whichDog.style.visibility="hidden";
  else if (isN4) document.theLayer.visibility="hide";
}
function showMe(){
  window.scroll(0,0);
  if (isIE||isNN) whichDog.style.visibility="visible";
  else if (isN4) document.theLayer.visibility="show";
}
document.onmousedown=ddInit;

function displayMessage(url)
{
	window.scroll(0,0);
	messageObj.setSource(url);
	messageObj.setCssClassMessageBox(false);
	messageObj.setSize(400,200);
	messageObj.setShadowDivVisible(true);	// Enable shadow for these boxes
	messageObj.display();
}

function displayStaticMessage(messageContent,cssClass)
{
	messageObj.setHtmlContent(messageContent);
	messageObj.setSize(300,150);
	messageObj.setCssClassMessageBox(cssClass);
	messageObj.setSource(false);	// no html source since we want to use a static message here.
	messageObj.setShadowDivVisible(false);	// Disable shadow for these boxes	
	messageObj.display();
	//alert('hello');
}
function displayPopupMessage(messageContent,cssClass,width,height)
{
	window.scroll(0,0);
	messageObj.setHtmlContent(messageContent);
	messageObj.setSize(width,height);
	messageObj.setCssClassMessageBox(cssClass);
	messageObj.setSource(false);	// no html source since we want to use a static message here.
	messageObj.setShadowDivVisible(false);	// Disable shadow for these boxes	
	messageObj.display();
}

function closeMessage()
{
	messageObj.close();	

}
//popup
function windowpopup(url,width,height){
newwindow=window.open(url,'name','height='+height+',width='+width+',left=100,top=200,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus()}
}
function popWin(urllink){
	document.getElementById("universitywin").innerHTML="";
	var newwindow=window.open("universitypopup.php?showpage="+urllink,'name','height=580,width=800,left=100,top=200,resizable=no,scrollbars=no,directories=no,fullscreen=no,status=no,titlebar=no,toolbar=no');
	if (window.focus) {newwindow.focus()}
}
function popup(url,width,height)
{
/*	newwindow=window.open(url,'name','height='+height+',width='+width+',left=100,top=200,resizable=yes,scrollbars=yes');
	if (window.focus) {newwindow.focus()}*/
//alert(url);
//	displayMessage(url);
  ajaxSendRequest(url+'&width='+width+'&height='+height,ajaxUpdateContentMulti,true,'ajaxManager',false);

	//return newwindow;
}

// functions for auto suggestion textbox
// div based popup function

// end div based popup function

function initstate(xml) { 
/*document.getElementById("txtcity").value='';
document.getElementById("txtcity").disabled=true;
document.getElementById("txtschool").value='';
document.getElementById("txtschool").disabled=true;*/
	func='getcity()';
 var oTextbox = new AutoSuggestControl(document.getElementById("txtstate"), new StateSuggestions(xml),func); 
 }
function initcity(xml) { 
document.getElementById("txtcity").value='';
document.getElementById("txtcity").disabled=false;
document.getElementById("txtschool").value='';
document.getElementById("txtschool").disabled=true;
	func='getschool()';
  var oTextbox = new AutoSuggestControl(document.getElementById("txtcity"), new StateSuggestions(xml),func); 
document.getElementById("txtcity").focus();
            }
function initschool(xml) { 
document.getElementById("txtschool").value='';
document.getElementById("txtschool").disabled=false;

	func="0";
  var oTextbox = new AutoSuggestControl(document.getElementById("txtschool"), new StateSuggestions(xml),func); 
document.getElementById("txtschool").focus();				
 }


function findinst(){
		var options_xml = {
		script:"includes/auto_suggest.php?suggest=college&",
		varname:"input",
		callback: function (obj) { 
			document.getElementById('AddSchoolId').value = obj.id; 
			}
	};
	var as_xml = new AutoSuggest('AddSchoolName', options_xml);
}
function editfindinst(id){
		var options_xml = {
		script:"includes/auto_suggest.php?suggest=college&",
		varname:"input",
		callback: function (obj) { 
			document.getElementById('EditSchoolId'+id).value = obj.id; 
			}
	};

	var as_xml = new AutoSuggest('EditSchoolName'+id, options_xml);
}
// end auto suggestion textbox

////////////////////////////////////////////////////////////////////////////////////////drag and drop
function initdrop(numbox,numfolder){
var dragDropObj = new DHTMLgoodies_dragDrop();
var msg='';
if(numbox>0)
{
for(var i=1; i <= numbox; i++) { 
 boxname='box'+i;
 dragDropObj.addSource(boxname,true);	// Make <div id="box1"> dragable. slide item back into original position after drop
 }
}
for(var i=1; i <= numfolder; i++) { 
 boxname='dropBox'+i;
  dragDropObj.addTarget(boxname,'dropItems');	// Set <div id="dropBox"> as a drop target. Call function dropItems on drop
 }
dragDropObj.init();
}
// Custom drop actions for <div id="dropBox">
function dropItems(idOfDraggedItem,targetId,x,y)
{
	var html = document.getElementById('dropContent').innerHTML;
	if(html.length>0)html = html + '<br>';
	html = html + 'Item with id="' + idOfDraggedItem+'" dropped'+ document.getElementById('my'+idOfDraggedItem).value+'target:'+targetId;
	instid=document.getElementById('my'+idOfDraggedItem).value;
	folderid='my'+targetId;
	folderval=document.getElementById(folderid).value;
//	document.getElementById('targetId').className="highlight";
//	document.getElementById('dropContent').innerHTML = html+':'+folderid+':'+folderval;
//	alert('page=useraction&ajaxAction=savefoldercont&instid='+instid+'&folderid='+folderval);
    ajaxSendRequest('page=useraction&ajaxAction=savefoldercont&instid='+instid+'&folderid='+folderval,ajaxUpdateContentMulti,true,'ajaxManager');
}

// Custom drop actions for <div id="dropBox2">

function dropItems2(idOfDraggedItem,targetId,x,y)
{
	var html = document.getElementById('dropContent2').innerHTML;
	if(html.length>0)html = html + '<br>';
	html = html + 'Item "' + document.getElementById(idOfDraggedItem).innerHTML + '" dropped';
	document.getElementById('dropContent2').innerHTML = html;
}

////////////////////////////////////////////////////////////////////////////////////////drag and drop end 
//after user login to confirm
var placeHolderDiv;
var url = 'ajax_manager.php';
var debug = true;
var ajaxRequester = new Requester();

function ajaxManagerInit() {
	if(ajaxRequester.isAvailable()) 
		ajaxRefresh(true);
}

function getElement(id) {
	return document.getElementById(id);
}

function getDropDownValue(id) {
	return getElement(id).value;
}

function getValue(id) {
	return getElement(id).value;
}
//-----------------------------------------------------------------<<common function
//function for find the blank space
function IsBlank(s)
{
	var len=s.length;
	  for(i=0;i<len;i++)
	  {
		if(s.charAt(i)!=" ")
		{return false}
	  }
return true
}
function getKeyCode(evt){
	 var charCode = (evt.which) ? evt.which : event.keyCode;
	 return charCode;	
}
//to check whether numeric
function isNotNumeric(s)
{
	if(isNaN(s))
	{
		return(true);
	}
	return(false);
}
//function to check mail
function validEmail(em)
{
  if (em=='')
    return false;
  var emMax=em.length-1;
  var emAt=em.indexOf('@');
  if ((emAt<=0)||(emAt>=emMax))
    return false;
  emAt++;
  var emDot=em.indexOf('.',emAt);
  if ((emDot<0)||(emAt==emDot)||(emDot>=emMax))
    return false;
  return true;
}
//function to set visibility of div
function showdiv_action(divId,action){
if(action==0){
document.getElementById(divId).style.display="none";
}else if(action==1){
document.getElementById(divId).style.display="block";
}

}
//**********function for checking us phone format

function reformat (s)

{   var arg;
    var sPos = 0;
    var resultString = "";

    for (var i = 1; i < reformat.arguments.length; i++) {
       arg = reformat.arguments[i];
       if (i % 2 == 1) resultString += arg;
       else {
           resultString += s.substring(sPos, sPos + arg);
           sPos += arg;
       }
    }
    return resultString;
}

function reformatUSPhone (USPhone)
{   return (reformat (USPhone, "(", 3, ")-", 3, "-", 4))
}

function isInteger (s)

{   var i;

    if ((s == null) || (s.length == 0)) 
       if (isInteger.arguments.length == 1) return false;
       else return (isInteger.arguments[1] == true);

    // Search through string's characters one by one
    // until we find a non-numeric character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);

        if (!((c >= "0") && (c <= "9"))) return false;
    }

    // All characters are numbers.
    return true;
}

// isUSPhoneNumber (STRING s [, BOOLEAN emptyOK])
// 
// isUSPhoneNumber returns true if string s is a valid U.S. Phone
// Number.  Must be 10 digits.
//
// NOTE: Strip out any delimiters (spaces, hyphens, parentheses, etc.)
// from string s before calling this function.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function isUSPhoneNumber (s)
{   if ((s == null) || (s.length == 0)) 
       if (isUSPhoneNumber.arguments.length == 1) return false;
       else return (isUSPhoneNumber.arguments[1] == true);
    return (isInteger(s) && s.length == 10)
}
// checkUSPhone (TEXTFIELD theField [, BOOLEAN emptyOK==false])
//
// Check that string theField.value is a valid US Phone.
//
// For explanation of optional argument emptyOK,
// see comments of function isInteger.

function checkUSPhone (theField, emptyOK){
	var theField = document.getElementById("txtphone");

	if (checkUSPhone.arguments.length == 1) emptyOK = false;
    if ((emptyOK == true) && (isEmpty(theField.value))) return true;
    else
    {  var normalizedPhone = stripCharsInBag(theField.value, "()- ")
       if (!isUSPhoneNumber(normalizedPhone, false)) 
          return warnInvalid (theField, "This field must be a 10 digit U.S. phone number (like 415 555 1212). Please reenter it now.");
       else 
       {  // if you don't want to reformat as (123) 456-789, comment next line out
         theField.value = reformatUSPhone(normalizedPhone)
          return true;
       }
    }
}

// Removes all characters which appear in string bag from string s.

function stripCharsInBag (s, bag)

{   var i;
    var returnString = "";

    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.

    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }

    return returnString;
}

// Notify user that contents of field theField are invalid.
// String s describes expected contents of theField.value.
// Put select theField, pu focus in it, and return false.

function warnInvalid (theField, s)
{   theField.focus()
    theField.select()
    alert(s)
    return false
}

//------------------------------------------------------------------<< Common Stuff
function ajaxSendRequest(requestString,functionName, refresh, target, showloading) {
	var arRequestString = new Array;
	if(showloading==null)
		showloading=true;
	if('' != requestString)
		arRequestString.push(requestString);
	
	if(refresh == false) 
		ajaxRequester.setAction(ajaxEmpty);	
	else 
		ajaxRequester.setAction((((null == functionName) || ('' == functionName)) ? ajaxUpdateContent : functionName));
	
	if(null == target) {
		ajaxRequester.setTarget('ajaxManager');
	}
	else {
		ajaxRequester.setTarget(target);
		arRequestString.push('target='+target);
	}


	//show loading..
  
//	var objBody = document.getElementById(ajaxRequester.getTarget());
  if (target == null)
	var objBody = document.getElementById('ajaxManager');
	else
	var objBody = document.getElementById(target);
	var objOverlayBody = document.getElementById('outerContainerHold');
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','overlay');
	
	objOverlay.style.position = 'absolute';
	objOverlay.style.textAlign = 'center';
	objOverlay.style.verticalAlign = 'middle';
	objOverlay.style.width = objOverlayBody.clientWidth;
	objOverlay.style.height = objOverlayBody.clientHeight;
	objOverlay.style.zIndex = 99999;
	objOverlay.style.left=0;
	objOverlay.style.top=0;
		objOverlay.style.filter = 'alpha(opacity=50)';
		objOverlay.style.opacity = 0.5;
		objOverlay.style.backgroundColor="#DEDDFB";
	objOverlayBody.insertBefore(objOverlay, objOverlayBody.firstChild);
	objOverlay.style.display = 'block';
	//height='+objOverlayBody.clientHeight
if(showloading){
    document.getElementById("overlay").innerHTML = '<table  width='+screen.width+' height=750  border=0 ><tr><td align="center" valign="top"><img src="images/loading.gif">Loading...</td></tr></table>';
	window.scroll(0,0);
	}
  //eof show loading
/*msg='';
var divss= objOverlayBody.getElementsByTagName('DIV');
		for(var no=0;no<divss.length;no++){
			msg=msg+no+':'+divss[no].id+':::::::'+divss[no].innerHTML+'\n';
		}
alert(msg);
*/
//return;
	requestString = arRequestString.join('&');
	ajaxRequester.loadURL(url, requestString);

	return false;
}

function ajaxEmpty(){}

function ajaxReportError(request) {
	alertjs('Sorry. There was an error.');
}



function ajaxUpdateContent(id) {
//alert('ind'+ajaxRequester.getText());
	getElement(ajaxRequester.getTarget()).innerHTML = ajaxRequester.getText();

	var objOverlay = document.getElementById('overlay');
	objOverlay.style.display = 'none';

}

function ajaxUpdateContentMulti(id) {
	var result = ajaxRequester.getText();
//	alert('multi'+result);
	//alertjs('multi'+result);
//getElement('output').innerHTML = result;
	//split string with </divresult> word
	arr = result.split('</divresult>');	
	
	for (i=0; i<arr.length; i++) {
	  try {
	    //get div name
	    regexp = /<divresult name=\"(\w+)\">/;
	    var divelement = arr[i].match(regexp)[1];
      //get div content
	    var divresult = arr[i].replace(regexp,"") ;
		if(divelement=='alertjs') alertjs(divresult); // for  alert
		else if(divelement=='runjs') { eval(divresult); }// for  run
		else if(divelement=='messagejs') { messagejs(divresult); }// for  run
		else if(divelement=='edtEventShowJs') { edtEventShowJs(divresult); }// for  run
		else if(divelement=='showpopup') { popupjs(divresult); }// for  run
		else {  getElement(divelement).innerHTML = divresult; } // alert(divelement+":  "+divresult); 
	  }
	  catch (error) {}    
	}
	var objOverlayBody = document.getElementById('innerContainer');
	var objOverlay = document.getElementById('overlay');
	objOverlay.style.display = 'none';
}

//------------------------------------------------------------------<< page Actions
//contenttype='ajaxUpdateContentMulti';
function alertjs(message){
displayStaticMessage('<div class="alertBoxHolder"><div class="alertBox"><div class="alertBoxLt"><img src="images/alertCurveLeft.gif" alt="" border="0" /></div> <div class="alertBoxMid"><div class="alertTopTitle"><img src="images/alert.gif" alt="" border="0" align="top"/> Alert</div>    </div> <div class="alertBoxLt"><img src="images/alertCurveRight.gif" alt="" border="0" /></div>  </div>  <div class="alertBoxWorkBox"> <strong>'+message+'</strong> </div><div class="alertBoxBtn"> <div class="okButtonHoldInnerSingl"> <div class="okButtonHold"><div class="okButton"><a href="#"  onclick=\'closeMessage();return false\' id="okButton">OK</a></div><br /><br />   </div>   </div>  </div>    </div>   </div>                                           ',false);

/*
displayStaticMessage('<div class="alertTop"><div class="crossLt">Alert</div><div class="cross"></div></div><div class="alertNormalText">'+message+'</div><div class="okButtonHold"><div class="okButton"><a href="#"  onclick=\'closeMessage();return false\' id="okButton">OK</a></div></div>',false);*/
document.getElementById("okButton").focus();
}
function messagejs(message){
displayStaticMessage('<div class="alertBoxHolder"><div class="alertBox"><div class="alertBoxLt"><img src="images/alertCurveLeft.gif" alt="" border="0" /></div> <div class="alertBoxMid"><div class="alertTopTitle"><img src="images/massage.gif" alt="" border="0" align="top"/> Alert</div>     </div> <div class="alertBoxLt"><img src="images/alertCurveRight.gif" alt="" border="0" /></div>  </div>  <div class="alertBoxWorkBox"> <strong>'+message+' </strong><br /></div><div class="alertBoxBtn"> <div class="okButtonHoldInnerSingl"> <div class="okButtonHold"><div class="okButton"><a href="#"  onclick=\'closeMessage();return false\' id="okButton">OK</a></div><br /><br />   </div>   </div>   </div>    </div>   </div>  ',false);
/*
displayStaticMessage('<div class="alertTop"><div class="crossLt">Message</div><div class="cross"></div></div><div class="alertNormalText">'+message+'</div><div class="okButtonHold"><div class="okButton"><a href="#"  onclick=\'closeMessage();return false\' id="okButton">OK</a></div></div>',false);*/
document.getElementById("okButton").focus();
}
function popupjs(message){
	var width='';	var height='';	var content='';

	arrpopup = message.split('</divlength>');	
	
	for (var i=0; i<arrpopup.length; i++) {
	  try {
	    //get div name
	    regexppopup = /<divlength name=\"(\w+)\">/;
	    var divelementpopup = arrpopup[i].match(regexppopup)[1];
      //get div content
	    var divresult = arrpopup[i].replace(regexppopup,"") ;
		if(divelementpopup=='width') { width=divresult; }
		else if(divelementpopup=='height') { height=divresult; }// for  run
		else if(divelementpopup=='content') { content=divresult; }// for  run
	  }
	  catch (error) {}    
	}

/*displayPopupMessage('<div><a href="#" onclick=\'closeMessage();return false\'><img src="images/cross.gif" border="0" alt="" title="Close"/></a>'+content+'</div>',false,width,height);*/
/*displayPopupMessage('<div class="alertTop"><div class="crossLt">ApplyU </div><div class="cross"><a href="#" onclick=\'closeMessage();return false\'><img src="images/cross.gif" border="0" alt="" title="Close"/></a></div></div><div class="alertNormalText">'+content+'</div>',false,width,height);
*/
displayPopupMessage('<div class="alertBoxHolderB" ><ul><li style="width:100%; background-color:#2a5a8f; height:20px;"><div class="alertBoxLt"><img src="images/alertCurveLeftbg.gif" alt="" border="0" /></div><div class="alertTopTitle">ApplyU</div><div class="alertTopTitleRt"><!--<a href="#" onclick=\'closeMessage();return false\'><img src="images/close_btn.gif" alt="" border="0" /></a>--></div></li><li style="background-color:#ffffff; width:99.8%;  border-left:1px solid #2a5a8f; border-right:1px solid #2a5a8f;"><div class="alertBoxWorkBoxB">  <br />'+content+' </div></li><li style="background-color:#ffffff; width:99.8%;  border-left:1px solid #2a5a8f; border-right:1px solid #2a5a8f;">  </li> <li style="width:100%; background-color:#2a5a8f; height:20px;"> <img src="images/poprtbot.gif" alt="" border="0" align="right"/></li> </ul> </div>',false,width,height);
}
function confirmjs(message,verify){
displayStaticMessage('<div class="alertBoxHolder">     <div class="alertBox">     <div class="alertBoxLt"><img src="images/alertCurveLeft.gif" alt="" border="0" /></div>     <div class="alertBoxMid"><div class="alertTopTitle"><img src="images/confirmation.gif" alt="" border="0" align="top"/> Confirmation</div>        </div>     <div class="alertBoxLt"><img src="images/alertCurveRight.gif" alt="" border="0" /></div>   </div>     <div class="alertBoxWorkBox">   <strong>'+message+'</strong><br />  </div><div class="alertBoxBtn">  <div class="okButtonHoldInner">  <div class="okButtonHold"><div class="okButton"><a href="#"  onclick=\'closeMessage();'+verify+'(true);\' id="yesButton">YES</a></div> <div class="okButton"><a href="#"  onclick=\'closeMessage();'+verify+'(false);\'>NO</a></div><br /><br />    </div>    </div>    </div>     </div>  ',false);

/*displayStaticMessage('<div class="alertTop"><div class="crossLt">Confirmation</div><div class="cross"></div></div><div class="alertNormalText">'+message+'</div><div class="okButtonHold"><div class="okButton"><a href="#"  onclick=\'closeMessage();'+verify+'(true);\' id="yesButton">YES</a><a href="#"  onclick=\'closeMessage();'+verify+'(false);\'>NO</a></div></div>',false);*/
document.getElementById("yesButton").focus();
}

function loginuser(){ //USER LOGIN
	//alert(document.frmlogin.txtemail.value);
	var login_email_address = document.frmlogin.txtemail.value;
	var login_password = document.frmlogin.txtpassword.value;
	var chkremember=document.frmlogin.chkremember.checked;
	//alert(chkremember);
//	alert('ajaxAction=PerformLogin&email_address='+login_email_address+'&password='+login_password)
if(login_email_address!=''&&login_password!=''){
  ajaxSendRequest('page=useraction&ajaxAction=loginuser&email_address='+login_email_address+'&password='+login_password+'&chkremember='+chkremember,ajaxUpdateContentMulti,true,'ajaxManager');
//  ajaxSendRequest('page=useraction&ajaxAction=loginuser&email_address='+login_email_address+'&password='+login_password,'',true,'ajaxManager');
}
else{
 alertjs('Please enter email address and password');
}  
  
}
function invite(){
	var invite_email_address = document.frminvite.txtinviteemail.value;
if(invite_email_address!='' && validEmail(invite_email_address)){
 ajaxSendRequest('page=useraction&ajaxAction=inviteuser&invite_email_address='+invite_email_address,ajaxUpdateContentMulti,true,'ajaxManager');
}else{
 alertjs('Please enter your email address');
 document.frmlogin.txtinviteemail.focus();
}
}
function callshowpage(page){ //LOAD PAGE
  ajaxSendRequest('page=useraction&ajaxAction=loadpage&mypage='+page,ajaxUpdateContentMulti,true,'ajaxManager',true);
}

function showpage(page){ //LOAD PAGE
if(page=='searchpage')
	window.location.href='index.php?task=search';
else if(page=='homepage')
	window.location.href='index.php';
else
  ajaxSendRequest('page=useraction&ajaxAction=loadpage&mypage='+page,ajaxUpdateContentMulti,true,'ajaxManager');
// ajaxSendRequest('page=useraction&ajaxAction=loadpage&mypage='+page,'',true,'ajaxManager');
// alert('page=useraction&ajaxAction=loadpage&mypage='+page);
}
function showstaticapage(page){ //SHOW STATIC PAGE
  ajaxSendRequest('page=useraction&ajaxAction=showstaticapage&staticpage='+page,ajaxUpdateContentMulti,true,'ajaxManager');
}

function verifylogout(ver){
if(ver){
	ajaxSendRequest('page=useraction&ajaxAction=logout',ajaxUpdateContentMulti,true,'ajaxManager');
	}
}
function logout(){
 ajaxSendRequest('page=useraction&ajaxAction=logout',ajaxUpdateContentMulti,true,'ajaxManager');
//confirmjs('Do you really wants to logout','verifylogout');
}
//--------------------------------------------------------------------------
function registrationpage(){//registrationpage
//--------------------------------------------------------------------------
	var fname 		= document.frmregistration.txtfname.value;
	var mname 		= document.frmregistration.txtmname.value;
	var lname 		= document.frmregistration.txtlname.value;
	var email 		= document.frmregistration.txtemail.value;
	var cemail 		= document.frmregistration.txtcemail.value;
	var password 	= document.frmregistration.txtpassword.value;
	var cpassword 	= document.frmregistration.txtcpassword.value;
	var state		= document.frmregistration.txtstate.value;
	var city		= document.frmregistration.txtcity.value;
	var school		= document.frmregistration.txtschool.value;
	var gryear		= document.frmregistration.txtgryear.value;
		 if(IsBlank(fname)||IsBlank(lname)||IsBlank(email)||IsBlank(cemail)||IsBlank(password)||IsBlank(cpassword)||IsBlank(state)) 
			 alertjs('Please fill all necessary fields');
		 /* else if(email!=cemail)
			 alert('email does not match');
		  else if(!validEmail(email))
			  alert('Your e-mail address appears to be invalid; please correct it.\n');
		  else if(password!=cpassword)
			 alert('password does not match');*/
		  else	ajaxSendRequest('page=useraction&ajaxAction=reguser&fname='+fname+'&mname='+mname+'&lname='+lname+'&email='+email+'&password='+password+'&state='+state+'&city='+city+'&school='+school+'&gryear='+gryear,ajaxUpdateContentMulti,true,'ajaxManager');
}

//--------------------------------------------------------------------------
function validedemail(){//validedemail
//--------------------------------------------------------------------------
	var email 		= document.frmregistration.txtemail.value;
			if(!validEmail(email)){
			  alertjs('Your e-mail address appears to be invalid; please correct it.');
			 document.frmregistration.txtemail.focus();
			}

}
//--------------------------------------------------------------------------
function confirmemail(){//confirmemail
//--------------------------------------------------------------------------
var email 		= document.frmregistration.txtemail.value;
var cemail 		= document.frmregistration.txtcemail.value;
			if(email != cemail){
				//alertjs('email does not match');
				document.getElementById('chkmail').style.display="block";
				document.frmregistration.txtcemail.focus();
			}else{
				document.getElementById('chkmail').style.display="none";			
			}
}
//--------------------------------------------------------------------------
function confirmpassword(){//confirmemail
//--------------------------------------------------------------------------
var password 	= document.frmregistration.txtpassword.value;
var cpassword 	= document.frmregistration.txtcpassword.value;
		if(password!=cpassword){
//			 alertjs('password does not match');
				document.getElementById('chkpassword').style.display="block";
				document.frmregistration.txtcpassword.focus();
		}else{
				document.getElementById('chkpassword').style.display="none";		
		}
}
function validename(){
var fname= document.frmregistration.txtfname.value;
var lname= document.frmregistration.txtlname.value;
	if(IsBlank(fname) || IsBlank(lname)){
		document.getElementById('chkname').style.display="block";		
	}else{
		document.getElementById('chkname').style.display="none";		
	}

}

function forgetpwd(){
	 ajaxSendRequest('page=useraction&ajaxAction=forgetpwd',ajaxUpdateContentMulti,true,'ajaxManager');
}
function sendpwd(){
	var email=document.getElementById('txtforgetemail').value;
	 if(!validEmail(email))
	  alertjs('Your e-mail address appears to be invalid; please correct it.\n');
	 else
	  ajaxSendRequest('page=useraction&ajaxAction=sendpwd&email='+email,ajaxUpdateContentMulti,true,'ajaxManager');
}
function most_viewed(view){
if(view==null) view='icon';
  ajaxSendRequest('page=useraction&ajaxAction=most_viewed&view='+view,ajaxUpdateContentMulti,true,'ajaxManager',false);
}
function recently_viewed(view){
if(view==null) view='icon';
  ajaxSendRequest('page=useraction&ajaxAction=recently_viewed&view='+view,ajaxUpdateContentMulti,true,'ajaxManager',false);
}
//------------------------------Show Search---------------------------------------
function showpagesearch(){
//--------------------------------------------------------------------------------
  ajaxSendRequest('page=useraction&ajaxAction=showpagesearch&history=back',ajaxUpdateContentMulti,true,'ajaxManager');
}
//------------------------------loadgooglemap---------------------------------------
function loadgooglemap(numschool) {
//--------------------------------------------------------------------------------
//document.getElementById('mymsg').innerHTML="latitude:"+latitude+"longintude:"+longintude+"schoolname"+schoolname+"schoollink"+schoollink;
if(numschool>1){
centerlat=37.149582;
centerlong=-96.904215;
zoomlevel=3;
}else{
centerlat=document.getElementById('latitude1').value; 
centerlong=document.getElementById('longitude1').value; 
zoomlevel=13;
}
	  var lat=new Array();
	  var longitude=new Array();
	  var schoolname=new Array();
	  var linkname=new Array();
        for (var i = 1; i <=numschool ; i++) {
		  var latText='latitude'+i; 
		  lat[i]=document.getElementById(latText).value; 
		  var longitudeText='longitude'+i;
		  longitude[i]=document.getElementById(longitudeText).value;
		  var schoolText='schoolname'+i;
		  schoolname[i]=document.getElementById(schoolText).value;
		  var linkText='schoollink'+i;
		  linkname[i]=document.getElementById(linkText).value;
        }
    

	if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GSmallMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(centerlat, centerlong), zoomlevel);

        // Creates a marker at the given point with the given number label
        function createMarker(point, number) {
          var marker = new GMarker(point);
          GEvent.addListener(marker, "click", function() {
			if(numschool>1){
            marker.openInfoWindowHtml('<b><a href="JavaScript:'+linkname[number]+'">' + schoolname[number] + '</a></b>');
			}
          });
          return marker;
        }

        // Add 10 markers to the map at random locations
        var bounds = map.getBounds();
        var southWest = bounds.getSouthWest();
        var northEast = bounds.getNorthEast();
        var lngSpan = northEast.lng() - southWest.lng();
        var latSpan = northEast.lat() - southWest.lat();
		var test;
        for (var i = 1; i <= numschool; i++) {
		  if(lat[i]!='' && longitude[i]!=''){
			  var point = new GLatLng(lat[i],longitude[i]);
			  map.addOverlay(createMarker(point, i));
		  }
        }
			
	}
	
}
//------------------------------history back---------------------------------------
function historyback(){
//--------------------------------------------------------------------------
page='pagestate';
  ajaxSendRequest('page=useraction&ajaxAction=loadpage&mypage='+page+'&history=back',ajaxUpdateContentMulti,true,'ajaxManager');
//  ajaxSendRequest('page=useraction&ajaxAction=historyback',ajaxUpdateContentMulti,true,'ajaxManager');
}
//------------------------------history forward---------------------------------------
function historyforward(){
//--------------------------------------------------------------------------
page='pagestate';
  ajaxSendRequest('page=useraction&ajaxAction=loadpage&mypage='+page+'&history=forward',ajaxUpdateContentMulti,true,'ajaxManager');
}
//------------------------------Find---------------------------------------
function findschool(page,view){
//-------------------------------------------------------------------------
var addurl='';
if(document.frm_search)
	var sh=document.frm_search.elements["txttype[1]"].checked;
//tester();
//alert(sh);
if(document.frm_search) setfindvalues();

var url='page=useraction&ajaxAction=search&refpage='+page;
if(document.frm_search) addurl=getfindurl();
if(!IsBlank(addurl)){
if(!view)			view=document.getElementById('myview').value
if(view)			addurl=addurl+'&view='+view;
url=url+addurl;
//alert(url);
	ajaxSendRequest(url,ajaxUpdateContentMulti,true,'ajaxManager',false);
}
	//'page=useraction&ajaxAction=search&keyword='+keyword+'&refpage='+page
	return false;
}
function tester(){
document.getElementById("tester").innerHTML=document.getElementById("tester").innerHTML+'hello;';
}
function findschoolbykeyword(keyword){
//showpage('searchpage');
var keyword=document.getElementById('searchKeyword').value;
findschoolbykeyword2(keyword);
}
function findschoolbykeyword2(keyword){
var url='page=useraction&ajaxAction=searchKeyword&refpage=1';
var	addurl='&keyword='+keyword
url=url+addurl;
//alert(url);
	ajaxSendRequest(url,ajaxUpdateContentMulti,true,'ajaxManager',false);
}
function showsearchKeyword(keyword){
if(document.frmsearch){
document.getElementById('txtkeyword').value="";
document.getElementById('txttype_show').innerHTML="any";
document.getElementById('txtmajor_course_show').innerHTML="any";
document.getElementById('txtcompetition_show').innerHTML="any";
document.getElementById('txtinstsize_show').innerHTML="any";
document.getElementById('txtcatscore_show').innerHTML="any";
document.getElementById('txttuitionfees_show').innerHTML="any";
}

	document.getElementById('searchKeyword').value=keyword;
	document.getElementById('txtkeyword').value=keyword;
	//findschool(1);
	//setTimeout('findschool(1)',1000);
}
function showfavorites(){
	ajaxSendRequest('page=useraction&ajaxAction=show_favorites',ajaxUpdateContentMulti,true,'ajaxManager',false);
}
function refinesearch(view){
new Effect.BlindUp('refine1',{duration:1.5});
var keyword=document.getElementById('keyword').value;
var mylocation=document.getElementById('location').value;
var instsize=document.getElementById('instsize').value
var competition=document.getElementById('competition').value;
if(document.getElementById('searchid')) var searchid=document.getElementById('searchid').value;
var type=document.getElementById('type').value;

var url='page=useraction&ajaxAction=refine_search';
addurl=getfindurl();
if(!view)			view=document.getElementById('myview').value
if(view)			addurl=addurl+'&view='+view;
url=url+addurl;

/*if(keyword)			url=url+'&keyword='+keyword; 
if(mylocation!=0)	url=url+'&location='+mylocation;
if(instsize!=0)		url=url+'&instsize='+instsize;
if(competition!=0)	url=url+'&competition='+competition;
if(view)			url=url+'&view='+view;
if(searchid)		url=url+'&searchid='+searchid;
if(type)			url=url+'&type='+type;*/
//  ajaxSendRequest(url,ajaxUpdateContentMulti,true,'ajaxManager',false);
setTimeout("new Effect.BlindDown('refine2',{duration:1.5});",2000);
}
function refinebksearch(view){
new Effect.BlindUp('refine2',{duration:1.5});
/*var keyword=document.getElementById('keyword').value;
var mylocation=document.getElementById('location').value;
var instsize=document.getElementById('instsize').value;
var competition=document.getElementById('competition').value;
if(document.getElementById('searchid')) var searchid=document.getElementById('searchid').value;
var type=document.frmsearch.type.value;
*/
var url='page=useraction&ajaxAction=refinebk_search';
addurl=getfindurl();
if(!view)			view=document.getElementById('myview').value
if(view)			addurl=addurl+'&view='+view;
url=url+addurl;
/*if(keyword)			url=url+'&keyword='+keyword; 
if(mylocation!=0)	url=url+'&location='+mylocation;
if(instsize!=0)		url=url+'&instsize='+instsize;
if(competition!=0)	url=url+'&competition='+competition;
if(view)			url=url+'&view='+view;
if(searchid)		url=url+'&searchid='+searchid;
if(type)			url=url+'&type='+type;
*/
//  ajaxSendRequest(url,ajaxUpdateContentMulti,true,'ajaxManager',false);
setTimeout("new Effect.BlindDown('refine1',{duration:1.5});",2000);
}
//------------------------------Set Find Values---------------------------------------
function setfindvalues(){
//-------------------------------------------------------------------------------------
//keyword
	document.getElementById('keyword').value=document.getElementById('txtkeyword').value;
//type
document.getElementById('type').value='';	
for(i=0;i<=document.getElementById("txttype_length").value;i++){	
if(document.frm_search.elements["txttype["+i+"]"].checked) 
	document.getElementById('type').value=document.getElementById('type').value+document.frm_search.elements["txttype["+i+"]"].value+',';
}
//competition
document.getElementById('competition').value='';	
for(i=0;i<=document.getElementById("txtcompetition_length").value;i++){	
if(document.frm_search.elements["txtcompetition["+i+"]"].checked) 
	document.getElementById('competition').value=document.getElementById('competition').value+document.frm_search.elements["txtcompetition["+i+"]"].value+',';
}
//Academic Programs
document.getElementById('major_course').value='';	
for(i=0;i<=document.getElementById("txtmajor_course_length").value;i++){	
if(document.frm_search.elements["txtmajor_course["+i+"]"].checked) 
	document.getElementById('major_course').value=document.getElementById('major_course').value+document.frm_search.elements["txtmajor_course["+i+"]"].value+',';
}
//instsize
document.getElementById('instsize').value='';	
for(i=0;i<=document.getElementById("txtinstsize_length").value;i++){	
if(document.frm_search.elements["txtinstsize["+i+"]"].checked) 
	document.getElementById('instsize').value=document.getElementById('instsize').value+document.frm_search.elements["txtinstsize["+i+"]"].value+',';
}
//tuition fees
document.getElementById('tuitionfees').value='';	
for(i=0;i<=document.getElementById("txttuitionfees_length").value;i++){	
if(document.frm_search.elements["txttuitionfees["+i+"]"].checked) 
	document.getElementById('tuitionfees').value=document.getElementById('tuitionfees').value+document.frm_search.elements["txttuitionfees["+i+"]"].value+',';
}
// sat/act scores
document.getElementById('catscore').value='';	
for(i=0;i<=document.getElementById("txtcatscore_length").value;i++){	
if(document.frm_search.elements["txtcatscore["+i+"]"].checked) 
	document.getElementById('catscore').value=document.getElementById('catscore').value+document.frm_search.elements["txtcatscore["+i+"]"].value+',';
}


/*if(document.getElementById('txtlocation')){  //location
var objlocation=document.getElementById('txtlocation');
document.getElementById('location').value=objlocation.options[objlocation.selectedIndex].value; }

if(document.getElementById('txtinstsize')){  //instsize
var objinstsize=document.getElementById('txtinstsize');
document.getElementById('instsize').value=objinstsize.options[objinstsize.selectedIndex].value; }

if(document.getElementById('txttuitionfees')){  //tuition fees
var objtuitionfees=document.getElementById('txttuitionfees');
//document.getElementById('tuitionfees').value=objtuitionfees.options[objtuitionfees.selectedIndex].value;
}
//alert(document.getElementById("txttype_length").value);
//alert(document.frm_search.elements["txttype[1]"].checked);*/
}
//------------------------------Get Find URL---------------------------------------
function getfindurl(){
//--------------------------------------------------------------------------
var keyword=document.getElementById('keyword').value;
var mylocation=document.getElementById('location').value;
var instsize=document.getElementById('instsize').value
var type=document.getElementById('type').value;
var competition=document.getElementById('competition').value;
var major_course=document.getElementById('major_course').value;
var catscore=document.getElementById('catscore').value;
/*var initScores=document.getElementById('catScores').value;
var endScores=document.getElementById('endScores').value;*/
var tuitionfees=document.getElementById('tuitionfees').value;
//var tuitionfees=objtuitionfees.options[objtuitionfees.selectedIndex].value;

//refine
//var objrangeloc=document.getElementById('txtrangeloc');
//var rangeloc=objrangeloc.options[objrangeloc.selectedIndex].value;
//var miles=document.getElementById('txtmiles').value;
var rangeloc=''; var miles='';var subjectid=0;
/*var subjectid=document.getElementById('subjectid').value
var catscores=document.getElementById('catScores').value
if(isNotNumeric(document.getElementById('initScores').value)) 
{ 
alert('Please enter valid scores'); 
document.getElementById('initScores').value='';
return; 
}
else var initScores=document.getElementById('initScores').value
if(isNotNumeric(document.getElementById('endScores').value)) 
{ 
alert('Please enter valid scores'); 
document.getElementById('endScores').value='';
return; 
}
else var endScores=document.getElementById('endScores').value
*/
if(document.getElementById('searchid')) var searchid=document.getElementById('searchid').value;
if(document.getElementById('mypage')) var mypage=document.getElementById('mypage').value;
if(document.getElementById('folderid')) var folderid=document.getElementById('folderid').value;

addurl='';
if(keyword) { if(keyword!='Name/Keywords' )	addurl=addurl+'&keyword='+keyword; }
if(mylocation!=0)	addurl=addurl+'&location='+mylocation;
if(instsize!=0)		addurl=addurl+'&instsize='+instsize;
if(competition!=0)	addurl=addurl+'&competition='+competition;
if(major_course!=0)	addurl=addurl+'&major_course='+major_course;
if(catscore!=0)	addurl=addurl+'&catscore='+catscore;
//if(subjectid!=0) 	addurl=addurl+'&subjectid='+subjectid;
if(tuitionfees!=0) 	addurl=addurl+'&tuitionfees='+tuitionfees;

/*if((initScores!=0 && initScores!='')||(endScores!=0 && endScores!=''))
	addurl=addurl+'&initScores='+initScores+'&endScores='+endScores+'&catscores='+catscores;	
*/
if(type && type!=0){	addurl=addurl+'&type='+type; }
if(searchid)		addurl=addurl+'&searchid='+searchid;
if(folderid)		addurl=addurl+'&folderid='+folderid;
if(mypage)			addurl=addurl+'&mypage='+mypage;
if(!IsBlank(rangeloc) && rangeloc!=0  && !IsBlank(miles)){
	if(rangeloc)		addurl=addurl+'&rangeloc='+rangeloc;
	if(miles)			addurl=addurl+'&miles='+miles;
}
//alertjs(addurl);
return addurl;
}
//------------------------------New search on Find--------------------------
function findschool_new(){
//-------------------------------------------------------------------------
if(document.frm_search){
	if(document.getElementById('txtkeyword'))
	document.getElementById('txtkeyword').value="";
document.getElementById('txttype_show').innerHTML="any";
document.getElementById('txtmajor_course_show').innerHTML="any";
document.getElementById('txtcompetition_show').innerHTML="any";
document.getElementById('txtinstsize_show').innerHTML="any";
document.getElementById('txtcatscore_show').innerHTML="any";
document.getElementById('txttuitionfees_show').innerHTML="any";

optSubmit('txttype',document.getElementById('txttype_length').value,0);
optSubmit('txtmajor_course',document.getElementById('txtmajor_course_length').value,0);
optSubmit('txtcompetition',document.getElementById('txtcompetition_length').value,0);
optSubmit('txtinstsize',document.getElementById('txtinstsize_length').value,0);
optSubmit('txtcatscore',document.getElementById('txtcatscore_length').value,0);
optSubmit('txttuitionfees',document.getElementById('txttuitionfees_length').value,0);

document.getElementById('search_msg').innerHTML="";
document.getElementById('paging_msg').innerHTML="";
}
  ajaxSendRequest('page=useraction&ajaxAction=findschool_new',ajaxUpdateContentMulti,true,'ajaxManager',false);
  
}

function findpageschool(id,view,page){
var url='page=useraction&ajaxAction=showsearch&refpage='+page+'&searchid='+id+'&view='+view;
	ajaxSendRequest(url,ajaxUpdateContentMulti,true,'ajaxManager',false);
	//'page=useraction&ajaxAction=search&keyword='+keyword+'&refpage='+page
}


function viewschool(view){
var searchid,mypage,func,folderid;

if(!document.getElementById('searchid')&&!document.getElementById('folderid')&&!document.getElementById('func')) alertjs('Please search to view');
else if(document.getElementById('searchid')){
	searchid=document.getElementById('searchid').value;
	mypage=document.getElementById('mypage').value;
	document.getElementById('myview').value=view
	findpageschool(searchid,view,mypage);
}else if(document.getElementById('folderid')){
	folderid = document.getElementById('folderid').value;
	mypage = document.getElementById('mypage').value;
	document.getElementById('myview').value=view
	showfoldercont(folderid,view,mypage);
}else if(document.getElementById('func')){
	func=document.getElementById('func').value;
	if(func=='recently_viewed')
	recently_viewed(view);
else if(func=='most_viewed')
	most_viewed(view);
}
}
/////////////////////////to close div by id
function closediv(divid){
//alert(document.getElementById(divid).innerHTML);
document.getElementById(divid).innerHTML="";
document.getElementById(divid).className="";
}
//////////////////////////////////to show folder stored by user
function showsearchfolder(){
//	alert('page=useraction&ajaxAction=showsearchfolder');
	  ajaxSendRequest('page=useraction&ajaxAction=showsearchfolder',ajaxUpdateContentMulti,true,'ajaxManager');
}
//////////////////////////////////to save folder
function savefolder(){
foldername=document.frmfolder.txtfoldername.value;
	if(foldername==null || foldername=='')
		alert('Please enter folder name');
	else 
	{
	ajaxSendRequest('page=useraction&ajaxAction=savefolder&foldername='+foldername,ajaxUpdateContentMulti,true,'ajaxManager');
	closeMessage();
	}
}
//////////////////////////////////to save Search
function savesearch(){
searchname=document.frmfolder.txtsearchname.value;
	if(searchname==null || searchname=='')
		alert('Please enter Search name');
	else 
	{
	popup('page=useraction&ajaxAction=savesearch&searchid='+document.getElementById('searchid').value+'&searchname='+searchname);
	closeMessage();
	}
}
////////////////////////show folder content by id
function showfoldercont(folderid,view,page){
	//findschool_new(); 
ajaxSendRequest('page=useraction&ajaxAction=showfoldercont&folderid='+folderid+'&mypage='+page+'&view='+view,ajaxUpdateContentMulti,true,'ajaxManager',false);
}
////////////////////////show search 
function showsearch(id,view){
	 //findschool_new();
	  ajaxSendRequest('page=useraction&ajaxAction=showsearch&searchid='+id+'&view='+view,ajaxUpdateContentMulti,true,'ajaxManager',false);
}
function checktosave(url){
check=true;
if(!document.getElementById('searchid')) check=false
else if(IsBlank(document.getElementById('searchid').value)) check=false
if(check==true){
popup(url);
}else{
alertjs('please search to store');
}
}
function rundeletefolder(){
folderval=document.getElementById('foldername').options[document.getElementById('foldername').selectedIndex].value
confirmjs('really wants to delete','verifydelete');
}
function verifydelete(ver){
if(ver) {
popup('page=useraction&ajaxAction=deletefolder&folderid='+folderval);
closeMessage();
}
}
var instid, divdel;
function deletefoldercont(div,myinstid,instnm){
divdel=div;
instid=myinstid;
confirmjs('Are you sure you want to remove '+instnm+' from your Favorites?','verifyfoldercont');
}
function verifyfoldercont(ver){
if(ver){
folderid=document.getElementById('folderid').value;
  ajaxSendRequest('page=useraction&ajaxAction=deletefoldercont&folderid='+folderid+'&instid='+instid,ajaxUpdateContentMulti,true,'ajaxManager');
closediv(divdel);
}
}

//--------------------------------------------------------------------------
function OrganiseTask(){ //USER LOGIN 
//--------------------------------------------------------------------------
	var login_email_address = document.frmlogin.txtemail.value;
	var login_password = document.frmlogin.txtpassword.value;
	if(login_email_address != '' && login_password != ''){ 
	}
	else{ 
	 alert('Please Login.....');
	}  
  
}
//--------------------------------------------------------------------------
function callFunTask(){ //Fun Task 
//--------------------------------------------------------------------------
	window.location.href='index.php?task=funtask';
}
//--------------------------------------------------------------------------
function FunTask(col_name, sort_order,mypage){ //Fun Task 
//--------------------------------------------------------------------------
	ajaxSendRequest('page=useraction&ajaxAction=FunTaskModule&col_name='+col_name+'&sort_order='+sort_order+'&mypage='+mypage,ajaxUpdateContentMulti,true,'ajaxManager');
}
//--------------------------------------------------------------------------
function ShowSchoolField(){ //Show School Field 
//--------------------------------------------------------------------------
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('school').style.display = 'block'; 

		if (document.getElementById) { // DOM3 = IE5, NS6 
			document.getElementById('school1').style.display = 'none'; 
		} 
	}	
		//ajaxSendRequest('page=useraction&ajaxAction=auto_suggest',ajaxUpdateContentMulti,true,'ajaxManager');
		//ajaxSendRequest('page=auto_suggest',ajaxUpdateContentMulti,true,'ajaxManager');
findinst();
}
//--------------------------------------------------------------------------
function ShowTaskField(){ //Show Task Field 
//--------------------------------------------------------------------------

	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('task').style.display = 'block'; 
		if (document.getElementById) { // DOM3 = IE5, NS6 
			document.getElementById('task1').style.display = 'none'; 
		} 
	}			
}

//--------------------------------------------------------------------------
function ShowDueDateField(){ // Show Due Date Field
//--------------------------------------------------------------------------
	
		if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('dudate').style.display = 'block'; 

		if (document.getElementById) { // DOM3 = IE5, NS6 
			document.getElementById('dudate1').style.display = 'none'; 
		} 
	}	
}

//--------------------------------------------------------------------------
function ShowEditTaskField(id){ // Show Due Date Field
//--------------------------------------------------------------------------
	
		if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('edittask'+id).style.display = 'block'; 

		if (document.getElementById) { // DOM3 = IE5, NS6 
			document.getElementById('edittask1'+id).style.display = 'none'; 
		} 
	}
	editfindinst(id);
}

//--------------------------------------------------------------------------
function FunTaskAddWindow(){//Fun Task Add 
//--------------------------------------------------------------------------

	var Task 		= document.FunTask1.AddschoolTask.value;
	var SchoolName 	= document.FunTask1.AddSchoolId.value;
	var DueDateNew 	= document.FunTask1.DueDateNew.value;
	var funid		= document.FunTask1.funid.value;
	if(IsBlank(Task) || IsBlank(SchoolName)){
	 alert('Please fill all necessary fields');
	}
	else 
	{
		ajaxSendRequest('page=useraction&ajaxAction=FunTaskAddWindow&Priority=&Task='+Task+'&SchoolName='+SchoolName+'&DueDateNew='+DueDateNew+'&AlertUser=&funid='+funid,ajaxUpdateContentMulti,true,'ajaxManager');
	  closeMessage(); 
	}
}
//--------------------------------------------------------------------------
function FunTaskCancelWindow(){ // Fun Task Cancel Window
//--------------------------------------------------------------------------
	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('school').style.display = 'none'; 

		if (document.getElementById) { // DOM3 = IE5, NS6 
			document.getElementById('school1').style.display = 'block'; 
		} 

	}	

	if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('task').style.display = 'none'; 
		if (document.getElementById) { // DOM3 = IE5, NS6 
			document.getElementById('task1').style.display = 'block'; 
		} 
	}			

		if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('dudate').style.display = 'none'; 

		if (document.getElementById) { // DOM3 = IE5, NS6 
			document.getElementById('dudate1').style.display = 'block'; 
		} 
	}	
}
//--------------------------------------------------------------------------
function FunTaskEditCancelWindow(id){ // Fun Task Cancel Window
//--------------------------------------------------------------------------
		if (document.getElementById) { // DOM3 = IE5, NS6 
		document.getElementById('edittask'+id).style.display = 'none'; 

		if (document.getElementById) { // DOM3 = IE5, NS6 
			document.getElementById('edittask1'+id).style.display = 'block'; 
		} 
	}

}
//--------------------------------------------------------------------------
function FunTaskEditSaveWindow(Fid){//Fun Task Edit Save Window 
//--------------------------------------------------------------------------

	var EditPriority 	= document.getElementById('EditPriority'+Fid).value;
	var EditTask 		= document.getElementById('EditOldTask'+Fid).value;
	var EditSchoolName 	= document.getElementById('EditSchoolId'+Fid).value;
	var EditDueDate 	= document.getElementById('EditDueDate'+Fid).value;
	var EditAlert 		= document.getElementById('EditAlert'+Fid).value;
	var Editfunid		= Fid;
	if(IsBlank(EditTask) || IsBlank(EditSchoolName)){
	 alert('Please fill all necessary fields');
	}
	else 
	{
	  ajaxSendRequest('page=useraction&ajaxAction=FunTaskEditSaveWindow&EditPriority='+EditPriority+'&EditTask='+EditTask+'&EditSchoolName='+EditSchoolName+'&EditDueDate='+EditDueDate+'&AlertUser='+EditAlert+'&Editfunid='+Editfunid,ajaxUpdateContentMulti,true,'ajaxManager');
	  closeMessage(); 
	}
}

FunId='';
//--------------------------------Fun Task Delete Window-----------------------------
function FunTaskDeleteWindow(Fid){
//--------------------------------------------------------------------------
	FunId=Fid;
	confirmjs('Are u sure to delete this task','VerifyDeleteTask');
}
//--------------------------------verify delete task-----------------------------
function VerifyDeleteTask(ver){
//--------------------------------------------------------------------------
	if(ver){
		//showmypage=document.getElementById('showmypage').value;
		ajaxSendRequest('page=useraction&ajaxAction=FunTaskDeleteWindow&DeleteTaskId='+FunId,ajaxUpdateContentMulti,true,'ajaxManager');
	}
}


//----------------------------------
function OrganiseTaskForLoginUser(){ //Organise Task For Login User  
//----------------------------------
window.location.href='index.php?task=organise';
}
//----------------------------------
function callOrganiseTaskForLoginUser(){ //Organise Task For Login User  
//----------------------------------
		ajaxSendRequest('page=useraction&ajaxAction=Organise',ajaxUpdateContentMulti,true,'ajaxManager');
}
//--------------------------------------------------------------------------
function FunTaskModuleForPriority(ID,FunID){ //Fun Task Module For Priority  
//--------------------------------------------------------------------------
			var Funid =ID;
			if(Funid == 4){
				ID = 2;
			}if(Funid == 2){
				ID = 3;
			}if(Funid == 3){
				ID =4;
			}
		ajaxSendRequest('page=useraction&ajaxAction=FunTaskModuleForPriority&PriorityValue='+ID+'&FunID='+FunID,'',true,'ajaxManager');
}
//--------------------------------------------------------------------------
function AlertTaskPopUp(pid,fid){ //AlertTaskPopUp   
//--------------------------------------------------------------------------
	popup('page=useraction&ajaxAction=showpopup&popuppage=handlealert&fid='+fid+'&pid='+pid,300,300);
//		window.open('./includes/classes/alert_pop_up.php?fid='+fid+'&pid='+pid,'','directories=no,fullscreen=no,height=180,width=400,left=300,location=no,menubar=no,resizable=no,scrollbars=no,status=no,titlebar=no,toolbar=no,top=300');
}
//--------------------------------------------------------------------------
function scholarhip(){ //scholarship page
//--------------------------------------------------------------------------
window.location.href='index.php?task=scholarship';
}
//--------------------------------------------------------------------------
function showScholarship(){ //show scholarship
//--------------------------------------------------------------------------
ajaxSendRequest('page=useraction&ajaxAction=scholarship',ajaxUpdateContentMulti,true,'ajaxManager');
}
//--------------------------------------------------------------------------
function apply_scholarship(scholarship_id){ //show scholarship
//--------------------------------------------------------------------------
ajaxSendRequest('page=useraction&ajaxAction=apply_scholarship&scholarship_id='+scholarship_id,ajaxUpdateContentMulti,true,'ajaxManager');
}
//--------------------------------------------------------------------------
function studentnote(){ //My Notes  
//--------------------------------------------------------------------------
window.location.href='index.php?task=mynotes';
}
//--------------------------------------------------------------------------
function MyNote(col_name,sort_order,school_page,showmypage){ //My Notes  
//--------------------------------------------------------------------------
	  var col_name, sort_order,page;
		  if(col_name==null){
			 col_name='post_date';
		  }
		  if(sort_order==null){
			  sort_order='desc';
		  }
		  if(school_page==null){
			  school_page=1;
		  }
		if(showmypage==null){
			if(document.getElementById('showmypage')) showmypage=document.getElementById('showmypage').value;
			else showmypage="mynotes";
		}	
		//ajaxSendRequest('page=useraction&ajaxAction=MyNote&col_name='+col_name+'&sort_order='+sort_order+'&school_page='+school_page+'&showmypage='+showmypage,ajaxUpdateContentMulti,true,'ajaxManager');
if(document.getElementById('unitid'))
	unitid=document.getElementById('unitid').value;
else unitid=0;
ajaxSendRequest('page=useraction&ajaxAction=MyNote&col_name='+col_name+'&sort_order='+sort_order+'&school_page='+school_page+'&showmypage='+showmypage+'&unitid='+unitid,ajaxUpdateContentMulti,true,'ajaxManager');
}

////////////////////////////popout on school profile
function popoutnote(){
document.getElementById("notebookloader").innerHTML="";
document.getElementById("popuplink").innerHTML='<a href="JavaScript:popinnote()" class="popoutlink">Pop In</a>';
windowpopup('alert_pop_up.php?showpage=MyNote',800,300);
}
////////////////////////////popin on school profile
function popinnote(){
var unitid;
	if(document.getElementById("notebookloader").innerHTML==""){
		document.getElementById("popuplink").innerHTML='<a href="JavaScript:popoutnote()" class="popoutlink">Pop Out</a>';
		if(document.getElementById('unitid'))
			unitid=document.getElementById('unitid').value;
		else unitid=0;
		ajaxSendRequest('page=useraction&ajaxAction=popinnote&unitid='+unitid,ajaxUpdateContentMulti,true,'ajaxManager',false);
	}
}
//--------------------------------------------------------------------------
function homepage(){//Home Page
//--------------------------------------------------------------------------
		ajaxSendRequest('page=useraction&ajaxAction=logout',ajaxUpdateContentMulti,true,'ajaxManager');

}

//for pop show hide
//--------------------------------------------------------------------------
function FunTaskPopUpDivWindow(){//Fun Task Pop Up Div Window
//--------------------------------------------------------------------------
	var Priority;
	if(document.FunTasknew.Priority[0].checked)
	Priority=document.FunTasknew.Priority[0].value;
	else if(document.FunTasknew.Priority[1].checked)
	Priority=document.FunTasknew.Priority[1].value;
	else Priority=4;
	var Task 		= document.FunTasknew.Task.value;
	var SchoolName 	= document.FunTasknew.SchoolName.value;
	var DueDateNew 	= document.FunTasknew.DueDateNew.value;
	var funid		= document.FunTasknew.funid.value;
	if(document.FunTasknew.AlertUser.checked) AlertUser=1; else AlertUser=0;
	if(AlertUser){
		if(document.FunTasknew.TypeOfAlertSms.checked){alertsms=1;} else {alertsms=0;}
		if(document.FunTasknew.TypeOfAlertEmail.checked) alertemail=1; else alertemail=0;
		if(document.FunTasknew.TypeOfAlertPopUp.checked) alertpopup=1; else alertpopup=0;
		if(!alertsms && !alertemail && !alertpopup) AlertUser=0;
	
	addurl='&alertsms='+alertsms+'&alertemail='+alertemail+'&alertpopup='+alertpopup;
	} else addurl='';
	if(IsBlank(Task)||IsBlank(DueDateNew))
	 alert('Please fill all necessary fields');
	else
	{
	  //ajaxSendRequest('page=useraction&ajaxAction=FunTaskPopUpDivWindow&Priority='+Priority+'&Task='+Task+'&SchoolName='+SchoolName+'&DueDateNew='+DueDateNew+'&AlertUser='+AlertUser+'&funid='+funid+addurl,'',true,'ajaxManager');
	  ajaxSendRequest('page=useraction&ajaxAction=FunTaskPopUpDivWindow&Priority='+Priority+'&Task='+Task+'&SchoolName='+SchoolName+'&DueDateNew='+DueDateNew+'&AlertUser='+AlertUser+'&funid='+funid+addurl+'&showpage='+showmypage,ajaxUpdateContentMulti,true,'ajaxManager');
	  closeMessage();
	}
}


///function to show text box added by keshav
//-----------------------------Show MyNote Text------------------------------
function showMyNoteText(){
//--------------------------------------------------------------------------
document.getElementById('prompt').style.visibility="hidden";
document.MyNoteBook.mynote.width="1000";
document.MyNoteBook.mynote.style.visibility="visible";
document.getElementById('hit').style.visibility="visible";
document.MyNoteBook.mynote.focus();

}
//------------------------------save new note------------------------------
function savenewnote(){
//--------------------------------------------------------------------------
var schoolid=document.getElementById('schoolid').value;
var schoolname=document.getElementById('schoolname').value;
var comment=document.getElementById('comment').value;
var showmypage=document.getElementById('showmypage').value;
var unitid;
if(document.getElementById('unitid'))
	unitid=document.getElementById('unitid').value;
else unitid=0;

if(IsBlank(schoolname)){
	 alert('Please fill School Name');
	document.getElementById('schoolname').focus();
}else if(IsBlank(comment)){
	 alert('Please fill Comment');
	document.getElementById('comment').focus();
}
else{
	HideNoteField();
//alert('page=useraction&ajaxAction=savenote&unitid='+unitid+'&noteid=0&schoolid='+schoolid+'&schoolname='+schoolname+'&comment='+comment+'&showpage='+showmypage);
ajaxSendRequest('page=useraction&ajaxAction=savenote&unitid='+unitid+'&noteid=0&schoolid='+schoolid+'&schoolname='+schoolname+'&comment='+Url.encode(comment)+'&showpage='+showmypage,ajaxUpdateContentMulti,true,'ajaxManager');
}
}
//-------------------------------save note----------------------------------
function savenote(noteid){
//--------------------------------------------------------------------------
	/*closeMessage();
	schoolid=document.addschool.school.value;
	comment=document.addschool.comment.value;
	showmypage=document.getElementById('showmypage').value;
	ajaxSendRequest('page=useraction&ajaxAction=savenote&noteid='+noteid+'&schoolid='+schoolid+'&comment='+comment+'&showpage='+showmypage,ajaxUpdateContentMulti,true,'ajaxManager');*/
	var schoolname=document.getElementById('editschoolname'+noteid).value;
	var schoolid=document.getElementById('editschoolid'+noteid).value;
	var comment=document.getElementById('editcomment'+noteid).value;
	var showmypage=document.getElementById('showmypage').value;
	var unitid;
if(document.getElementById('unitid'))
	unitid=document.getElementById('unitid').value;
else unitid=0;
if(IsBlank(schoolname)){
	 alert('Please fill School Name');
	document.getElementById('editschoolname'+noteid).focus();
}else if(IsBlank(comment)){
	 alert('Please fill Comment');
	document.getElementById('comment').focus();
}else{
//	alert('page=useraction&ajaxAction=savenote&unitid='+unitid+'&noteid='+noteid+'&schoolid='+schoolid+'&schoolname='+schoolname+'&comment='+Url.encode(comment)+'&showpage='+showmypage);
	ajaxSendRequest('page=useraction&ajaxAction=savenote&unitid='+unitid+'&noteid='+noteid+'&schoolid='+schoolid+'&schoolname='+schoolname+'&comment='+Url.encode(comment)+'&showpage='+showmypage,ajaxUpdateContentMulti,true,'ajaxManager');
 }
}
//-------------------------------delete note----------------------------------
function deletenote(mynoteid){
//--------------------------------------------------------------------------
noteid=mynoteid;
confirmjs('Are you sure to delete note','verifydeletenote');
}
//--------------------------------verify delete note-----------------------------
function verifydeletenote(ver){
//--------------------------------------------------------------------------
if(ver){
var showmypage=document.getElementById('showmypage').value;
var unitid;
if(document.getElementById('unitid'))
	unitid=document.getElementById('unitid').value;
else unitid=0;
ajaxSendRequest('page=useraction&ajaxAction=deletenote&unitid='+unitid+'&noteid='+noteid+'&showmypage='+showmypage,ajaxUpdateContentMulti,true,'ajaxManager');
}
}
function ShowNoteField(){
		document.getElementById('addnote').style.display = 'none';
		document.getElementById('addnote_div').style.display = 'block';
		if(document.getElementById('schoolname'))
		document.getElementById('schoolname').focus();
}

function HideNoteField(){
		document.getElementById('addnote').style.display = 'block';
		document.getElementById('addnote_div').style.display = 'none';
}

function findinstid(){
		var options_xml = {
		script:"includes/auto_suggest.php?suggest=college&",
		varname:"input",
		callback: function (obj) { 
			document.getElementById('schoolid').value = obj.id; 
		}
	};
	var as_xml = new AutoSuggest('schoolname', options_xml);
}

function findinstid_id(id){
		var options_xml = {
		script:"includes/auto_suggest.php?suggest=college&",
		varname:"input",
		callback: function (obj) { 
			document.getElementById('editschoolid'+id).value = obj.id;
		}
	};
	var as_xml = new AutoSuggest('editschoolname'+id, options_xml);
}
function initsuggestbox(list,txtid,txtname){
		var options_xml = {
		script:"includes/auto_suggest.php?suggest="+list+"&",
		varname:"input",
		callback: function (obj) { 
			document.getElementById(txtid).value = obj.id; 
			}
	};
	var as_xml = new AutoSuggest(txtname, options_xml);
}

function ShowEditMyNote(id){ // edit my notes
		if (document.getElementById) { 
		document.getElementById('editnote'+id).style.display = 'none';
		document.getElementById('editnote1'+id).style.display = 'block';
		document.getElementById('editschoolname'+id).focus();
		} 

	}	
//------------------------------show alert type-----------------------------
function showalerttype(){
//--------------------------------------------------------------------------
if(document.FunTasknew.AlertUser.checked){
 document.getElementById("alerttype").style.display="block";
}
else{
 document.getElementById("alerttype").style.display="none";
}
}
//-----------------------------save alert---------------------------------
function savealert(){
//--------------------------------------------------------------------------
var alertsms,alertemail,alertpopup;
	duedate=document.AlertPopUp.DueDate.value;
	fid=document.AlertPopUp.fid.value;
	if(IsBlank(duedate))
		alert('Please Select Date');
	else{
		if(document.AlertPopUp.AlertUsernew.checked){
			alertuser=1;
			if(document.AlertPopUp.TypeOfAlertSms.checked){alertsms=1;} else {alertsms=0;}
			if(document.AlertPopUp.TypeOfAlertEmail.checked) alertemail=1; else alertemail=0;
			if(document.AlertPopUp.TypeOfAlertPopUp.checked) alertpopup=1; else alertpopup=0;
			if(!alertsms && !alertemail && !alertpopup) alertuser=0;
		}else
			alertuser=0;
		ajaxSendRequest('page=useraction&ajaxAction=savealert&fid='+fid+'&duedate='+duedate+'&alertuser='+alertuser+'&alertsms='+alertsms+'&alertemail='+alertemail+'&alertpopup='+alertpopup,ajaxUpdateContentMulti,true,'ajaxManager');
	}
}
//-----------------------to finish/unfinish funtask------------------------
function finishtask(taskid,finish){
//--------------------------------------------------------------------------
	ajaxSendRequest('page=useraction&ajaxAction=finishtask&taskid='+taskid+'&finish='+finish,ajaxUpdateContentMulti,true,'ajaxManager');
}
//-----------------------------My Blog---------------------------------------------
function callMyBlog(){ //My Blog 
//--------------------------------------------------------------------------
window.location.href='index.php?task=blog';
}
//-----------------------------My Blog---------------------------------------------
function myBlog(col_name,sort_order,blog_page,showmypage){ //My Blog 
//--------------------------------------------------------------------------
	  var col_name, sort_order,blog_page;
		  if(col_name==null){
			 col_name='name';
		  }
		  if(sort_order==null){
			  sort_order='asc';
		  }
		  if(blog_page==null){
			  blog_page=1;
		  }
		if(showmypage==null){
			if(document.getElementById('showmypage')) showmypage=document.getElementById('showmypage').value;
			else showmypage="myBlog";
		}	ajaxSendRequest('page=useraction&ajaxAction=myBlog&col_name='+col_name+'&sort_order='+sort_order+'&blog_page='+blog_page+'&showmypage='+showmypage,ajaxUpdateContentMulti,true,'ajaxManager');


}
//------------------------------save new blog topic------------------------------
function saveNewBlogTopic(){
//--------------------------------------------------------------------------
var blogTopic=document.getElementById('schoolname').value;
var blogDescription=document.getElementById('comment').value;;
var showmypage=document.getElementById('showmypage').value;
if(IsBlank(blogTopic)){
	 alert('Please fill Topic Name');
	document.getElementById('schoolname').focus();
}else if(IsBlank(blogDescription)){
	 alert('Please fill Description');
	document.getElementById('comment').focus();
}
else{
	HideNoteField();
ajaxSendRequest('page=useraction&ajaxAction=saveBlogTopic&blogTopic='+blogTopic+'&blogDescription='+Url.encode(blogDescription)+'&showpage='+showmypage,ajaxUpdateContentMulti,true,'ajaxManager');
}
}
//------------------------------load section of particular Tab of student profile--------------------------
function showPost(topicId,blog_page,showmypage){
//--------------------------------------------------------------------------
var topicId,blog_page,showmypage;
if(blog_page == null){
			  blog_page=1;
		  }
		if(showmypage==null){
			if(document.getElementById('showmypage')) showmypage=document.getElementById('showmypage').value;
			else showmypage="myBlogPost";
		}
//popup('page=useraction&ajaxAction=postBlog&blog_page='+blog_page+'1&topicId='+topicId,400,500);
ajaxSendRequest('page=useraction&ajaxAction=postBlog&blog_page='+blog_page+'&topicid='+topicId+'&showmypage='+showmypage,ajaxUpdateContentMulti,true,'ajaxManager');
}
//------------------------------save new blog topic------------------------------
function saveNewPost(topicId){
//--------------------------------------------------------------------------
var blogPost=document.getElementById('commentPost').value;
var showmypage=document.getElementById('showmypage').value;
if(IsBlank(blogPost)){
	 alert('Please fill Post');
	document.getElementById('comment').focus();
}
else{
	//HideNoteField();
ajaxSendRequest('page=useraction&ajaxAction=saveBlogPost&topicId='+topicId+'&blogPost='+Url.encode(blogPost)+'&showpage='+showmypage,ajaxUpdateContentMulti,true,'ajaxManager');
}
}
//------------------------------show school profile--------------------------
function schoolprofile(instid){
//--------------------------------------------------------------------------
window.location.href='index.php?task=schoolprofile&instid='+instid;
}

//------------------------------show school profile--------------------------
function callschoolprofile(instid){
//--------------------------------------------------------------------------
var addurl='';
//addurl=getfindurl();
//view=document.getElementById('myview').value
//addurl=addurl+'&view='+view;
  ajaxSendRequest('page=useraction&ajaxAction=schoolprofile&instid='+instid+addurl,ajaxUpdateContentMulti,true,'ajaxManager');
}
//------------------------------to show tab of school profile--------------------------
function schoolprofiletab(instid,tab){
//--------------------------------------------------------------------------
//activate tab
  ajaxSendRequest('page=useraction&ajaxAction=schoolprofiletab&instid='+instid+'&tab='+tab,ajaxUpdateContentMulti,true,'ajaxManager');
//document.getElementById("linkwiki").className="";
document.getElementById("linkfact").className="";
document.getElementById("linkadmission").className="";
document.getElementById("linkmedia").className="";
document.getElementById("linknews").className="";
//if(tab=='wiki')
//document.getElementById("linkwiki").className="";
//else 
if(tab=='fact')
document.getElementById("linkfact").className="current";
else if(tab=='admission')
document.getElementById("linkadmission").className="current";
else if(tab=='media')
document.getElementById("linkmedia").className="current";
else if(tab=='news')
document.getElementById("linknews").className="current";
}
//------------------------------to show tab of school profile--------------------------
function addtofavorites(instid,imgobj){
//--------------------------------------------------------------------------
  imgobj.src="images/heart_red.gif";
  ajaxSendRequest('page=useraction&ajaxAction=savefoldercont&instid='+instid+'&fav=1',ajaxUpdateContentMulti,true,'ajaxManager');
}
//------------------------------show student profile--------------------------
function callstudentprofile(){
//--------------------------------------------------------------------------
window.location.href='index.php?task=studentprofile';
}
//------------------------------show student profile--------------------------
function studentprofile(studentid){
if(studentid==null)
	studentid=0;
  ajaxSendRequest('page=useraction&ajaxAction=studentprofile&studentid='+studentid,ajaxUpdateContentMulti,true,'ajaxManager');
//--------------------------------------------------------------------------
}
//------------------------------to show tab of student profile--------------------------
function studentprofiletab(studentid,tab,refresh){
//--------------------------------------------------------------------------
if(studentid==null)
	studentid=0;
//activate tab
if(refresh==null)
	refresh=true;
else 
	refresh=false;
  ajaxSendRequest('page=useraction&ajaxAction=studentprofiletab&studentid='+studentid+'&tab='+tab+'&refresh='+refresh,ajaxUpdateContentMulti,true,'ajaxManager',refresh);
document.getElementById("linkaboutme").className="";
document.getElementById("linkacademics").className="";
document.getElementById("linkwriting").className="";
document.getElementById("linkactivities").className="";
document.getElementById("linkmedia").className="";
if(tab=='aboutme')
document.getElementById("linkaboutme").className="current";
else if(tab=='academics')
document.getElementById("linkacademics").className="current";
else if(tab=='writing')
document.getElementById("linkwriting").className="current";
else if(tab=='activities')
document.getElementById("linkactivities").className="current";
else if(tab=='media')
document.getElementById("linkmedia").className="current";
}
//------------------------------load section of particular Tab of student profile--------------------------
function updatestudentprofile(tab,section,id,work){
//--------------------------------------------------------------------------
if(id==null)	id=0;
if(tab==null)	tab="";
if(section==null)	section="";
if(work==null)	work="";
//alert('page=useraction&ajaxAction=showpopup&popuppage=updatestudentprofile&tab='+tab+'&section='+section+'&work='+work+'&id='+id);
popup('page=useraction&ajaxAction=showpopup&popuppage=updatestudentprofile&tab='+tab+'&section='+section+'&work='+work+'&id='+id,400,500);

//popup('page=useraction&ajaxAction=showpopup&popuppage=updatestudentprofile&tab='+tab+'&section='+section+'&id='+id,400,500);
//  ajaxSendRequest('page=useraction&ajaxAction=studentprofiletab&studentid='+studentid+'&tab='+tab,ajaxUpdateContentMulti,true,'ajaxManager');
}
//------------------------------student Writing Tab of student profile--------------------------
function showmorewriting(){ //show-hide div
document.getElementById('writingdisplayblock_1').style.display = 'none';
document.getElementById('writingdisplayblock_2').style.display = 'block';
}
function showlesswriting(){ //show-hide div
document.getElementById('writingdisplayblock_1').style.display = 'block';
document.getElementById('writingdisplayblock_2').style.display = 'none';
}
function showeditwriting(){ //show-hide div
document.getElementById('writingdisplayblock_1').style.display = 'none';
document.getElementById('writingdisplayblock_2').style.display = 'none';
document.getElementById('editwriting').style.display = 'block';
}
function showaddwriting(){ //show-hide div
document.getElementById('writingblock_1').style.display = 'none';
document.getElementById('writingblock_2').style.display = 'block';
}
function savewriting(action){ //send url to ajax for writing note in student profile
var title=document.getElementById('writing_title').value;
var writing_date=document.getElementById('writing_date').value;
var writing_note=document.getElementById('writing_note').value;
if(document.getElementById('writing_agree').checked)
	var agree='yes';
else
	var agree='no';

var url='page=useraction&ajaxAction=savestudentprofilesection&tab=writing&title='+title+'&writing_date='+writing_date+'&writing_note='+writing_note+'&agree='+agree+'&save='+action;
ajaxSendRequest(url,ajaxUpdateContentMulti,true,'ajaxManager');
/*if(action=='Save'){
document.getElementById('editwriting').style.display = 'none';
}*/
}
function CheckWritingForm(act){// check the value for proper fill

if(IsBlank(document.frm_writing.writing_title.value.toString())){
			alert("Please Enter Title");
			document.frm_writing.writing_title.focus();
			return false;
		}
if(IsBlank(document.frm_writing.writing_date.value.toString())){
			alert("Please Enter Date");
			document.frm_writing.writing_date.focus();
			return false;
		}
if(IsBlank(document.frm_writing.writing_note.value.toString())){
			alert("Please Enter Note");
			document.frm_writing.writing_note.focus();
			return false;
		}
		if(act=='Add')
		savewriting('Add');
		else if(act=='Save')
		savewriting('Save');
return true;
}
//------------------------------end of student Writing Tab--------------------------
//-----------------------------to upload file---------------------------
function savestudentprofile(upload_field){
	var fname = document.frmupload.txtfname.value;
	var lname = document.frmupload.txtlname.value;
    var filename = upload_field.value;
	var phoneret=true;
 if(IsBlank(fname)||IsBlank(lname)) 
	 alert('Please fill all necessary fields');
 else {
	var phone=document.getElementById("txtphone").value; 
	if(!IsBlank(phone)) { 	phoneret=checkUSPhone(); }
	if(phoneret==true){ //ret=jsUpload(upload_field);    
	upload_field.form.submit();
	setTimeout("closeMessage()",1000)
	setTimeout("studentprofile()",1100);
	}
  }
}
function jsUpload(upload_field)
{
    // this is just an example of checking file extensions
    // if you do not need extension checking, remove 
    // everything down to line
    // upload_field.form.submit();
	
	var re_text = /\.gif|\.jpg|\.jpeg|\.png/i;
    var filename = upload_field.value;
//alert(filename);
    /* Checking file type */
	if(!IsBlank(filename)){
    if (filename.search(re_text) == -1)
    {
        alert("File does not have text(gif, jpg, png) extension");
        upload_field.form.reset();
        return false;
    }
	}else{
		alert('Please select file to upload');
	}
    if (!IsBlank(filename))
    {
    upload_field.form.submit();
	//closeMessage();
	document.getElementById('profile_img').style.display="none";
	setTimeout("studentprofile()",2000);
    return true;
	}
	//return false;
}
//save by section of tab of [student profile]
function savestudentprofilesection(tab,section,frm){
closeMessage();
var elements=frm.elements;
var url='page=useraction';
for(i=0; i<frm.elements.length; i++){
 url=url+'&'+frm.elements[i].name+'='+frm.elements[i].value;
}
ajaxSendRequest(url,ajaxUpdateContentMulti,true,'ajaxManager');
}

//----------------------------for media section of student
function savestudentprofilemedia(upload_field){
	
	var fname = document.frmupload.title.value;
	var fsection = document.frmupload.section.value;
    var filename = upload_field.value;
 if(IsBlank(fname)) 
	 alert('Please fill all necessary fields');
 else {
	 ret=jsUploadmedia(upload_field,fsection);
  }
}
function jsUploadmedia(upload_field,fsection)
{
    // this is just an example of checking file extensions
    // if you do not need extension checking, remove 
    // everything down to line
    // upload_field.form.submit();

	var retchk=checkExtension(upload_field,fsection);
	if(retchk==false) return false;
		 if(fsection=='video'){	
			retchk=checkExtension(document.frmupload.file2,'picture');
			if(retchk==false) return false;	
		 }
	upload_field.form.submit();
//	setTimeout("studentprofiletab(0,'media');",2000);
	setTimeout("studentprofiletab(0,'media');closeMessage();",2000);
    return true;
}

function checkExtension(upload_field,fsection){
	if(fsection=='picture')
	var re_text = /\.gif|\.jpg|\.jpeg|\.png|\.bmp/i;
	else if(fsection=='audio')
	var re_text = /\.mp3|\.mp4|\.wav|\.wma/i;
	else if(fsection=='video')
	var re_text = /\.avi|\.dat|\.wmv|\.mpeg/i;

    var filename = upload_field.value;
    /* Checking file type */
	if(!IsBlank(filename)){
    if (filename.search(re_text) == -1)
    {
        if(fsection=='picture')
			alert("File does not have (gif, jpg, png, bmp) extension");
		else if(fsection=='audio')
			alert("File does not have (mp3, mp4, wav, wma) extension");
		else if(fsection=='video')
			alert("File does not have (avi, dat, wmv, mpeg) extension");
		
        //upload_field.form.reset();
        return false;
    }
	}

}
function deletestudentprofilemedia(){
	document.frmupload.submit();
	setTimeout("studentprofiletab(0,'media');closeMessage();",2000);
    return true;
}

///////////////////////////////////////////Calendar Section Start Here//////////////////////////////////////
///To show calendar
function retDate(){
	var cur_dt=new Date();
	var mon=cur_dt.getMonth()+1;
	mon=(mon<10)?('0'+mon):mon;
	var dt=cur_dt.getDate();
	dt=(dt<10)?('0'+dt):dt;
	//alert(cur_dt.getFullYear()+'-'+mon+'-'+dt);
return cur_dt.getFullYear()+'-'+mon+'-'+dt;
}

function callcalendar(){
	var datetime=retDate();
	//alert(datetime)
	ajaxSendRequest('page=useraction&ajaxAction=calendar',ajaxUpdateContentMulti,true,'calendarDiv');
}

function calendar(){
	window.location.href='index.php?task=calendar';
}

///To change calendar view
function showNxtCal(values){
			
	if(values.indexOf('?')>0)
		if(values.substr(values.indexOf('?')+1)!='E')
			document.getElementById('which').value=values.substr(values.indexOf('?')+1);
	
	document.getElementById('recentDate').value=values.substr(0,10);
	var cal_id=document.getElementById('c_ids').value;
	if(values.indexOf('?')<0)
		values=values+'?'+document.getElementById('which').value;

	var request='page=useraction&ajaxAction=nxtCal&values='+values+'&cal_id='+cal_id;
//alert(request);
	ajaxSendRequest(request,ajaxUpdateContentMulti,true,'ajaxManager');
}


///To save event by popup
function saveCalVal(val){
	ajaxSendRequest('page=useraction&ajaxAction=saveCal&val='+val,ajaxUpdateContentMulti,true,'ajaxManager');
}


///To get details from edit event form and save it
function submitEventForm(id){
	var frmdt,msg='',todt='',cal_id;
	var d= new Date();
	var df=d.getFullYear()+'-'+d.getMonth()+'-'+d.getDate();
	var dt=(d.getHours()%12)+'-'+d.getMinutes();

	if(document.getElementById('c_ids')){
		if(document.getElementById('c_ids').value==0)
			msg+="No calendar selected.\n";
		else	
			cal_id=document.getElementById('c_ids').value;
	}
	var pg=document.getElementById('which').value;
	var what=document.getElementById('what').value;
	var frmdate=document.getElementById('frmdate').value;
	var frmtime=document.getElementById('frmtime').value;
	frmdt=frmdate+' '+frmtime;
	if(!document.getElementById('allday').checked){
		var todate=document.getElementById('todate').value;
		var totime=document.getElementById('totime').value;
		todt=todate+' '+totime;
	}
	var repeat=document.getElementById('repeat').value;
	var where=document.getElementById('where').value;
	var description=document.getElementById('description').value;
	var reminder=document.getElementById('reminder').value;
	var duration=document.getElementById('duration').value;
	var units=document.getElementById('units').value;
	
	
	if(!what)	msg+='Please enter value for what\n';
	
	if(!frmdate)	msg+='Please enter value for From Date\n';
	else if(checkFormat(frmdate,'D'))	msg+='Please enter value for From Date in YYYY-MM-DD (e.i- '+df+') format\n';
	
	if(!todate)	msg+='Please enter value for To Date\n';
		else if(checkFormat(todate,'D'))	msg+='Please enter value for To Date in YYYY-MM-DD (e.i- '+df+') format\n';
		
	if(pg!='M'){
		if(!frmtime)	msg+='Please enter value for From Time\n';
		else if(checkFormat(frmtime,'T'))	msg+='Please enter value for From Time in HH:MM (e.i- '+dt+') format\n';
			
		if(!totime)	msg+='Please enter value For From time\n';
		else if(checkFormat(totime,'T'))	msg+='Please enter value for To Time in HH:MM (e.i- '+dt+') format\n';
		
		if(checkDateTime(frmdate,frmtime,todate,totime))
			msg+='Please enter value for To Date/Time greter than From Date/Time\n';
	}else{
		if(checkDate(frmdate,todate))
			msg+='Please enter value for To Date greter than From Date\n';
	}
	
	
	if(msg)
		alert(msg)
	else{
		var url='page=useraction&ajaxAction=addEditEvent&id='+id+'&what='+what+'&frmdt='+frmdt+'&todt='+todt+'&repeat='+repeat+'&where='+where+'&description='+description+'&reminder='+reminder+'&duration='+duration+'&units='+units+'&cal_id='+cal_id+'&pg='+pg;
		//alert(url);
		ajaxSendRequest(url,ajaxUpdateContentMulti,true,'ajaxManager');
	}
}

///To add new public calendar
function addCal(val){
	ajaxSendRequest('page=useraction&ajaxAction=addNewCal&val='+val,ajaxUpdateContentMulti,true,'ajaxManager');
}

///To search new public calendar
function searchCal(){
	if(document.getElementById('calname'))
	var val=''+document.getElementById('calname').value+'';
	ajaxSendRequest('page=useraction&ajaxAction=searchNewCal&val='+val,ajaxUpdateContentMulti,true,'ajaxManager');
}

///To delete events by popup
function deleteEvent(m){
	var evid=document.getElementById('eventid'+m).value;
	var values=document.getElementById('which').value;
	ajaxSendRequest('page=useraction&ajaxAction=delCalEvent&evid='+evid+'&show='+values,ajaxUpdateContentMulti,true,'ajaxManager',true);
}

///To edit events
function editEvent(id){
	var time;
	//alert(id)
	var evid=document.getElementById('eventid'+id).value; //alert(evid)
	time=(evid=='')?document.getElementById('datetime'+id).value:'';
	var url='page=useraction&ajaxAction=editCalEvent&id='+evid+'&dtime='+time;
	ajaxSendRequest(url,ajaxUpdateContentMulti,true,'ajaxManager');
}

///To events from agenda
function delAgendaEvent(evid){
	ajaxSendRequest('page=useraction&ajaxAction=delCalEvent&evid='+evid+'&show=A',ajaxUpdateContentMulti,true,'ajaxManager',true);
}


///To events from agenda
function edtAgendaEvent(evid){
	ajaxSendRequest('page=useraction&ajaxAction=editCalEvent&id='+evid,ajaxUpdateContentMulti,true,'ajaxManager');
}

function changeCalClr(id,clr_id){
	ajaxSendRequest('page=useraction&ajaxAction=changeCalClr&id='+id+'&clr_id='+clr_id,ajaxUpdateContentMulti,true,'ajaxManager');
}

function edtEventShowJs(message){
	var divElmnts='';
	divElmnts='<div class="alertBack">'+message+'</div>';
displayPopupMessage(divElmnts,'eventAlertBoxHolder',(screen.availWidth-400),(screen.availHeight-505))
}

function closeEventMessage()
{
	messageObj.close();
	changeCalView();
}

////////////////////////////////////////////////Calendar Section End Here/////////////////////////////////



function chksession(){
	ajaxSendRequest('page=useraction&ajaxAction=chksession',ajaxUpdateContentMulti,true,'ajaxManager');
}
/////////// for change theme
function changeHomeTheme(){
document.getElementById("outerContainer").className="outerContainerImg";
document.getElementById("ltLogo").src="images/ltLogoEnner.gif";
}

/////////// for change theme Again
function changeOtherTheme(){
document.getElementById("outerContainer").className="outerContainer";
document.getElementById("ltLogo").src="images/ltLogo.gif";
}
//delete academics
function deleteAcademics(class_cat,grade){
ajaxSendRequest('page=useraction&ajaxAction=savestudentprofilesection&tab=student_academics&section='+class_cat+'&act=delete&grade='+grade,ajaxUpdateContentMulti,true,'ajaxManager',false);
}
//delete activities
function deleteActivities(class_cat,id){
ajaxSendRequest('page=useraction&ajaxAction=savestudentprofilesection&tab=student_activities&section='+class_cat+'&act=delete&id='+id,ajaxUpdateContentMulti,true,'ajaxManager',false);
}

//update academics tab school profile
function adddatatolist(subject,score,target){
if(IsBlank(subject)){ alert('Please enter subject')}
else if(IsBlank(score)){ alert('Please enter score')}
else if(isNotNumeric(score)){ alert('Please enter score between 0.0 to 4.0')}
else if(score>4){ alert('Please enter score between 0.0 to 4.0')}
else addtexttolist(subject+'=>'+score,target)
}
function adddatatolistaward(subject,score,target){
if(IsBlank(subject)){ alert('Please enter subject')}
else if(IsBlank(score)){ alert('Please enter Year')}
else addtexttolist(subject+'=>'+score,target)
}
function checkdata(tab,section,frm){
if(isNotNumeric(document.academics_12th.txtyear.value) ||(document.academics_12th.txtyear.value<1900)){ 
alert('Please enter valid year');
}
else {closeMessage();savestudentprofilesection(tab,section,frm);}

return true;
}
//update activities tab school profile
function addacttolist(team,position,year,target){
if(IsBlank(team)){ alert('Please enter Club/Sport')}
else if(IsBlank(position)){ alert('Please enter Position/Title')}
else if(isNotNumeric(year) || (year<1900)){ alert('Please enter valid year'+year);}
else {addtexttolist(position+'@'+team+'-['+year+']',target);
	ajaxSendRequest('page=useraction&ajaxAction=savestudentprofilesection&tab='+document.frmactivities.tab.value+'&section='+document.frmactivities.section.value+'&act=add&team='+team+'&position='+position+'&year='+year,ajaxUpdateContentMulti,true,'ajaxManager',false);
}
}
function removeactfromlist(src) {
	id=src.options[src.selectedIndex].value;
	/*alertjs('page=useraction&ajaxAction=savestudentprofilesection&tab='+document.frmactivities.tab.value+'&section='+document.frmactivities.section.value+'&act=delete&id='+id);*/
	if(id!=0) ajaxSendRequest('page=useraction&ajaxAction=savestudentprofilesection&tab='+document.frmactivities.tab.value+'&section='+document.frmactivities.section.value+'&act=delete&id='+id,ajaxUpdateContentMulti,true,'ajaxManager',false);
}

function showactfromlist() {
    ajaxSendRequest('page=useraction&ajaxAction=savestudentprofilesection&tab='+document.frmactivities.tab.value+'&section='+document.frmactivities.section.value+'&act=show',ajaxUpdateContentMulti,true,'ajaxManager',false);
}
 
////////add list data from one to another
function addtexttolist(src,target) {
	var fl = src.length -1;
	var au = target.length -1;
	if(au>8) return;
	//gets value of percentage assignment of selected resource
//	var perc = form.percentage_assignment.options[form.percentage_assignment.selectedIndex].value;
	var perc ="";
	var list2val = "x";

	//build array of assiged list2val
	for (au; au > -1; au--) {
		list2val = list2val + "," + target.options[au].value + ","
	}

	//Pull selected list1 and add them to list
		if (list2val.indexOf( "," + src + "," ) == -1) {
			t = target.length
			opt = new Option( src, 0);
			target.options[t] = opt
		}
	
}
///remove from list
function removefromlist(src) {
	fl = src.length -1;
	for (fl; fl > -1; fl--) {
		if (src.options[fl].selected) {
			var selValue = src.options[fl].value;			
				src.options[fl] = null;
		}
	}
}
function showlist(src){
var msg='';
var x=0;
	fl = src.length -1;
	for (x=0; x <= fl; x++) {
		msg=msg+src.options[x].text+';';
	}
	return msg;
}
var onOff=0;

//function to set visible property of search modules
function showHide(imgId,divId){
	if(onOff){
		document.getElementById(imgId).src='images/Whtdw.gif';
		document.getElementById(divId).style.display='inline';
		onOff=0;
	}else{
		document.getElementById(imgId).src='images/whtErow2.gif';
		document.getElementById(divId).style.display='none';
		onOff=1;
	}
}


var Url = {
//alert(Url.decode(act));
	// public method for url encoding
	encode : function (string) {
		return escape(this._utf8_encode(string));
	},

	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},

	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},

	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	}

}
