// top Banner text, link
var tbanner=null;
var pmsg=null;
//var tbanner = {text:" Eureka 2009 Preliminary Results Available",link:"http://vectorindia.org/eureka/results.html"}
//Click here to view All India Entrance test Results(JAN 27<sup>th</sup>)
//var tbanner = {text:" RESULTS will be Announced on (26<sup>th</sup> Aug 2010 , 8:30PM)",link:"#"}
var tbanner = {text:"Click here to view All India Entrance test Results(Aug 22<sup>nd</sup>)",link:"onlineresults.aspx"}
//var tbanner = {text:"Admissions Closed. Next Entrance Test Date 2 Be Announced on 11<sup>th</sup> July",link:"#"}
//var tbanner={text:"Apply for Embedded Sys/VLSI All India Entrance Test - 22<sup>nd</sup> August 2010",link:"examschedule.html"};
//var tbanner={text:"Hallticket for Robert Bosch Pooled Campus",link:"offcampus/genhallticket.aspx"};
//var tbanner={text:"Click here to Generate Hall Ticket",link:"admission.aspx"};

//popup message
//var pmsg = {text:"Admissions Closed. Next Entrance Test Date 2 Be Announced on 11<sup>th</sup> July",link:"#"};
//var pmsg = {text:" RESULTS will be Announced on <br/><center> 26<sup>th</sup> Aug 2010, 8:30PM</center>",link:"#"};
var pmsg = {text:"Click here to view All India Entrance test Results(Aug 22<sup>nd</sup>)",link:"onlineresults.aspx"};
//var pmsg = {text:"Click here to Generate Hall Ticket",link:"admission.aspx"};
//var pmsg = {text:"Apply for Embedded Sys/VLSI All India Entrance Test <br\><center> 22<sup>nd</sup> August 2010</center>",link:"examschedule.html"};

//var pmsg = {text:" Eureka 2009 Preliminary Results Available<br/>",link:"http://vectorindia.org/eureka/results.html"};
//var pmsg={text:"",link:""};

//var pmsg = {text:"Robert Bosch Pooled Campus - 5<sup>th</sup> Sept 2009<br/>Click here to generate HALL-TICKET",link:"offcampus/genhallticket.aspx"};
//news enter the news text in double codes (Note: text contains double code escape it ex:" ==> \")
// each news item seperated by coma.

var news=[
    "06th JAN 2010: 17th All India Entrance Test on 07th FEB'10",
	"02nd JAN 2010: Robert Bosch Campus",
	"31st Dec 2009: Mars Telecom Recruitment",
	"24th Dec 2009: Purple Talk Recruitment",
	"23rd Dec 2009: Grit Innovation Recruitment",
	"22nd Dec 2009: GE Campus",
	"15th Dec 2009: Vector Celebrates 4th Anniversary",
	"17th Dec 2009: SQLStar International Recruitment",
	"12th Dec 2009: Synfosys Recruitment",
	"12th Dec 2009: PrimeSoft Sol Recruitment",
	"01st Dec 2009: Key Point Recruitment",
	"09th Nov 2009: American MegaTrends Campus",
	"04th Nov 2009: AutoMotive Robotics Recruitment",
	"30th Oct 2009: Srans Info Sys Campus",
	"12th Oct 2009: Bartronics Recruitment",
	"19th Sept 2009: Megasoft Recruitment",
	"18th Sept 2009: Synfosys Recruitment",
	"09th Sept 2009: Robert Bosch Campus",
	"03rd Sept 2009: TeamF1 Sol Campus",
        "02nd Sept 2009: SQL Star International Recruitment"];

//menu
var menu={};
menu["institute"] =[{"mname":"Vision","link":"vision.html"},{"mname":"Mission","link":"mission.html"},{"mname":"Infrastructure","link":"infrastructure.html"}];
menu["facilities"] =[{"mname":"Class rooms","link":"classrooms.html"},{"mname":"System labs","link":"systemslab.html"},{"mname":"Hardware lab","link":"hardwarelab.html"},{"mname":"Library","link":"library.html"},{"mname":"Hostel Facility","link":"hostel_facility.html"},{"mname":"Placement cell","link":"placement_cell.html"}];
menu["course"] =[{"mname":"Embedded Systems","link":"embedded.html"},{"mname":"VLSI","link":"VLSI.html"},{"mname":"C++","link":"C_plus_plus.html"},{"mname":"C","link":"C.html"}];
menu["corporate"] =[{"mname":"Recruitment","link":"recruitmentAssistance.html"},{"mname":"Corporate Training","link":"corporate.html"},{"mname":"Downloads","link":"freeDownload.html"}];
menu["admission"] =[{"mname":"Mode & selection process","link":"selection_process.html"},{"mname":"Eligibility","link":"eligibility.html"},{"mname":"Entrance exam schedule","link":"examschedule.html"},{"mname":"Special Discounts","link":"special_discount.html"},{"mname":"Test Centers","link":"test_centers.html"},{"mname":"Apply Online","link":"admission.aspx"},{"mname":"Embedded Sample Paper", "link":"images/embeddedsamplepaper.pdf"},{"mname":"VLSI Sample Paper","link":"images/vlsisamplepaper.pdf"}];
//menu["placements"] =[{"mname":"Current Placements","link":"cplacements.html"},{"mname":"Placement Policy","link":"placement_policy.html"},{"mname":"Placement record","link":"list_of_candidates.html"},{"mname":"Integration program","link":"intigrationProgram.html"}];
var populated=false;
var nscroll=null;
function newsInit(){
	var n1 =document.getElementById('N1');
	var n2 =document.getElementById('N2');
	if(n1 && n2){
		n1.h=n2.h= n1.offsetHeight;
		n1.t=0;
		n2.t=n2.h;
	}
	nscroll=setTimeout("newsStart()",10);
}
function newsStart(){
	var n1 =document.getElementById('N1');
	var n2 =document.getElementById('N2');
	if(n1 && n2){
		if(n1.t <= -(n1.h)){
			n1.t=n1.h;
		}
		if(n2.t <= -(n2.h)){
			n2.t=n2.h;
		}
		n1.t=n1.t-2;
		n2.t=n2.t-2;
		n1.style.top=n1.t+'px';
		n2.style.top=n2.t+'px';
		if(nscroll){
		clearTimeout(nscroll);
		}
		nscroll=setTimeout("newsStart()",50);
	}
}
function newsStop(){
	if(nscroll){
		clearTimeout(nscroll);
	}
	nscroll=null;
}
function initMenu(){
	if(!populated){
	var el = document.getElementById('tempMenu');
	var it =document.getElementById('tempitem');
	for(var p in menu){
		var item = menu[p];
		var m = el.cloneNode(true);
		m.id=p;
		var tb = m.getElementsByTagName('tbody');
		for(var i=0;i<item.length;i++){
			var itm = it.cloneNode(true);
			itm.id=p+item.mname;
			var tds = itm.getElementsByTagName('td');
			tds[1].innerHTML = item[i].mname;
			itm.onclick = new Function("menuClick('"+item[i].link+"')");
			tb[0].appendChild(itm);
		}
		document.body.appendChild(m);
		m.style.display="none";
		m.style.position="absolute";
	}
	var ns = document.getElementById('news');
	if(ns){
		ns.innerHTML="";
		var div1 = document.createElement('div');
		
		for(var i=0;i<news.length;i++){
			var s = document.createElement('div');
			s.style.textAlign="left";
			s.innerHTML="<b>" + (i+1) + " :</b> " + news[i];
			var br = document.createElement("hr");
			div1.appendChild(s);
			div1.appendChild(br);
		}
		div1.style.position="absolute";
		var div2 = div1.cloneNode(true);
		div1.id="N1";
		div2.id="N2";
		ns.appendChild(div1);
		ns.appendChild(div2);
		
		newsInit();
	}
	
	var tb = document.getElementById('tbanner');
	if(tb && window.tbanner && tbanner.text != ""){
		var a = document.createElement('a');
		a.innerHTML=tbanner.text;
		a.href=tbanner.link;
		//a.target="_blank";
		tb.innerHTML="";
		tb.appendChild(a);
	}
	var pop = document.getElementById('popmsg');
	if(pop && window.pmsg && pmsg.text != ""){
		pop.style.left='-1000px';
		pop.style.display="block";
		var pa = document.getElementById('popmsga');
		pa.innerHTML=pmsg.text;
		pa.href=pmsg.link;
		//pa.target="_blank";
		pop.style.left=(Math.floor(document.body.clientWidth/2)-175) +'px';
	}
	populated=true;
	}
}

function menuClick(link){
	window.open(link,"_self");
}
function showMenu(ev,el){
	if(!ev)ev=window.event;
	if(ev)stopEvent(ev);
	if(window.showing){
		window.showing.style.display="none";
	}
	var id = el.getAttribute("men");
	if(window.showing && id == window.showing.id){
		window.showing.style.display='block';
		return;
	}
	var m = document.getElementById(id);
        if(m){
	window.showing=m;
	var xy = findPos(el);
	m.style.left = xy.x+'px';
	m.style.top = (xy.y+15)+'px';
	m.style.display="block";
        }
}
function findPos(obj) {
    var curleft = curtop = 0;
    if (obj.offsetParent) {
        curleft = obj.offsetLeft
            curtop = obj.offsetTop
            while (obj = obj.offsetParent) {
                curleft += obj.offsetLeft
                    curtop += obj.offsetTop
            }
    }
    var n = {x:curleft,y:curtop};
    return n;
}
function hideMenu(){
if(window.showing)
	window.showing.style.display="none";
}
stopEvent = function(e) {
    if (e.stopPropagation) {
        e.preventDefault();
        e.stopPropagation();
    } else {
        e.cancelBubble = true;
        e.returnValue = false;
    }
}
var loadedwidow=true;
function onloadfun(){
  if(loadedwidow){
  loadedwidow=false;
  if(loadtimer)clearInterval(loadtimer);
  initMenu();
  }
}
// for Mozilla
if (document.addEventListener) {
	document.addEventListener("DOMContentLoaded", onloadfun, false);
}
// for IE
/*@cc_on @*/
/*@if (@_win32)
  document.write("<script id=ieonloadfun defer src=javascript:void(0)><\/script>");
  var script = document.getElementById("ieonloadfun");
  script.onreadystatechange = function() {
  	if (this.readyState == "complete") {
  		onloadfun();
  	}
  };
/*@end @*/

// for safari
if (/WebKit/i.test(navigator.userAgent)) {
	var loadtimer = setInterval(function() {
			if (/loaded|complete/.test(document.readyState)) {
				onloadfun();
			}
	},10);
}

/*
    json.js
    2006-10-05

    This file adds these methods to JavaScript:

        object.toJSONString()

            This method produces a JSON text from an object. The
            object must not contain any cyclical references.

        array.toJSONString()

            This method produces a JSON text from an array. The
            array must not contain any cyclical references.

        string.parseJSON()

            This method parses a JSON text to produce an object or
            array. It will return false if there is an error.

    It is expected that these methods will formally become part of the
    JavaScript Programming Language in the Fourth Edition of the
    ECMAScript standard.
*/
(function () {
    var m = {
            '\b': '\\b',
            '\t': '\\t',
            '\n': '\\n',
            '\f': '\\f',
            '\r': '\\r',
            '"' : '\\"',
            '\\': '\\\\'
        },
        s = {
            array: function (x) {
                var a = ['['], b, f, i, l = x.length, v;
                for (i = 0; i < l; i += 1) {
                    v = x[i];
                    f = s[typeof v];
                    if (f) {
                        v = f(v);
                        if (typeof v == 'string') {
                            if (b) {
                                a[a.length] = ',';
                            }
                            a[a.length] = v;
                            b = true;
                        }
                    }
                }
                a[a.length] = ']';
                return a.join('');
            },
            'boolean': function (x) {
                return String(x);
            },
            'null': function (x) {
                return "null";
            },
            number: function (x) {
                return isFinite(x) ? String(x) : 'null';
            },
            object: function (x) {
                if (x) {
                    if (x instanceof Array) {
                        return s.array(x);
                    }
                    var a = ['{'], b, f, i, v;
                    for (i in x) {
                        v = x[i];
                        f = s[typeof v];
                        if (f) {
                            v = f(v);
                            if (typeof v == 'string') {
                                if (b) {
                                    a[a.length] = ',';
                                }
                                a.push(s.string(i), ':', v);
                                b = true;
                            }
                        }
                    }
                    a[a.length] = '}';
                    return a.join('');
                }
                return 'null';
            },
            string: function (x) {
                if (/["\\\x00-\x1f]/.test(x)) {
                    x = x.replace(/([\x00-\x1f\\"])/g, function(a, b) {
                        var c = m[b];
                        if (c) {
                            return c;
                        }
                        c = b.charCodeAt();
                        return '\\u00' +
                            Math.floor(c / 16).toString(16) +
                            (c % 16).toString(16);
                    });
                }
                return '"' + x + '"';
            }
        };

    Object.prototype.toJSONString = function () {
        return s.object(this);
    };

    Array.prototype.toJSONString = function () {
        return s.array(this);
    };
})();

String.prototype.parseJSON = function () {
    try {
        return (/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(this)) &&
            eval('(' + this + ')');
    } catch (e) {
        return false;
    }
};
