//Set tab in Library
function setTab(index)
{
    var allLinks= $('ul#tnb').children('li').children('a');
    allLinks.removeClass('selected');
    $(allLinks[index-1]).addClass('selected');
} 
/*ends*/

function showTab(obj,divID)
{
	$('#'+divID).parent().children().hide();
	$(obj).parent().children().removeClass();
	$('#'+divID).slideDown();
	$(obj).addClass('selected');	
}

function slideDown(divID)
{
	jQuery('div#'+divID).slideDown();
}
function slideUp(divID)
{
	jQuery('div#'+divID).slideUp();
}
function fadeIn(divID)
{
	jQuery('div#'+divID).fadeIn('fast');
}
function fadeOut(divID)
{
	jQuery('div#'+divID).fadeOut('fast');
}
function toggleDiv(divID)
{
	if(document.getElementById(divID).style.display=='none')
	jQuery('div#'+divID).fadeIn();
	else
	jQuery('div#'+divID).fadeOut();
}

function toggleDivLink(sender,divID)
{
	if(document.getElementById(divID).style.display=='none')
	{
		jQuery('div#'+divID).slideDown();
		sender.getElementsByTagName('img')[0].src='../images/TabL.png';
	}
	else
	{
		jQuery('div#'+divID).slideUp();
		sender.getElementsByTagName('img')[0].src='../images/TabR.png';
	}
}
function onlyShow(divId)
{
	document.getElementById(divId).style.display="";
}
function onlyHide(divId)
{
	document.getElementById(divId).style.display="none";
}


//Image Slider Home JS
var slideContainerID;
var linkContainerID;
var slideTimer;
var slideIndex=-1;
var pagerID;
var numSlides;
function showSlide()
{
	if(slideTimer)
	clearInterval(slideTimer);
	slideIndex++;

	var allSlides=$('#'+slideContainerID).children();

	numSlides=allSlides.length;
	allSlides.hide();
	if(slideIndex>numSlides-1)
	slideIndex=0;
	$(allSlides[slideIndex]).fadeIn('slow');
	if(document.getElementById(linkContainerID))
	{
		var allLinks=document.getElementById(linkContainerID).getElementsByTagName('a');
		for(var loop=0;loop<allLinks.length;loop++)
		$(allLinks[loop]).removeClass();
		$(allLinks[slideIndex]).addClass('selected');
	}
	if(document.getElementById(pagerID))
	{
		$('#'+pagerID).html((slideIndex+1)+'/'+numSlides);
	}
	slideTimer=setTimeout(showSlide,8000);
}

function gotoAndPlay(slideToPlay)
{
	slideIndex=slideToPlay-1;
	showSlide();
}

function nextSlide()
{
	showSlide();
}
function prevSlide()
{
	slideIndex=slideIndex-2;
	if(slideIndex<-1)
	slideIndex=numSlides-2;
	showSlide();
}

//Dropdown Starts
var menu=function(){
	var t=15,z=50,s=6,a;
	function dd(n){this.n=n; this.h=[]; this.c=[]}
	dd.prototype.init=function(p,c){
		a=c; var w=document.getElementById(p), s=w.getElementsByTagName('ul'), l=s.length, i=0;
		for(i;i<l;i++){
			var h=s[i].parentNode; this.h[i]=h; this.c[i]=s[i];
			h.onmouseover=new Function(this.n+'.st('+i+',true)');
			h.onmouseout=new Function(this.n+'.st('+i+')');
		}
	}
	dd.prototype.st=function(x,f){
		var c=this.c[x], h=this.h[x], p=h.getElementsByTagName('a')[0];
		clearInterval(c.t); c.style.overflow='hidden';
		if(f){
			p.className+=' '+a;
			if(!c.mh){c.style.display='block'; c.style.height=''; c.mh=c.offsetHeight; c.style.height=0}
			if(c.mh==c.offsetHeight){c.style.overflow='visible'}
			else{c.style.zIndex=z; z++; c.t=setInterval(function(){sl(c,1)},t)}
		}else{p.className=p.className.replace(a,''); c.t=setInterval(function(){sl(c,-1)},t)}
	}
	function sl(c,f){
		var h=c.offsetHeight;
		if((h<=0&&f!=1)||(h>=c.mh&&f==1)){
			if(f==1){c.style.filter=''; c.style.opacity=1; c.style.overflow='visible'}
			clearInterval(c.t); return
		}
		var d=(f==1)?Math.ceil((c.mh-h)/s):Math.ceil(h/s), o=h/c.mh;
		c.style.opacity=o; c.style.filter='alpha(opacity='+(o*100)+')';
		c.style.height=h+(d*f)+'px'
	}
	return{dd:dd}
}();


   function myFocus(element) {
     if (element.value == element.defaultValue) {
       element.value = '';
     }
   }
   function myBlur(element) {
     if (element.value == '') {
       element.value = element.defaultValue;
     }
   }

//Scroll News Home Page
//index pages news
var pausecontent=new Array()

pausecontent[0]='<p><a  class="feat-prog" href="./news/featured_program.html">SpeechTek 2011   </a></p><span><b> Aug 8 - 10, 2011, NY, USA </b></span>'
pausecontent[1]='<p><a  class="feat-prog" href="./news/featured_program.html">Interop 2011</a></p><span><b>Oct 3 - 7, 2011, NY, USA </b></span>' 
pausecontent[2]='<p><a  class="feat-prog" href="./news/featured_program.html">Content & Communications World   </a></p><span><b> Oct 12 - 13, 2011, NY, USA</b></span>'


//index pages what's our client say
var whatourclient=new Array()
whatourclient[0]='<p><a href="http://www.diaspark.com/news/client_testimonials.html#11" target="_blank"> I wanted to take this opportunity to offer my most sincere appreciation for the work Diaspark has done.</a></p>' 
whatourclient[1]='<p><a href="http://www.diaspark.com/news/client_testimonials.html#12" target="_blank">The overall experience of working with Diaspark was excellent.</a></p>' 
whatourclient[2]='<p><a href="http://www.diaspark.com/news/client_testimonials.html#13" target="_blank">The feedback so far has been good.</a></p>' 
whatourclient[3]='<p><a href="http://www.diaspark.com/news/client_testimonials.html#14" target="_blank">Thanks Team for doing a great job on releasing the Billing SDK builds.</a></p>' 
whatourclient[4]='<p><a href="http://www.diaspark.com/news/client_testimonials.html#15" target="_blank"> Diasparks team of professionals</a></p>' 
whatourclient[5]='<p><a href="http://www.diaspark.com/news/client_testimonials.html#16" target="_blank"> Looks like your creative guy is reading my mind</a></p>' 

//resources pages news
var pausecontent_new1=new Array()
pausecontent_new1[0]='<p><a href="http://www.diaspark.com/news/index.htm#aug2011">Diaspark Inc., a global provider of IT services and solutions</a></p>'
pausecontent_new1[1]='<p><a href="http://www.diaspark.com/news/index.htm#26july2011">Stunning Performance by Diasparks Mobile Practice Team</a></p>'
pausecontent_new1[2]='<p><a href="http://www.diaspark.com/news/index.htm#july2011">Diaspark at NAHC and HHFMA 17th Annual Financial Management Conference & Exposition </a></p>'
pausecontent_new1[3]='<p><a href="http://www.diaspark.com/news/index.htm#june2011">Diasparks employee presents a research paper at 3rd Conference on Excellence in Research and Education 2011 hosted by IIM, Indore</a></p>'
pausecontent_new1[4]='<p><a href="http://www.diaspark.com/news/index.htm#2june2011">Diaspark at JCK Las Vegas </a></p>'




//resources pages news
var newuploads=new Array()
newuploads[0]='<p><a href="http://www.diaspark.com/news/whitepapers.aspx">Paradigm Shift in the Software Testing Outsourcing trend - a New road Ahead </a></p>'
newuploads[1]='<p><a href="http://www.diaspark.com/news/casestudy.aspx">Diaspark helped a leading Home Healthcare Software provider Re-engineer their Home Health Agency Management System </a></p>'
newuploads[2]='<p><a href="http://www.diaspark.com/news/brochures.aspx">Order Entry is a breeze and selling is easier with Diaspark Catalog2go app on iPad </a></p>'




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
document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%; height: 100%;" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; height: 100%; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
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()}, 500)
}

// -------------------------------------------------------------------
// 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=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()}, 70)
}
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()}, 100)
else{
var i=this.hiddendivpointer
var ceiling=this.content.length
this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
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
}





