 function setupFadeLinks() {
  arrFadeLinks[0] = "/introduction/safety-privacy-security.php";
  arrFadeTitles[0] = "Only site to be ISO 9001:2000, VeriSign, TRUSTe Certified";
  arrFadeLinks[1] = "/introduction/why-we-are-no1.php";
  arrFadeTitles[1] = "Ranked the most visited matrimonial website in the world! - Ranking.com";
  arrFadeLinks[2] = "/introduction/why-we-are-no1.php";
  arrFadeTitles[2] = "\"Most preferred online matrimonial site for Indians\" - JuxtConsult";
}

// You can also play with these variables to control fade speed, fade color, and how fast the colors jump.

var m_FadeOut = 255;
var m_FadeIn=0;
var m_Fade = 0;
var m_FadeStep = 3;
var m_FadeWait = 1600;
var m_bFadeOut = true;

var m_iFadeInterval;

//window.onload = Fadewl;

var arrFadeLinks;
var arrFadeTitles;
var arrFadeCursor = 0;
var arrFadeMax;

function Fadewl() {
  m_iFadeInterval = setInterval(fade_ontimer, 10);
  arrFadeLinks = new Array();
  arrFadeTitles = new Array();
  setupFadeLinks();
  arrFadeMax = arrFadeLinks.length-1;
  setFadeLink();
}

function setFadeLink() {
  var ilink = document.getElementById("fade_link");
  ilink.innerHTML = arrFadeTitles[arrFadeCursor];
  ilink.href = arrFadeLinks[arrFadeCursor];
}

function fade_ontimer() {
  if (m_bFadeOut) {
    m_Fade+=m_FadeStep;
    if (m_Fade>m_FadeOut) {
      arrFadeCursor++;
      if (arrFadeCursor>arrFadeMax)
        arrFadeCursor=0;
      setFadeLink();
      m_bFadeOut = false;
    }
  } else {
    m_Fade-=m_FadeStep;
    if (m_Fade<m_FadeIn) {
      clearInterval(m_iFadeInterval);
      setTimeout(Faderesume, m_FadeWait);
      m_bFadeOut=true;
    }
  }
  var ilink = document.getElementById("fade_link");
  if ((m_Fade<m_FadeOut)&&(m_Fade>m_FadeIn))
    ilink.style.color = "#" + ToHex(m_Fade);
}

function Faderesume() {
  m_iFadeInterval = setInterval(fade_ontimer, 10);
}

function ToHex(strValue) {
  try {
    var result= (parseInt(strValue).toString(16));

    while (result.length !=2)
            result= ("0" +result);
    result = result + result + result;
    return result.toUpperCase();
  }
  catch(e)
  {
  }
}







function show_hide_login_layer() {
	clear_err_divs();
	var args = show_hide_login_layer.arguments;
	var do_what = args[0];
	if (do_what=='show') {
		//show_hide_more_layer('hide');
		//show_hide_profile_search_layer('hide');
		//enable_disable_form(document.forms['quicksearch'], 'disable');
		document.getElementById('login_layer').style.display = 'block';
		document.loginpage.login.focus();
	}
	else if (do_what=='hide') {
		if (document.loginpage) {
			document.loginpage.login.value = '';
			document.loginpage.password.value = '';
			//document.getElementById('id_spacer_1').style.display = 'block';
			document.getElementById('login_layer').style.display = 'none';
			//enable_disable_form(document.forms['quicksearch'], 'enable');
		}
	}
}

function validate_login_form() {
	clear_err_divs();
	var flag = false;
	if (document.loginpage.login.value=='') {
		document.getElementById('id_spacer_1').style.padding='3px';
		document.getElementById('login_err_div').style.display='block';
		document.getElementById('login_err_div').innerHTML='Please specify Email.';
		flag = true;
	}
	if (document.loginpage.password.value=='') {
		document.getElementById('password_err_div').style.display='block';
		document.getElementById('password_err_div').innerHTML='Please specify Password.';
		flag = true;
	}
	if (flag) {
		return false;
	}
	return true;
}
function clear_err_divs() {
	if (document.getElementById('login_err_div')) {
		document.getElementById('login_err_div').innerHTML = '';
	}
	if (document.getElementById('password_err_div')) {
		document.getElementById('password_err_div').innerHTML = '';
	}
	if (document.getElementById('profile_id_err_div')) {
		document.getElementById('profile_id_err_div').innerHTML = '';
	}
}



/*
*	function to set the timeout for active subtab to close
*
* @param  string  tabId		Top tab id which will get activated on clicking Page link
* @return
*
* @usage $var_name = function_name($param);
*/
var t
var timeout	= 20000;

function subTabTimeout(subtabId,tabId,arrowId){
t = setTimeout('changeSubTabDisplay(\''+subtabId+'\',\''+tabId+'\',\''+arrowId+'\')',timeout);
}

function mcancelclosetime()
{
	if(t)
	{
		window.clearTimeout(t);
		t = null;
	}
}


var allTopTabs = []
var allSubTabs = []


function onloadAllTabs()
{
	//to take care of window resizing
	var panel = document.getElementById("nav_wrap").getElementsByTagName("div");

	//set the all the toptabs and subtabs in respective arrays
	for(var i=0;i<panel.length;i++)
	{
		if(panel.item(i).getAttribute( 'name' ) == 'toptab' )
		{
			allTopTabs.push( panel.item(i) );
		}
		if(panel.item(i).getAttribute( 'name' ) == 'subtab' )
		{
			allSubTabs.push( panel.item(i) );
		}
	}
}


function changeSubTabDisplay(subtabId,tabId,arrowId) {

	var tabEl = document.getElementById(tabId).parentNode;
	
	tabEl.className = tabEl.className.replace("active","");
	document.getElementById(subtabId).style.display = "none";
	document.getElementById('arr'+arrowId).className = "tp_nav_arrow";
	clearTimeout(t);

}



function changetab(tabId,menuId,action)
{
	var tabEl = document.getElementById(tabId).parentNode;
	
	var check = tabEl.className.match("active");
	if(action==1)
	{
		if (!check)
		tabEl.className = tabEl.className+" active";
	}
	else if(action==2)
	{
		if(document.getElementById('menu_block'+menuId).style.display == 'none')
		{
			tabEl.className = tabEl.className.replace("active","");
		}
	}
	else if(action==3)
	{
		for(i=0;i<6;i++)
		{
			if(tabId != 'tab'+i)
			{
				if(document.getElementById('tab'+i))
				{
					var tabEl = document.getElementById('tab'+i).parentNode;
					
					var check = tabEl.className.match("active");
					if(check)
					{
						tabEl.className = tabEl.className.replace("active","");
					}
				}
			}
		}
	}

}



/**
* function to return the type of top tab  "active" or "page active"
* "active" tab			- when the arrow image is clicked to view the dropdown
* "page active" tab	- the current page, when the user clicks the toptab link the tab	                          becomes "page active"
*
* @return
*
* @usage $var_name = function_name($param);
*/
function checkIfTabPageActive(tabParentClass){
//returns not null value if the tab is page active
return tabParentClass.match("page active")
}

function checkIfTabActive(tabParentClass){
//returns not null value if the tab is active
return tabParentClass.match("active")
}

function checkIfDropdown(tabParentClass){
	return tabParentClass.match("droptrue")
}

function setPageActiveTopTab(tabId)	{
	//clear the timeout variable
	clearTimeout(t)
	/* browse all toptabs and set the page active tab
	* set all the other to tabs to in-active state
	*/
	for(var i = 0; i<allTopTabs.length; i++){
		var getParentDiv = allTopTabs[i].parentNode
		var class_name = getParentDiv.className
		if(allTopTabs[i].id == tabId){
		//check if tab already active
		if(checkIfTabActive(class_name)){
		class_name = class_name.replace("page","")
		class_name = class_name.replace("active","")
		class_name = class_name.replace("droptrue","")
		}

		//set page active tab
		if(!checkIfTabPageActive(class_name)){
		getParentDiv.className = class_name + " page active droptrue"
		}
		subtab = allTopTabs[i].getAttribute("rel")

		}
		else{
		//set other tabs to in-active
		if(class_name.match("active")){
		class_name = class_name.replace("active","")
		}
		if(class_name.match("page"))	{
		class_name = class_name.replace("page","")
		}
		if(class_name.match("droptrue"))	{
		class_name = class_name.replace("droptrue","")
		}

		getParentDiv.className = class_name
		}//end of else

		
	}

	/* hide all subtabs */
	for(var i=0;i<allSubTabs.length;i++){
	allSubTabs[i].style.display="none"
	}


}



function setActiveTopTab(tabId)	{
	//clear the timeout variable
	clearTimeout(t)
	/*
	browse all toptabs
	if page active tab, leave it as it is
	if any other tab is active , deactivate it
	set the selected tab to active state
	*/
	var subtab
	for(var i = 0; i<allTopTabs.length; i++){
		var getParentDiv = allTopTabs[i].parentNode
		var class_name = getParentDiv.className
			
		if(allTopTabs[i].id == tabId){
			//if active page
			//alert(class_name);
			if(checkIfTabPageActive(class_name)){
			//getParentDiv.className = class_name.replace("droptrue","")
			}
			//set active tab
			else if(!checkIfTabActive(class_name)){
			getParentDiv.className = class_name + " active"
			//arrow.src = img_src_dir + "arrow-down.gif"
			}
			else
			{
			//getParentDiv.className = class_name.replace("active","")
			}
			subtab = allTopTabs[i].getAttribute("rel")
		}
		else{
			if(!getParentDiv.className.match("page")){
			getParentDiv.className = class_name.replace("active","")
			}
			if(checkIfTabPageActive(class_name) && !class_name.match("droptrue")){
			getParentDiv.className = class_name + " droptrue"
			}
		}//end of else
	}

	/*
	browse all subtabs
	if the subtab is of the selected top tab, toggle its display
	hide all other subtabs
	*/
	for(var i = 0; i<allSubTabs.length; i++)
	{
		if(allSubTabs[i].id == subtab)
		{
	//set active sub tab
			if( allSubTabs[i].style.display == "none" || allSubTabs[i].style.display == "" )	
			{
				allSubTabs[i].style.display="block"
			}
			else
			{
				//allSubTabs[i].style.display="none"
			}//end of else
		}
		else
		{
			allSubTabs[i].style.display="none"
		}//end of else
	}
}



function closeAllDropdown(ev)
{
	var node =(typeof event!=='undefined')? event.srcElement : ev.target
	
	while (node && !node.id && typeof node.offsetParent != "unknown")
	{
		node = node.offsetParent;
	}

	if(typeof page_onclick=='function')
	{
		// below onclick function should be called for external onclick event 
		page_onclick();
	}

	
	if(node && (node.id == 'arr1' || node.id == 'arr2' || node.id =='arr3' || node.id =='arr4' || node.id =='arr5' || node.id =='arr6' || node.id =='less_myshaadi_text' || node.id =='less_myshaadi' || node.id =='less_myshaadi_img' || node.id =='more_myshaadi_text' || node.id =='more_myshaadi' || node.id =='more_myshaadi_img' || node.id =='less_ps_text' || node.id =='less_ps' || node.id =='less_ps_img' ||node.id =='more_ps_text' || node.id =='more_ps' || node.id =='more_ps_img' || node.id =='tbl_my_shaadi' || node.id =='tbl_ps' || node.id =='tbl_com' || node.id =='tbl_mem' || node.id =='tbl_ms' || node.id =='tbl_help') ) return;

	for(ctr=1; ctr<7; ctr++)
	{
		if(document.getElementById('menu_block'+ctr))
		{
			document.getElementById('menu_block'+ctr).style.display = 'none';
			document.getElementById('arr'+ctr).className = 'tp_nav_arrow';
		}
		
	}

	for(i=0; i<6; i++)
	{
		if(document.getElementById('tab'+i))
		{
			var tabEl = document.getElementById('tab'+i).parentNode;
					
			var check = tabEl.className.match("active");
			if(check)
			{
				tabEl.className = tabEl.className.replace("active","");
			}
		}
	}
}
if (window.captureEvents)
{
	window.captureEvents(Event.CLICK);
	window.onclick=closeAllDropdown;
}
else
{
	document.onclick=closeAllDropdown;
}

function show_menu(B,C,A)
{
	curleft=0;curtop=0;curright=0;

		if(C!='')
		{
			if(C.offsetParent)
			{
				do{curleft+=C.offsetLeft;curtop+=C.offsetTop}
				while
					(C=C.offsetParent)
			}
		}

		if (B != 6)
		{
			curleft= curleft - A + 2;
			curtop += 31;
		}
		else
		{
			//getting windows width
			var winWidth = document.all?document.body.clientWidth:window.innerWidth;
			
			if (navigator.appName == 'Netscape')
			{
				curtop += 30;
				curleft = winWidth - curleft - A - 26;
			}
			else
			{
				curtop += 31;
				curleft = winWidth - curleft - A - 21;
			}
		}
		
		
	
	
	
	for(ctr=1;ctr<7;ctr++)
	{
		if(B==ctr)
		{
			continue
		}
		if(document.getElementById('menu_block'+ctr)!=null)
		{
			document.getElementById('menu_block'+ctr).style.display='none'
			document.getElementById('arr'+ctr).className = 'tp_nav_arrow';
		}
	}

	if(B>0)
	{
		if(document.getElementById('menu_block'+B).style.display=='none')
		{
			document.getElementById('menu_block'+B).style.display='block';
			if (B == 6)
			{
				document.getElementById('menu_block'+B).style.right=curleft;
				document.getElementById('arr'+B).className = 'tp_nav_arrow_act';
			}
			else
			{
				document.getElementById('menu_block'+B).style.left=curleft;
				document.getElementById('arr'+B).className = 'tp_nav_arrow_act';
			}
			
			document.getElementById('menu_block'+B).style.top=curtop
		}
		else if(document.getElementById('menu_block'+B).style.display=='block')
		{
			document.getElementById('menu_block'+B).style.display='none';
			document.getElementById('arr'+B).className = 'tp_nav_arrow';
		}
	}

}



function show_menu_myshaadi(B,C,A)
{
	
	curleft=0;curtop=0;curright=0;
	var  is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
		if(C!='')
		{
			if(C.offsetParent)
			{
				do{curleft+=C.offsetLeft;curtop+=C.offsetTop}
				while
					(C=C.offsetParent)
			}
		}

		if (B != 6)
		{
			curtop+=31;
			
			if (navigator.appName == 'Netscape' && is_chrome != true)
			{
				curleft = curleft - A + 3;
			}else
			{
				curleft = curleft - A + 1;
			}
		}
		else
		{
			curtop+=30;

			//getting windows width
			var winWidth = document.all?document.body.clientWidth:window.innerWidth;
			
			if (navigator.appName == 'Netscape' && is_chrome != true )
			{
				curleft = winWidth - curleft - A - 30;
			}
			else if (navigator.appName == "Microsoft Internet Explorer")
			{	
				var iewinWidth = document.documentElement.clientWidth;
				var arrAppVersion = navigator.appVersion.split(';');
		
				if (arrAppVersion[1]==' MSIE 7.0')
				{
					curleft = iewinWidth - curleft  - A - 22;	
				}
				else if ( arrAppVersion[1]==' MSIE 6.0' )
				{
					curleft = iewinWidth - curleft  - A - 23;	
				}
				else if ( arrAppVersion[1]==' MSIE 8.0' )
				{
					curleft = iewinWidth - curleft  - A - 11;	
				}
			
			}
			else
			{
				curleft = winWidth - curleft - A - 27;
			}
			
		}
		
	
	for(ctr=1;ctr<7;ctr++)
	{
		if(B==ctr)
		{
			continue
		}
		if(document.getElementById('menu_block'+ctr)!=null)
		{
			document.getElementById('menu_block'+ctr).style.display='none'
			document.getElementById('arr'+ctr).className = 'tp_nav_arrow';
		}
	}

	if(B>0)
	{
		if(document.getElementById('menu_block'+B).style.display=='none')
		{
			document.getElementById('menu_block'+B).style.display='block';
			if (B == 6)
			{
				document.getElementById('menu_block'+B).style.right=curleft;
				document.getElementById('arr'+B).className = 'tp_nav_arrow_act';
			}
			else
			{
				document.getElementById('menu_block'+B).style.left=curleft;
				document.getElementById('arr'+B).className = 'tp_nav_arrow_act';
			}
			
			document.getElementById('menu_block'+B).style.top=curtop
		}
		else if(document.getElementById('menu_block'+B).style.display=='block')
		{
			document.getElementById('menu_block'+B).style.display='none';
			document.getElementById('arr'+B).className = 'tp_nav_arrow';
		}
	}

}






function show_hide_tooltip_layer()
{
	var B=show_hide_tooltip_layer.arguments;
	var A=B[0];
	if(A=="show")
	{
		document.getElementById("tooltip_layer").style.display="block"
	}
	else
	{
		if(A=="hide")
		{
			document.getElementById("tooltip_layer").style.display="none"
		}
	}
}




function more(id)
{
    var layer = document.getElementById(id);
    if (layer != null)
    {
        layer.style.display = 'block';
    }
}
function less(id)
{
    var layer = document.getElementById(id);
    if (layer != null)
    {
        layer.style.display = 'none';
    }
}
