/* New Page Right JS starts here */

var cur_id,pre_id;
var right_cur_id,right_pre_id;
var pre_color = '';

function showSlide( id)
{
	var content_slide = '';
	var tab_id = '';
	var cur_class = '',pre_class = '';

	content_slide = "contentslide_";
	tab_id = "linktab_";
	cur_class = "onclick_red";
	pre_class = "onclick_blue";

        cur_id = id;
        if(document.getElementById(content_slide+cur_id))
        {
                document.getElementById(content_slide+cur_id).style.display = 'block';
                document.getElementById(tab_id+cur_id).className = cur_class;

        }
        if( cur_id != pre_id )
        if(document.getElementById(content_slide+pre_id))
        {
                document.getElementById(content_slide+pre_id).style.display = 'none';
                document.getElementById(tab_id+pre_id).className = pre_class;
        }

        else
        {
                pre_id = '1';
                if( cur_id != pre_id )
                {
                        document.getElementById(content_slide+pre_id).style.display = 'none';
                        document.getElementById(tab_id+pre_id).className = pre_class;
                }

        }


        pre_id = cur_id;

        return;
}
function showRightSlide( id,cur_color,new_color,default_color )
{
	var color = '';
        var content_slide = '';
        var bg = '',arrow = '';
        var tab_id = '';
        content_slide = "rightslide_";
        tab_id = "clicktab_";
        bg = "bg_";
        arrow = "arrow_";
        color = 'color_';
	
	if(pre_color == '')
		pre_color = default_color;

        right_cur_id = id;
        if(document.getElementById(content_slide+right_cur_id))
        {
                document.getElementById(content_slide+right_cur_id).style.display = 'block';
                document.getElementById(bg+right_cur_id).style.backgroundColor = new_color;
                document.getElementById(arrow+right_cur_id).style.color = '#FFFFFF';
                document.getElementById(arrow+right_cur_id).style.backgroundColor = new_color;
		document.getElementById(arrow+right_cur_id).style.backgroundImage = "url(/img/arrow-down.gif)";
		document.getElementById(arrow+right_cur_id).style.backgroundRepeat = 'no-repeat';
		document.getElementById(arrow+right_cur_id).style.backgroundPosition = 'left center';
		document.getElementById(color+right_cur_id).style.backgroundColor = new_color;
        }
        if( right_cur_id != right_pre_id )
        if(document.getElementById(content_slide+right_pre_id))
        {
                document.getElementById(content_slide+right_pre_id).style.display = 'none';
                document.getElementById(bg+right_pre_id).style.backgroundColor = cur_color;
                document.getElementById(arrow+right_pre_id).style.backgroundColor = cur_color;
                document.getElementById(color+right_pre_id).style.backgroundColor = pre_color;                
		document.getElementById(arrow+right_pre_id).style.backgroundImage = "url(/img/brn-arrow-side.gif)";
                document.getElementById(arrow+right_pre_id).style.color = '#AB2E36';
		document.getElementById(arrow+right_pre_id).style.backgroundPosition = 'left center';
		document.getElementById(arrow+right_pre_id).style.backgroundRepeat = 'no-repeat';
        }
        else
        {
                right_pre_id = '1';
                if( right_cur_id != right_pre_id )
                {
                        document.getElementById(content_slide+right_pre_id).style.display = 'none';
		        document.getElementById(bg+right_pre_id).style.backgroundColor = cur_color;
		        document.getElementById(arrow+right_pre_id).style.backgroundColor = cur_color;
		        document.getElementById(color+right_pre_id).style.backgroundColor = pre_color;       
			document.getElementById(arrow+right_pre_id).style.backgroundImage = "url(/img/brn-arrow-side.gif)";
                	document.getElementById(arrow+right_pre_id).style.color = '#AB2E36';
			document.getElementById(arrow+right_pre_id).style.backgroundRepeat = 'no-repeat';
			document.getElementById(arrow+right_pre_id).style.backgroundPosition = 'left center';
                }

        }

        right_pre_id = right_cur_id;
	pre_color = new_color;

        return;
}


function invokeDidUMiss( category_id ) // for the category_id
{
       var pageURL = "/scripts/cms/getArticleDetails.php?category_id="+category_id+"&type=did-u-miss";
       var status = AjaxRequest.get(
               {
                       'url':pageURL
                       ,'onSuccess':function(req){
                                       content = req.responseText;
					if( content.length > 0 )
					{
						document.getElementById('did-u-miss').innerHTML = content;
					}
                                       
                               }
                       ,'onError':function(req){ document.getElementById('did-u-miss').innerHTML = '';}
               }
       );

	return;

}


function invokeOnLine( html_id )
{
	if(document.getElementById(html_id))
		html_id = html_id;
	else
		html_id = html_id.id;


	var index = document.getElementById(html_id).selectedIndex;
	var story_tag = document.getElementById(html_id).options[index].text;
	var pageURL = "/scripts/cms/getArticleDetails.php?tag_name="+story_tag+"&type=latest-story";
	var status = AjaxRequest.get(
			{
			'url':pageURL
			,'onSuccess':function(req){
			content = req.responseText;
			if( content.length > 0 )
			{
			document.getElementById('latest_story').innerHTML = content;
			}

			}
			,'onError':function(req){ document.getElementById('latest_story').innerHTML =''; }
			}
			);


	return;
}


/* New Page Right JS till here */






//for blinking
function doBlink() {
	var blink = document.all.tags("BLINK")
	for (var i=0; i<blink.length; i++)
		blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
}

function startBlink() {
	if (document.all)
		setInterval("doBlink()",500)
}
window.onload = startBlink;




//main index script


function doBlink() {
	var blink = document.all.tags("BLINK")
	for (var i=0; i<blink.length; i++)
		blink[i].style.visibility = blink[i].style.visibility == "" ? "hidden" : "" 
}

function startBlink() {
	if (document.all)
		setInterval("doBlink()",200)
}
window.onload = startBlink;





function isValid() {
 var mail=document.form1.email.value;
 if (mail.indexOf(' ')==-1 
      && 0<mail.indexOf('@')
      && mail.indexOf('@')+1 < mail.length
 ) return true;
 else alert ('Invalid email address!')
 return false;
}

 

function selecttext() 
{ 
document.form1.email.select()
} 



function isValidlifestyle() {
 var mail=document.formlifestyle.email.value;
 if (mail.indexOf(' ')==-1 
      && 0<mail.indexOf('@')
      && mail.indexOf('@')+1 < mail.length
 ) return true;
 else alert ('Invalid email address!')
 return false;
}

function isValidyoga() {
 var mail=document.formyoga.email.value;
 if (mail.indexOf(' ')==-1 
      && 0<mail.indexOf('@')
      && mail.indexOf('@')+1 < mail.length
 ) return true;
 else alert ('Invalid email address!')
 return false;
}

 

function selecttextlifestyle() 
{ 
document.formlifestyle.email.select()
} 
function selecttextyoga() 
{ 
document.formyoga.email.select()
} 


//Header script

function validate_form() 
		
  { 
   if((document.search.query.value=="") || 
(eval(document.search.query).value.charAt()==' ')) 
   { 
    window.alert("Enter an Keyword to Search"); 
    document.search.query.focus(); 
    return false; 
   } 
   
   return true; 
  } 

  
function selectname() 
{ 
document.loginForm.login.select()
} 

function dologin(form,login_url)
{
	loginname = form.login.value.split("@");
	if(loginname[1])
		form.login.value=loginname[0];
}

  
 function validate_gsearch() 
		
  { 
   if((document.gsearch.q.value=="") || 
(eval(document.gsearch.q).value.charAt()==' ')) 
   { 
    window.alert("Please enter the Keyword"); 
    document.gsearch.q.focus(); 
    return false; 
   } 
   
   return true; 
  } 



//ajax script

function change_class(id, newClass) {
  identity=document.getElementById(id);
  identity.className=newClass;
}

	function show_tab(tab){

      var tabs = ["","top_cont_1","top_cont_2","top_cont_3","top_cont_4"];

        for(i=1; i < tabs.length; i++){
          var obj = document.getElementById(tabs[i]);
          change_class("ttab_nav_"+i, "tab_main_inactive")
          obj.style.display = "none";
        }
          
        var obj = document.getElementById("top_cont_"+tab);
        obj.style.display = "block";
        change_class("ttab_nav_"+tab, "tab_main_active")
      }
	  
	
function show_tab1(tab){

      var tabs = ["","top_cont_1","top_cont_2","top_cont_3"];

        for(i=1; i < tabs.length; i++){
          var obj = document.getElementById(tabs[i]);
          change_class("ttab_nav_"+i, "tab_main_inactive")
          obj.style.display = "none";
        }
          
        var obj = document.getElementById("top_cont_"+tab);
        obj.style.display = "block";
        change_class("ttab_nav_"+tab, "tab_main_active")
      }
	  
function swaperTabs(swapLayer, numberOfTabs, stringNumber)
	{
		
		var tabs = numberOfTabs;
		var strs = stringNumber;
		var currLayer = swapLayer;
		var currLayerIndex = currLayer.substring(0,strs);
		
		for(i=1; i<=tabs; i++)
		{
			
			var currLayerRest = currLayerIndex + i;
			document.getElementById(currLayerRest).style.display='none';
		}
		document.getElementById(currLayer).style.display='block';
	}
  
  
  
function tabs(swapLayer, numberOfTabs, stringNumber)
{
var tabs = numberOfTabs;
var strs = stringNumber;
var currLayer = swapLayer;
var currLayerIndex = currLayer.substring(0,strs);

for(i=1; i<=tabs; i++)
{

var currLayerRest = currLayerIndex + i;
document.getElementById(currLayerRest).style.display='none';
}
document.getElementById(currLayer).style.display='block';
}


//chat script


function popUp( url ) {
	var doc = document.chat;
	var roomname;
	roomname=doc.room.value;
	//alert(roomname);
	/*for(var i =0; i<doc.room.length; i++)
	{
		if(doc.room[i].checked)
		{
		alert(doc.room[i].checked);
		roomname=doc.room[i].value;
		alert(roomname);
		}
	}*/
	window.open( "http://chat.oneindia.in/example3/index.php?username="+doc.username.value+"&roomname="+roomname,"chatWindow",'width=700,height=500,status=no,scrollbars=no, location=no,toolbar=no,resizable=no');
}




//ajax script

function change_class(id, newClass) {
  identity=document.getElementById(id);
  identity.className=newClass;
}

	function show_tab(tab){

      var tabs = ["","top_cont_1","top_cont_2","top_cont_3","top_cont_4"];

        for(i=1; i < tabs.length; i++){
          var obj = document.getElementById(tabs[i]);
          change_class("ttab_nav_"+i, "tab_main_inactive")
          obj.style.display = "none";
        }
          
        var obj = document.getElementById("top_cont_"+tab);
        obj.style.display = "block";
        change_class("ttab_nav_"+tab, "tab_main_active")
      }
	  
	  
	  
	  
	  //main page Insync Script
function changeMustWatch( name, arg, total_arg){
    for (var i=1;i <= total_arg;i++){
        if(i == arg ){
            document.getElementById( name+i+"_0").style.display="block";
            document.getElementById( name+i+"_1").style.display="none";
        }
        else{
            document.getElementById( name+i+"_0").style.display="none";
            document.getElementById( name+i+"_1").style.display="block";
        }
    }
}

//main page Gallery
	  
	function swaperTabs(swapLayer, numberOfTabs, stringNumber)
	{
		
		var tabs = numberOfTabs;
		var strs = stringNumber;
		var currLayer = swapLayer;
		var currLayerIndex = currLayer.substring(0,strs);
		
		for(i=1; i<=tabs; i++)
		{
			
			var currLayerRest = currLayerIndex + i;
			document.getElementById(currLayerRest).style.display='none';
		}
		document.getElementById(currLayer).style.display='block';
	}
  
  
  
  
function tabs(swapLayer, numberOfTabs, stringNumber)
{
var tabs = numberOfTabs;
var strs = stringNumber;
var currLayer = swapLayer;
var currLayerIndex = currLayer.substring(0,strs);

for(i=1; i<=tabs; i++)
{

var currLayerRest = currLayerIndex + i;
document.getElementById(currLayerRest).style.display='none';
}
document.getElementById(currLayer).style.display='block';
}


