<!--Form validation-->

function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
    } if (errors) alert('The following error(s) occurred:\n'+errors);
    document.MM_returnValue = (errors == '');
} }



<!--Show video-->

function showmov2()
{
	document.getElementById('mov1').style.display='none';
	document.getElementById('mov2').style.display='block';
}
function showmov1()
{
	document.getElementById('mov2').style.display='none';
	document.getElementById('mov1').style.display='block';
}

<!--Drops of light-->
function Typewriter(sName)
{	// PROPERTIES
	this.counter = 0;
	this.name = sName;
	this.text = "";
	this.speed = 150; // in milliseconds
	
	// METHODS
	this.addText = AddText;
	this.next = Next;
	this.setSpeed = SetSpeed;
	this.write = Write;
	
	// FUNCTIONS
	function AddText(s)
	{	this.text = s
	}
	function Next()
	{	document.getElementById('typewriter_output').innerHTML = this.text.substr(0, this.counter++);
	}
	function SetSpeed(iSpeed)
	{	this.speed = iSpeed;
	}
	function Write()
	{	setInterval(this.name+".next()",this.speed);
	}
}
function dropoflight()
{
document.getElementById('drop').style.display = 'block';
}

function showHide(shID) {
    if (document.getElementById(shID)) {
        if (document.getElementById(shID+'-show').style.display != 'none') {
            document.getElementById(shID+'-show').style.display = 'none';
            document.getElementById(shID).style.display = 'block';
        }
        else {
            document.getElementById(shID+'-show').style.display = 'inline';
            document.getElementById(shID).style.display = 'none';
        }
    }
}

function open_new_window(url)
{ 
var new_window = window.open(url,'window_name','toolbar=0,menubar=0,resizable=0,dependent=0,status=0,width=525,height=200,left=100,top=100')
if (!new_window)
{
alert("A popup blocker was detected, Pls disable your popup blocker and try again");
}
}



<!--For flash video -->
function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}

<!--Fuction to clear input field value-->
function clearText(thefield)
 { if (thefield.defaultValue == thefield.value)
 {
  thefield.value = "" 
  }
  /*else 
  { thefield.value = thefield.defaultValue
   } */
}
<!--Image preloader-->
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
<!--Image preloader ends here-->
<!--Search form submit -->
function submit_search()
{
document.search_form.action="http://www.publicacademia.com/search/search2.php?keyword="+search_form.keyword.value+"&course="+search_form.course.value+"&level="+search_form.level.value+"&country="+search_form.country.value+"&university="+search_form.university.value+"&srow=0&erow=10";
document.search_form.target='_self';
document.search_form.submit();
}
<!--Search form submit ends here-->
<!--Search for students-->
function submit_search_student(){

document.search_form.action="http://www.publicacademia.com/student_logged/search2.php?keyword="+search_form.keyword.value+"&course="+search_form.course.value+"&level="+search_form.level.value+"&country="+search_form.country.value+"&university="+search_form.university.value+"&srow=0&erow=10";
document.search_form.target='_self';
document.search_form.submit();
}
<!--search students ends here-->
<!--Banner rotation-->

var image="";
var banners=0;
function cycle() {
  if (++banners > 3) banners=1;
    loadbanners();
    document.banner1.src = image;
    window.setTimeout('cycle();',7000);
  }
function loadbanners() {
   if (banners==1)
      {
      image="/images/banner_add1.jpg";
      }
   if (banners==2)
      {
      image="/images/banner_add2.jpg";
      }

}

var link = "http://publicacademia.com"
function urlswitch() {
if (banners==1)
{
link = "http://publicacademia.com/request_info.php";
}
if (banners==2)
{
link = "http://publicacademia.com/forum/index.php";
}
return link;
}
<!--Banner rotation ends here-->
<!--sub-category in tooltips -->

function obtainPostitionX(element) {
    var x=0;
    while(element)	{
        x += element.offsetLeft;
        element=element.offsetParent;
    }
    return x;
}

function obtainPostitionY(element) {
    var y=0;
    while(element) {
        y += element.offsetTop;
        element=element.offsetParent;
    }
    return y;
}

function showSubcategoties(objElement, categoryId){
	var overlayElement = document.getElementById('subcategoryDiv');
	overlayElement.style.display = 'block';
	if(objElement) {
		objElement = document.getElementById(objElement);
		overlayElement.style.top = obtainPostitionY(objElement) -5 +'px';
		overlayElement.style.left = obtainPostitionX(objElement)+ (objElement.offsetWidth+15) +'px';
		if(categoryId) {
			var url = objElement.href + '' + objElement.getAttribute('url');
			document.getElementById('subcategoryDivContent').innerHTML = getSubCategories(url, categoryId);
		}
	}
	overlayHackLayerForIE('subcategoryDiv', overlayElement);
}

function hideSubcategoties(objElement){
	objElement = 'subcategoryDiv';
	document.getElementById(objElement).style.display = 'none';
	dissolveOverlayHackForIE();
}

function getSubCategories(url, id) {
	var subCategoryHtml = '';
	var catergoryHtml = ''; 
	for(var categoryCount = 0; categoryCount < categoryList.length; categoryCount++) {
		if(id == categoryList[categoryCount].parentId) {
			var categoryUrl = url + ''+ categoryList[categoryCount].categoryID;
			var categoryRow =  '<div style="margin-bottom:5px;" class="text12grey"><a href="'+ categoryUrl +'" class="text12grey">'+ categoryList[categoryCount].categoryName +'</a></div>';
			if(categoryList[categoryCount].categoryName.toLowerCase().indexOf('other') == 0) {
				catergoryHtml += categoryRow;
			} else {
				subCategoryHtml += categoryRow;
			}
		}
	}
	catergoryHtml = subCategoryHtml + catergoryHtml;
	return catergoryHtml;
}

var categoryList = eval([{"categoryName":"Delhi University forum","categoryID":"index.php","urlName":"forum/","parentId":"1"},
						 {"categoryName":"Punjab University forum","categoryID":"index.php","urlName":"forum/","parentId":"1"},
						 
						 {"categoryName":"University Alerts","categoryID":"mypublicacademia.php","urlName":"","parentId":"2"},
						 {"categoryName":"Counselor Alerts","categoryID":"mypublicacademia.php","urlName":"","parentId":"2"},
						 {"categoryName":"Jobs Alerts","categoryID":"mypublicacademia.php","urlName":"","parentId":"2"},
						 
						 {"categoryName":"United Kingdom","categoryID":"uk.php","urlName":"pop_dest/","parentId":"4"},
						  {"categoryName":"Germany","categoryID":"germany.php","urlName":"pop_dest/","parentId":"4"},
						  {"categoryName":"Ireland","categoryID":"ireland.php","urlName":"pop_dest/","parentId":"4"},
						  {"categoryName":"France","categoryID":"france.php","urlName":"pop_dest/","parentId":"4"},
						  {"categoryName":"Sweden","categoryID":"sweden.php","urlName":"pop_dest/","parentId":"4"},
						 
						  {"categoryName":"Engineering","categoryID":"engineering.php","urlName":"pop_courses/","parentId":"5"},
						   {"categoryName":"Architecture","categoryID":"arch.php","urlName":"pop_courses/","parentId":"5"},
						   {"categoryName":"Medicine","categoryID":"medicine.php","urlName":"pop_courses/","parentId":"5"},
						   {"categoryName":"Law","categoryID":"law.php","urlName":"pop_courses/","parentId":"5"},
						   {"categoryName":"M.B.A","categoryID":"mba.php","urlName":"pop_courses/","parentId":"5"},
						   {"categoryName":"Aviation & Pilot Training","categoryID":"aviation.php","urlName":"pop_courses/","parentId":"5"},
						  
						  {"categoryName":"Finland","categoryID":"finland.php","urlName":"zero_tution_fee/","parentId":"6"},
						   {"categoryName":"France","categoryID":"france.php","urlName":"zero_tution_fee/","parentId":"6"},
						   {"categoryName":"Germany","categoryID":"germany.php","urlName":"zero_tution_fee/","parentId":"6"},
						   {"categoryName":"Sweden","categoryID":"sweden.php","urlName":"zero_tution_fee/","parentId":"6"},
						   {"categoryName":"Norway","categoryID":"norway.php","urlName":"zero_tution_fee/","parentId":"6"},
						  {"categoryName":"Austria","categoryID":"austria.php","urlName":"zero_tution_fee/","parentId":"6"},
						  
						  {"categoryName":"Luxury Goods Management","categoryID":"luxury.php","urlName":"hot_careers/","parentId":"7"},
						    {"categoryName":"Gaming & Animation","categoryID":"gaming.php","urlName":"hot_careers/","parentId":"7"},
						    {"categoryName":"Transportation & Car Design","categoryID":"car_design.php","urlName":"hot_careers/","parentId":"7"},
						    {"categoryName":"Fashion Marketing & Buying","categoryID":"fashion_marketing.php","urlName":"hot_careers/","parentId":"7"},
						    {"categoryName":"Fashion Communication","categoryID":"fashion.php","urlName":"hot_careers/","parentId":"7"}
						  
						 ]);
<!--sub-category in tooltips ends here -->
<!--pop up window-->

function open_new_window_faq(url)
{ 
var new_window = window.open(url,'window_name','toolbar=0,menubar=0,resizable=1,scrollbars=1,dependent=0,status=0,width=525,height=600,left=100,top=100')
if (!new_window)
{
alert("A popup blocker was detected, Pls disable your popup blocker and try again");
}
}



			function send_mail_request() {
				
			
				new Ajax.Request("http://www.publicacademia.com/mail_friend.php", 
					{ 
					method: 'post', 


					postBody: '&email_frnd='+ $F('email_frnd'),
					onComplete: showResponse_mail 
					});
			
				}

			function showResponse_mail(req){
				alert("Invitation sended.");
			//$('mail_message').innerHTML= req.responseText;
			}
			
<!--Model box-->
messageObj = new DHTML_modalMessage();	// We only create one object of this class
messageObj.setShadowOffset(5);	// Large shadow


function displayMessage(url)
{
	
	messageObj.setSource(url);
	messageObj.setCssClassMessageBox(false);
	messageObj.setSize(240,275);
	messageObj.setShadowDivVisible(false);	// Enable shadow for these boxes
	messageObj.display();
}

function closeMessage()
{
	messageObj.close();	
}

