// JavaScript Document
////////////////TESTIMONIALS/////////////// 
var pausecontent=new Array()
var pcontent=new Array()
pausecontent[0]='After completing my MBA, I worked with HDFC Bank for some time. But I was always influenced by the entrepreneurial taste of my family. So, I was looking for an opportunity in the best growth sectors of India. Since then I am associated with TCY as its franchisee at Moga and success is the only word I can use to express this relationship.';
pcontent[0]='<strong>Neha</strong> <span>(Patiala Center)</span>';

pausecontent[1]='I have currently two centers operating at Phagwara and Banga. I always admire the consistent changes in the courseware that are brought which always help us stay ahead of our competitors. Thanks to TCY, our business is growing day by day.';
pcontent[1]='<strong>Rajeev Singh</strong> <span>(Phagwara & Banga Center )</span>';

pausecontent[2]='We were the first to bring a franchise concept in Jammu for Engineering and Medical Entrance in the early nineties. After that we established ourselves in Jammu and made a huge student base. We joined hands with TCY after learning the innovative and franchise -friendly model they have.';
pcontent[2]='<strong>Suneet Verma</strong> <span>(Jammu Center)</span>';



function pausescroller(content, divId, divClass, delay){
this.content=content //message array content
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
this.hiddendivpointer=1 //index of message array for hidden div

/*var divData = '<div id="pscroller1Testing">'
   divData += '<div class="testimonial_text">'
   divData += '<span class="div1">'
   divData += '<img width="26" height="19" title="Testimonial" alt="Testimonial" src="/india/images/testimonial_comm.gif">'
   divData += '</span>Data'
   divData += '<span class="div2">'
   divData += '<img width="26" height="19" title="Testimonial" alt="Testimonial" src="/india/images/testimonial_comm_right.gif">'
   divData += '</span>'
   divData += '</div>'
   divData += '<div class="testimonial_NAME">name</div>'
   divData += '</div>'*/
divData = '<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden">';
   divData += '<div class="innerDiv" style="position: absolute; width: 100%;left:0px; top:0px;" id="'+divId+'1">'
   divData += '<div class="testimonial_text">'
   divData += ''+content[0]+''
   divData += '</div>'
   divData += '<div class="testimonial_NAME">'+pcontent[0]+'</div>'
   divData += '</div><div class="innerDiv" style="position: absolute; width: 100%;left:0px; top:0px; visibility: hidden" id="'+divId+'2">'
   divData += '<div class="testimonial_text">'
   divData += ''+content[1]+''
   divData += '</div><div class="testimonial_NAME">'+pcontent[1]+'</div></div></div>'
document.write(divData)
var scrollerinstance=this
if (window.addEventListener) //run onload in DOM2 browsers
window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
else if (window.attachEvent) //run onload in IE5.5+
window.attachEvent("onload", function(){scrollerinstance.initialize()})
else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
setTimeout(function(){scrollerinstance.initialize()}, 200)
}


// -------------------------------------------------------------------
// initialize()- Initialize scroller method.
// -Get div objects, set initial positions, start up down animation
// -------------------------------------------------------------------

pausescroller.prototype.initialize=function(){
this.tickerdiv=document.getElementById(this.tickerid)
this.visiblediv=document.getElementById(this.tickerid+"1")
this.hiddendiv=document.getElementById(this.tickerid+"2")
this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
this.getinline(this.visiblediv, this.hiddendiv)
this.hiddendiv.style.visibility="visible"
var scrollerinstance=this
document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
if (window.attachEvent) //Clean up loose references in IE
window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}
// -------------------------------------------------------------------
// animateup()- Move the two inner divs of the scroller up and in sync
// -------------------------------------------------------------------
pausescroller.prototype.animateup=function(){
var scrollerinstance=this
if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
setTimeout(function(){scrollerinstance.animateup()}, 220)
}
else{
this.getinline(this.hiddendiv, this.visiblediv)
this.swapdivs()
setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
}
}
// -------------------------------------------------------------------
// swapdivs()- Swap between which is the visible and which is the hidden div
// -------------------------------------------------------------------
pausescroller.prototype.swapdivs=function(){
var tempcontainer=this.visiblediv
this.visiblediv=this.hiddendiv
this.hiddendiv=tempcontainer
}
pausescroller.prototype.getinline=function(div1, div2){
div1.style.top=this.visibledivtop+"px"
div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
}
// -------------------------------------------------------------------
// setmessage()- Populate the hidden div with the next message before it's visible
// -------------------------------------------------------------------
pausescroller.prototype.setmessage=function(){
var scrollerinstance=this
if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
setTimeout(function(){scrollerinstance.setmessage()}, 150)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML='<div class="testimonial_text">'+this.content[this.hiddendivpointer]+'</div><div class="testimonial_NAME">'+pcontent[this.hiddendivpointer]+'</div>'

this.animateup()
}
}
pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
if (tickerobj.currentStyle)
return tickerobj.currentStyle["paddingTop"]
else if (window.getComputedStyle) //if DOM2
return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
else
return 0
}



var myvariable1 =0;myvariable2 =0;myvariable3 =0;course1 =0;course2 =0;course3 =0;course4 =0;year1 =0;year2 =0;year3 =0;year4 =0;
var total1 =0;total2 =0;allcourse=0; allYear1=0; allyear2 =0;
function variable(form) 
{
	document.form.Z1.value = Math.round(document.form.Y1.value*1.2);
	document.form.Z2.value = Math.round(document.form.Y2.value*1.2);
	document.form.Z3.value = Math.round(document.form.Y3.value*1.2);
	document.form.Z4.value = Math.round(document.form.Y4.value*1.2);
	document.form.Z5.value = Math.round(document.form.Y5.value*1.2);
	//document.form.Z6.value = Math.round(document.form.Y6.value*1.2);
	document.form.Z7.value = Math.round(document.form.Y7.value*1.2);
	document.form.Z8.value = Math.round(document.form.Y8.value*1.2);
	document.form.Z9.value = Math.round(document.form.Y9.value*1.2);
	document.form.Z10.value = Math.round(document.form.Y10.value*1.2);
	document.form.Z11.value = Math.round(document.form.Y11.value*1.2);
			
	document.form.CY1.value = ((Math.round(document.form.CT1.value*1))*(Math.round(document.form.Y1.value*1)));
	document.form.CY2.value = ((Math.round(document.form.CT2.value*1))*(Math.round(document.form.Y2.value*1)));
	document.form.CY3.value = ((Math.round(document.form.CT3.value*1))*(Math.round(document.form.Y3.value*1)));
	document.form.CY4.value = ((Math.round(document.form.CT4.value*1))*(Math.round(document.form.Y4.value*1)));
	document.form.CY5.value = ((Math.round(document.form.CT5.value*1))*(Math.round(document.form.Y5.value*1)));
	//document.form.CY6.value = ((Math.round(document.form.CT6.value*1))*(Math.round(document.form.Y6.value*1)));
	document.form.CY7.value = ((Math.round(document.form.CT7.value*1))*(Math.round(document.form.Y7.value*1)));
	document.form.CY8.value = ((Math.round(document.form.CT8.value*1))*(Math.round(document.form.Y8.value*1)));
	document.form.CY9.value = ((Math.round(document.form.CT9.value*1))*(Math.round(document.form.Y9.value*1)));
	document.form.CY10.value = ((Math.round(document.form.CT10.value*1))*(Math.round(document.form.Y10.value*1)));
	document.form.CY11.value = ((Math.round(document.form.CT11.value*1))*(Math.round(document.form.Y11.value*1)));


	document.form.CZ1.value = ((Math.round(document.form.CT1.value*1))*(Math.round(document.form.Z1.value*1)));
	document.form.CZ2.value = ((Math.round(document.form.CT2.value*1))*(Math.round(document.form.Z2.value*1)));
	document.form.CZ3.value = ((Math.round(document.form.CT3.value*1))*(Math.round(document.form.Z3.value*1)));
	document.form.CZ4.value = ((Math.round(document.form.CT4.value*1))*(Math.round(document.form.Z4.value*1)));
	document.form.CZ5.value = ((Math.round(document.form.CT5.value*1))*(Math.round(document.form.Z5.value*1)));
	//document.form.CZ6.value = ((Math.round(document.form.CT6.value*1))*(Math.round(document.form.Z6.value*1)));
	document.form.CZ7.value = ((Math.round(document.form.CT7.value*1))*(Math.round(document.form.Z7.value*1)));
	document.form.CZ8.value = ((Math.round(document.form.CT8.value*1))*(Math.round(document.form.Z8.value*1)));
	document.form.CZ9.value = ((Math.round(document.form.CT9.value*1))*(Math.round(document.form.Z9.value*1)));
	document.form.CZ10.value = ((Math.round(document.form.CT10.value*1))*(Math.round(document.form.Z10.value*1)));
	document.form.CZ11.value = ((Math.round(document.form.CT11.value*1))*(Math.round(document.form.Z11.value*1)));

	allyear1 = ((document.form.Y1.value*1) + (document.form.Y2.value *1) + (document.form.Y3.value * 1) + (document.form.Y4.value *1) + (document.form.Y5.value *1) + (document.form.Y7.value *1) + (document.form.Y8.value *1) + (document.form.Y9.value *1) + (document.form.Y10.value *1) + (document.form.Y11.value *1));
	document.form.ytotal.value = Math.round(allyear1);

	allyear2 = ((document.form.Z1.value*1) + (document.form.Z2.value *1) + (document.form.Z3.value * 1) + (document.form.Z4.value *1) + (document.form.Z5.value *1) + (document.form.Z7.value *1) + (document.form.Z8.value *1) + (document.form.Z9.value *1) + (document.form.Z10.value *1) + (document.form.Z11.value *1));
	document.form.ztotal.value = Math.round(allyear2);
			
	total1 = ((document.form.CY1.value*1) + (document.form.CY2.value *1) + (document.form.CY3.value * 1) + (document.form.CY4.value *1) + (document.form.CY5.value *1) + (document.form.CY7.value *1) + (document.form.CY8.value *1) + (document.form.CY9.value *1) + (document.form.CY10.value *1) + (document.form.CY11.value *1));
	document.form.cytotal.value = Math.round(total1);

	total2 = ((document.form.CZ1.value*1) + (document.form.CZ2.value *1) + (document.form.CZ3.value * 1) + (document.form.CZ4.value *1) + (document.form.CZ5.value *1) + (document.form.CZ7.value *1) + (document.form.CZ8.value *1)  + (document.form.CZ9.value *1) + (document.form.CZ10.value *1) + (document.form.CZ11.value *1));
	document.form.cztotal.value = Math.round(total2);

}


//*********VALIDATTION********//
function validate1(email){
   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   if(reg.test(email) == false) return false;
   else return true;
}
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;

function isInteger(s){   var i;
    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;
}

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;
}
function trim(s){   
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not a whitespace, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (c != " ") returnString += c;
    }
    return returnString;
}
function checkInternationalPhone(strPhone){
var bracket=3
strPhone=trim(strPhone)
if(strPhone.indexOf("+")>1) return false
if(strPhone.indexOf("(")!=-1 && strPhone.indexOf(")")==-1)return false
if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}
/***ENQUERY**/
function validate()
{
var name = document.enquiry.fname;
if(name.value.length=="")
{
alert("Please enter your name");
name.focus();
return false;
}
var address = document.enquiry.address;
if(address.value.length=="")
{
alert("Please enter address");
address.focus();
return false;
}
var city = document.enquiry.city;
if(city.value.length=="")
{
alert("Please enter city");
city.focus();
return false;
}											
var email=document.enquiry.email;
if (!emailCheck(document.enquiry.email.value))
{
alert("Please fill Correct Email Address")
email.focus()
email.select()
return false
}
var Phone=document.enquiry.phonenumber;
	if ((Phone.value==null)||(Phone.value=="")){
		alert("Please Enter your Phone Number")
		Phone.focus()
		return false
	}
	if (checkInternationalPhone(Phone.value)==false){
		alert("Please Enter a Valid Phone Number")
		Phone.value=""
		Phone.focus()
		return false
	}

var eduqual = document.enquiry.eduqual;
if(eduqual.value.length=="")
{
alert("Please fill Educational qualification");
eduqual.focus();
return false;
}

var venture = document.enquiry.venture;
if(venture.value.length=="")
{
alert("Please select venture");
venture.focus();
return false;
}	
if(document.enquiry.security_code)
{
	var security = document.enquiry.security_code;
	if(security.value=="Enter the code shown")
	{
	alert("Please fill the security code!");
	security.focus();
	return false;
	}
}

}
function emailCheck (emailStr) {
 var sw = true;
 var checkTLD=0;
 var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
 var emailPat=/^(.+)@(.+)$/;
 var specialChars="\\(\\)><@,;\\\\\\\"\\.\\[\\]";
 var validChars="\[^\\s" + specialChars + "\]";
 var quotedUser="(\"[^\"]*\")";
 var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
 var atom=validChars + '+';
 var word="(" + atom + "|" + quotedUser + ")";
 var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
 var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
 var matchArray=emailStr.match(emailPat);
 if (matchArray==null) { sw = false; return sw; }
 var user=matchArray[1];
 var domain=matchArray[2];
 for (i=0; i<user.length; i++) {
  if (user.charCodeAt(i)>127) sw = false;
 }
 for (i=0; i<domain.length; i++) {
  if (domain.charCodeAt(i)>127) sw = false;
 }
 if (user.match(userPat)==null) sw = false;
 var IPArray=domain.match(ipDomainPat);
 if (IPArray!=null) {
  for (var i=1;i<=4;i++) {
   if (IPArray[i]>255) sw = false;
  }
  return true;
 }
 var atomPat=new RegExp("^" + atom + "$");
 var domArr=domain.split(".");
 var len=domArr.length;
 for (i=0;i<len;i++) {
  if (domArr[i].search(atomPat)==-1) sw = false;
 }
if (checkTLD && domArr[domArr.length-1].length!=2 &&
domArr[domArr.length-1].search(knownDomsPat)==-1) sw = false;
if (len<2) sw = false;
return sw;
}
function changeexp(value)
{
	if(value=="yes")
	{
	document.getElementById('experince').style.display="block";
	}
	else if(value=="no" || value=='')
	{
	document.getElementById('experince').style.display="none";
	}
	else
	{
	return true;
	}
}
function trim(str)
{
	if(!str || typeof str != 'string')
		return null;

	return str.replace(/^[\s]+/,'').replace(/[\s]+$/,'').replace(/[\s]{2,}/,' ');
}



function chkFrmFields(frmObj){
	var flag = 0;
	var msg = 'All fields are compulsary. Please provide:';
	var f1 = trim(frmObj.first_name.value);
	var q1 = trim(frmObj.prefrdCallTime.value);
	var f2 = trim(frmObj.emailAddr.value);
	var f3 = trim(frmObj.phone.value);
	var cpch = trim(frmObj.captcha.value);
	var location = trim(frmObj.location.value);
	if(f1 == '' || f1 == 'Name'){ ++flag; msg += '\n\t Your Name'; }
	if(q1 == '' || q1 == 'Preferred time to call'){ ++flag; msg += '\n\t Preferred time to call'; }
	if(f2 == '' || f2 == 'Email/Username' || validate1(f2) == false){ ++flag; msg += '\n\t Your Email Address'; }
	if(f3 == '' || f3 == 'Mobile'){ ++flag; msg += '\n\t Your Mobile'; }
	if(f3!='' &&  f3 != 'Mobile' && checkInternationalPhone(f3)==false){ ++flag; msg += '\n\t Enter correct mobile number. (e.g. - 9123123123)'; }
	if(location == '' || location == 'Preferred Location'){ ++flag; msg += '\n\t Your Preferred Location'; }
	if(cpch == '' || cpch == 'Enter Code'){ ++flag; msg += '\n\t Security code as mentioned'; }
	if(flag>0){ alert(msg); return false; }
}
/**FOR CLASSROOM PAGE**/
function chkFrmFieldsNew(frmObj){
	var flag = 0;
	var msg = 'All fields are compulsary. Please provide:';
	var f1 = trim(frmObj.first_name.value);
	var q1 = trim(frmObj.PhoneNum.value);
	var f2 = trim(frmObj.emailAddr.value);
	var f3 = trim(frmObj.CourseName.value);
	var cpch = trim(frmObj.captcha.value);
	var location = trim(frmObj.franchiseName.value);
	if(f1 == '' || f1 == 'Name'){ 
	++flag; msg += '\n\t Your Name'; 
	}
	if(q1 == '' || q1 == 'Phone'){
	++flag; msg += '\n\t Your Mobile'; 
	}
	if(q1!='' &&  q1 != 'Phone' && checkInternationalPhone(q1)==false){ 
	++flag; msg += '\n\t Enter correct mobile number. (e.g. - 9123123123)'; 
	frmObj.PhoneNum.value='Phone';
	frmObj.PhoneNum.style.color='#AAAAAA';
	}
	if(f2 == '' || f2 == 'Email' || validate1(f2) == false){ 
	++flag; msg += '\n\t Your Email Address'; 
	frmObj.emailAddr.value='Email';
	frmObj.emailAddr.style.color='#AAAAAA';
	}
	if(location == '' || location == 'Nearest Centre'){ 
	++flag; msg += '\n\t Nearest Centre'; 
	}
	if(f3 == '' || f3 == 'Course'){ ++flag; msg += '\n\t Your Course'; }
	if(cpch == '' || cpch == 'Enter Code'){ ++flag; msg += '\n\t Security code as mentioned'; }
	if(flag>0){ alert(msg); return false; }
}
/**END FOR CLASSROOM PAGE**/
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;
function checkInternationalPhone(strPhone){
var bracket=3
strPhone=trim(strPhone)
if(strPhone.indexOf("+")>1) return false
if(strPhone.indexOf("(")!=-1 && strPhone.indexOf(")")==-1)return false
if(strPhone.indexOf("(")==-1 && strPhone.indexOf(")")!=-1)return false
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length == minDigitsInIPhoneNumber);
}
function isInteger(s){
	var i;
    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;
}
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;
}
//*********VALIDATTION********//
//***************************//


function trim(txt){
return txt.replace(/^\s+|\s+$/g,"");
}
function selCourse(frId){
	var servers = document.location.hostname;
	document.getElementById('courseDiv').innerHTML='<img src="http://'+servers+'/india/images/loading55by21.gif" alt="Loading" title="Loading" width="55" height="21" >';
	document.getElementById('courseDiv').style.display='block';
		xmlHttp94=GetXmlHttpObject_tcybar();
		var url="http://"+servers+"/ajax-classroom.php";
		url=url+"?frId="+frId+"&sid="+Math.random();
		xmlHttp94.onreadystatechange=function(){
			if (xmlHttp94.readyState==4){
				document.getElementById('courseDiv').innerHTML = xmlHttp94.responseText;
			}
		}						
	xmlHttp94.open("GET",url,true);
	xmlHttp94.send(null); 
}
