home *** CD-ROM | disk | FTP | other *** search
/ familyradio.com / www.familyradio.com.tar / www.familyradio.com / js / effects.js < prev    next >
Text File  |  2011-01-18  |  12KB  |  339 lines

  1. // JavaScript Document
  2. /*For changeing text at the top left side*/
  3.   var i=0;
  4.   var lblContents = new Array();
  5.   lblContents[0]="Free web consultancy";
  6.   lblContents[1]="International Clients";
  7.   lblContents[2]="Special focus on web promotions";
  8.   lblContents[3]="Reliable communication facilities";
  9.   lblContents[4]="MNC company with multiple locality";
  10.   lblContents[5]="Good Delegation Skills";
  11.   lblContents[6]="Round the clock services";
  12.   
  13.  function clabel(){
  14.      
  15.   setInterval("printlbl()",2000);
  16.  }
  17.  
  18.  function printlbl(){
  19.  obj=document.getElementById("clbl");
  20. // obj.innerHTML = lblContents[i];
  21.  obj.innerHTML = lblContents[i];
  22.  if(i<6)
  23.     i++;
  24.  else
  25.     i=0;
  26. }
  27.  
  28. function gup( name )
  29. {
  30. name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  31. var regexS = "[\\?&]"+name+"=([^&#]*)";
  32. var regex = new RegExp( regexS );
  33. var results = regex.exec( window.location.href );
  34. if( results == null )
  35. return "";
  36. else
  37. return results[1];
  38. }
  39.  
  40.  
  41. /*for left slider*/
  42. var slideInUse = new Array();
  43.  
  44. function Slide(objId, options) {
  45.     this.obj = document.getElementById(objId);
  46.     this.duration = 1;
  47.     this.height = parseInt(this.obj.style.height);
  48.  
  49.     if(typeof options != 'undefined') { this.options = options; } else { this.options = {}; }
  50.     if(this.options.duration) { this.duration = this.options.duration; }
  51.         
  52.     this.up = function() {
  53.         this.curHeight = this.height;
  54.         this.newHeight = '1';
  55.         if(slideInUse[objId] != true) {
  56.             var finishTime = this.slide();
  57.             window.setTimeout("Slide('"+objId+"').finishup("+this.height+");",finishTime);
  58.         }
  59.     }
  60.     
  61.     this.down = function() {
  62.         this.newHeight = this.height;
  63.         this.curHeight = '1';
  64.         if(slideInUse[objId] != true) {
  65.             this.obj.style.height = '1px';
  66.             this.obj.style.display = 'block';
  67.             this.slide();
  68.         }
  69.     }
  70.     
  71.     this.slide = function() {
  72.         slideInUse[objId] = true;
  73.         var frames = 30 * duration; // Running at 30 fps
  74.  
  75.         var tIncrement = (duration*1000) / frames;
  76.         tIncrement = Math.round(tIncrement);
  77.         var sIncrement = (this.curHeight-this.newHeight) / frames;
  78.  
  79.         var frameSizes = new Array();
  80.         for(var i=0; i < frames; i++) {
  81.             if(i < frames/2) {
  82.                 frameSizes[i] = (sIncrement * (i/frames))*4;
  83.             } else {
  84.                 frameSizes[i] = (sIncrement * (1-(i/frames)))*4;
  85.             }
  86.         }
  87.         
  88.         for(var i=0; i < frames; i++) {
  89.             this.curHeight = this.curHeight - frameSizes[i];
  90.             window.setTimeout("document.getElementById('"+objId+"').style.height='"+Math.round(this.curHeight)+"px';",tIncrement * i);
  91.         }
  92.         
  93.         window.setTimeout("delete(slideInUse['"+objId+"']);",tIncrement * i);
  94.         
  95.         if(this.options.onComplete) {
  96.             window.setTimeout(this.options.onComplete, tIncrement * (i-2));
  97.         }
  98.         
  99.         return tIncrement * i;
  100.     }
  101.     
  102.     this.finishup = function(height) {
  103.         this.obj.style.display = 'none';
  104.         this.obj.style.height = height + 'px';
  105.     }
  106.     
  107.     return this;
  108. }
  109.  
  110. /*for menu*/
  111. var DDSPEED = 10;
  112. var DDTIMER = 15;
  113.  
  114. // main function to handle the mouse events //
  115. function ddMenu(id,d){
  116.   var h = document.getElementById(id + '-ddheader');
  117.   var c = document.getElementById(id + '-ddcontent');
  118.   clearInterval(c.timer);
  119.   if(d == 1){
  120.     clearTimeout(h.timer);
  121.     if(c.maxh && c.maxh <= c.offsetHeight){return}
  122.     else if(!c.maxh){
  123.       c.style.display = 'block';
  124.       c.style.height = 'auto';
  125.       c.maxh = c.offsetHeight;
  126.       c.style.height = '0px';
  127.       //c.style='overflow-x:hidden; filter: alpha(opacity=50)';
  128.       /*h.style.backgroundColor = '#ffffff';*/
  129.       /*363636 color for hovering over interational ministry tab*/
  130.       
  131. //      filter: alpha(opacity=55); -moz-opacity: .55; background-color:#EEE;
  132.     }
  133.     c.timer = setInterval(function(){ddSlide(c,1,h)},DDTIMER);
  134.   }else{
  135.     h.timer = setTimeout(function(){ddCollapse(c,h)},50);
  136.   }
  137.  
  138. }
  139.  
  140. // collapse the menu //
  141. function ddCollapse(c,h){
  142.   var i = h;    
  143. //  alert(i);
  144.   c.timer = setInterval(function(){ddSlide(c,-1,i)},DDTIMER);
  145. }
  146.  
  147. // cancel the collapse if a user rolls over the dropdown //
  148. function cancelHide(id){
  149.   var h = document.getElementById(id + '-ddheader');
  150.   var c = document.getElementById(id + '-ddcontent');
  151.   clearTimeout(h.timer);
  152.   clearInterval(c.timer);
  153.   if(c.offsetHeight < c.maxh){
  154.     c.timer = setInterval(function(){ddSlide(c,1,h)},DDTIMER);
  155.   }
  156. }
  157.  
  158. // incrementally expand/contract the dropdown and change the opacity //
  159. function ddSlide(c,d,i){
  160.   var currh = c.offsetHeight;
  161.   var dist;
  162.   var h = i;
  163.   //alert(h);
  164.  
  165.   if(d == 1){
  166.       //alert("asdsad");
  167. //      h.style.backgroundColor='#545454';
  168.  
  169.      //document.getElementById("website_design_menu-ddheader").style.background='#d9e1e4';       
  170.     dist = (Math.round((c.maxh - currh) / DDSPEED));
  171.       }else{
  172.           //alert("asdsad");
  173.           //h.style.background='#none';       
  174.     //document.getElementById("website_design_menu-ddheader").style.background='none';      
  175.     dist = (Math.round(currh / DDSPEED));
  176.   }
  177.   if(dist <= 1 && d == 1){
  178.     dist = 1;
  179.   }
  180.   c.style.height = currh + (dist * d) + 'px';
  181.  
  182.   if(c.style.height == 4 + 'px'){
  183.       c.style.height = 1 + 'px' ;
  184.       if(c.style.height == 1 + 'px'){
  185.          h.style.background = 'none';       
  186.       }
  187.   }
  188.   c.style.opacity = currh / c.maxh;
  189. //  c.style.opacity = 0.104167;
  190. //  alert(c.style.opacity);
  191.   c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
  192.   //c.style.filter = 'alpha(opacity=0.520833333)';
  193.   //c.style.filter = 'alpha(opacity=' 0.520833333 + ')';
  194.   //alert(c.style.filter);
  195.   if((currh < 2 && d != 1) || (currh > (c.maxh - 2) && d == 1)){
  196.     clearInterval(c.timer);
  197.   }
  198. }
  199.  
  200. /*for Scroll news*/
  201. // JavaScript Document
  202. var pausecontent=new Array()
  203. pausecontent[0]='<span class="stylecontent2_new"><a href="http://www.ipixcalicutmarathon.com/" target="_blank"><img src="india_web_design_ipixsolutions_images/ipix_marathon.jpg" border="0"/></a></span> '
  204.  
  205. pausecontent[1]='<span class="stylecontent1">December 2009</span><br /><span class="stylecontent2">"iPIX successfully implemented a complete Hospital Management Solution at Asian Reproductive Medicine Centre, Calicut by proving iPIX∩┐╜s domain expertise"</span> '
  206.  
  207. pausecontent[2]='<span class="stylecontent1">College Management Solution</span><br /><span class="stylecontent2">∩┐╜∩┐╜by keeping quality & adeptness, iPIX recently launched a smart CERP(College ERP) Solution.∩┐╜</span> '
  208.  
  209. /*pausecontent[3]='<span class="stylecontent1">June 2009</span><br /><span class="stylecontent2">An exclusive Hospital management solution has been developed and employed at Asian Reproductive Medicine Centre, Calicut. </span> '*/
  210.  
  211. //pausecontent[2]='<a href="http://www.cssdrive.com" target="_new">CSS Drive</a><br />Categorized CSS gallery and examples.'
  212.  
  213.  
  214. function pausescroller(content, divId, divClass, delay){
  215. this.content=content //message array content
  216. this.tickerid=divId //ID of ticker div to display information
  217. this.delay=delay //Delay between msg change, in miliseconds.
  218. this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
  219. this.hiddendivpointer=1 //index of message array for hidden div
  220. document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden"><div class="innerDiv" style="position: absolute; width: 100%;line-height:18px;" id="'+divId+'1">'+content[0]+'</div><div class="innerDiv" style="position: absolute; width: 100%; line-height:18px; visibility: hidden" id="'+divId+'2">'+content[1]+'</div></div>')
  221. var scrollerinstance=this
  222. if (window.addEventListener) //run onload in DOM2 browsers
  223. window.addEventListener("load", function(){scrollerinstance.initialize()}, false)
  224. else if (window.attachEvent) //run onload in IE5.5+
  225. window.attachEvent("onload", function(){scrollerinstance.initialize()})
  226. else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
  227. setTimeout(function(){scrollerinstance.initialize()}, 500)
  228. }
  229.  
  230. // -------------------------------------------------------------------
  231. // initialize()- Initialize scroller method.
  232. // -Get div objects, set initial positions, start up down animation
  233. // -------------------------------------------------------------------
  234.  
  235. pausescroller.prototype.initialize=function(){
  236. this.tickerdiv=document.getElementById(this.tickerid)
  237. this.visiblediv=document.getElementById(this.tickerid+"1")
  238. this.hiddendiv=document.getElementById(this.tickerid+"2")
  239. this.visibledivtop=parseInt(pausescroller.getCSSpadding(this.tickerdiv))
  240. //set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
  241. this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
  242. this.getinline(this.visiblediv, this.hiddendiv)
  243. this.hiddendiv.style.visibility="visible"
  244. var scrollerinstance=this
  245. document.getElementById(this.tickerid).onmouseover=function(){scrollerinstance.mouseoverBol=1}
  246. document.getElementById(this.tickerid).onmouseout=function(){scrollerinstance.mouseoverBol=0}
  247. if (window.attachEvent) //Clean up loose references in IE
  248. window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
  249. setTimeout(function(){scrollerinstance.animateup()}, this.delay)
  250. }
  251.  
  252.  
  253. // -------------------------------------------------------------------
  254. // animateup()- Move the two inner divs of the scroller up and in sync
  255. // -------------------------------------------------------------------
  256.  
  257. pausescroller.prototype.animateup=function(){
  258. var scrollerinstance=this
  259. if (parseInt(this.hiddendiv.style.top)>(this.visibledivtop+5)){
  260. this.visiblediv.style.top=parseInt(this.visiblediv.style.top)-5+"px"
  261. this.hiddendiv.style.top=parseInt(this.hiddendiv.style.top)-5+"px"
  262. setTimeout(function(){scrollerinstance.animateup()}, 50)
  263. }
  264. else{
  265. this.getinline(this.hiddendiv, this.visiblediv)
  266. this.swapdivs()
  267. setTimeout(function(){scrollerinstance.setmessage()}, this.delay)
  268. }
  269. }
  270.  
  271. // -------------------------------------------------------------------
  272. // swapdivs()- Swap between which is the visible and which is the hidden div
  273. // -------------------------------------------------------------------
  274.  
  275. pausescroller.prototype.swapdivs=function(){
  276. var tempcontainer=this.visiblediv
  277. this.visiblediv=this.hiddendiv
  278. this.hiddendiv=tempcontainer
  279. }
  280.  
  281. pausescroller.prototype.getinline=function(div1, div2){
  282. div1.style.top=this.visibledivtop+"px"
  283. div2.style.top=Math.max(div1.parentNode.offsetHeight, div1.offsetHeight)+"px"
  284. }
  285.  
  286. // -------------------------------------------------------------------
  287. // setmessage()- Populate the hidden div with the next message before it's visible
  288. // -------------------------------------------------------------------
  289.  
  290. pausescroller.prototype.setmessage=function(){
  291. var scrollerinstance=this
  292. if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
  293. setTimeout(function(){scrollerinstance.setmessage()}, 100)
  294. else{
  295. var i=this.hiddendivpointer
  296. var ceiling=this.content.length
  297. this.hiddendivpointer=(i+1>ceiling-1)? 0 : i+1
  298. this.hiddendiv.innerHTML=this.content[this.hiddendivpointer]
  299. this.animateup()
  300. }
  301. }
  302.  
  303. pausescroller.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
  304. if (tickerobj.currentStyle)
  305. return tickerobj.currentStyle["paddingTop"]
  306. else if (window.getComputedStyle) //if DOM2
  307. return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
  308. else
  309. return 0
  310. }
  311.  
  312. /*for left expand*/
  313. function ex1(){
  314.   Slide('mydiv1').down();
  315.   Slide('mydiv2').up();
  316.   Slide('mydiv3').up();
  317.   Slide('mydiv4').up();
  318.  }
  319.  
  320. function ex2(){
  321.   Slide('mydiv2').down();
  322.   Slide('mydiv1').up();
  323.   Slide('mydiv3').up();
  324.   Slide('mydiv4').up();    
  325. }
  326.  
  327. function ex3(){
  328.   Slide('mydiv3').down();
  329.   Slide('mydiv1').up();
  330.   Slide('mydiv2').up();
  331.   Slide('mydiv4').up();
  332. }
  333.  
  334. function ex4(){
  335.   Slide('mydiv4').down();
  336.   Slide('mydiv1').up();
  337.   Slide('mydiv2').up();
  338.   Slide('mydiv3').up();
  339. }