/*
*
*/
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)
  {
  }
}
/*
*
*/
var content ;
var contentcontainer ;
var position = 1;
var rot_position = 1;
var rot_timer;
var maxY,wd, maxX, ready, slideDur=600, destX=0, destY=0, distY, distX, per, sliding, slideStart, aniTimer, startX, startY, xcoordinate, ycoordinate,url_path_rotation;
var no_of_records = 4;

function load(cntId,rot_value,url_path)
{
	position = 0;
	url_path_rotation = url_path;
	if(!document.getElementById)
		return;

	content = document.getElementById("content");
	contentcontainer = document.getElementById("content-container");

	content.visibility="hidden";
	content.style.top=0;
	content.style.left=0;
	xcoordinate=0;
	ycoordinate=0;
	maxY=(content.offsetHeight-contentcontainer.offsetHeight>0)?content.offsetHeight-contentcontainer.offsetHeight:0;
	wd=cntId?document.getElementById(cntId).offsetWidth:content.offsetWidth;
	maxX=(wd-contentcontainer.offsetWidth>0)?wd-contentcontainer.offsetWidth:0;
	content.style.visibility="visible";
	ready=true;
	document.getElementById("slide-links").style.visibility="visible";
		rot_timer = setInterval("do_rotation()",rot_value);
	}

function glideTo(MstartX, MstartY)
{
	content = document.getElementById("content");
	contentcontainer = document.getElementById("content-container");
	startX = parseInt(content.style.left);
	if(startX == "")
	{
		startX = 0;
	}
	startY = parseInt(content.style.top);
	destX = -Math.max(Math.min(MstartX, maxX), 0);
	destY = -Math.max(Math.min(MstartY, maxY), 0);
	distY = destY - startY;
	distX =  destX - startX;
	per = Math.PI/(2 * slideDur);
	sliding = false;
	slideStart = (new Date()).getTime();
	aniTimer = setInterval("doSlide()",10);
	on_slide_start(startX, startY);
  }


function doSlide()
{
	var elapsed = (new Date()).getTime() - slideStart;
	if (elapsed < slideDur)
	{
		var x = startX + distX * Math.sin(per*elapsed);
		var y = startY + distY * Math.sin(per*elapsed);
		shiftTo(x, y);
		on_slide(x, y);
	}
	else
	{	// if time's up
		clearInterval(aniTimer);
		sliding = false;
		shiftTo(destX, destY);
		//content = null;
		on_slide_end(destX, destY);
	}
}

function shiftTo(x,y)
{
	 if(typeof(x) == "number")
	 {
		content.style.left=x+"px";
		content.style.top=y+"px";
	 }
}

on_slide_start = function() {}
on_slide = function() {}
on_slide_end = function() {}

function slide(id,img_url)
{
	clearInterval(rot_timer);
	position = id;
	glideTo(eval(id-1) * 590,0);
	for(var z=1;z<=no_of_records;z++)
	{
		if(id == z)
		{
			document.getElementById("slide" + id).className="selected";
		}
		else
		{
			document.getElementById("slide" + z).className=""
		}
	}
}

function do_rotation()
{
	if(position < no_of_records)
	{
		position++;
		glideTo(eval(position-1) * 590,0);
	}
	else
	{
		position = 1;
		content.style.left="0px";
		content.style.top="0px";
	}
	for(var z=1;z<=no_of_records;z++)
	{
		if(position == z)
		{
			document.getElementById("slide" + position).className="selected";
		}
		else
		{
			document.getElementById("slide" + z).className="";
		}
	}
}


/*
*
*/
var more_layer_status_1 = 0;
var more_layer_status_2 = 0;

function show_hide_login_layer() {
	clear_err_divs();
	var args = show_hide_login_layer.arguments;
	var do_what = args[0];
	if (do_what=='show') {
		//enable_disable_form(document.forms['quicksearch'], 'disable');
		(document.forms['quicksearch']) ? enable_disable_form(document.forms['quicksearch'], 'disable') : "";
		document.getElementById('login_layer').style.display = 'block';
		if(document.getElementById('more_services_li'))
		document.getElementById('more_services_li').style.visibility = 'hidden';
		if(document.getElementById('help_li'))
		document.getElementById('help_li').style.visibility = 'hidden';
		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';
			if(document.getElementById('more_services_li'))
			document.getElementById('more_services_li').style.visibility= 'visible';
			if(document.getElementById('help_li'))
			document.getElementById('help_li').style.visibility= 'visible';
			(document.forms['quicksearch']) ? enable_disable_form(document.forms['quicksearch'], 'enable') : "";
		}
	}
}

function show_hide_tooltip_layer() {
	var args = show_hide_tooltip_layer.arguments;
	var do_what = args[0];
	if (do_what=='show') {
		document.getElementById('tooltip_layer').style.display = 'block';
	}
	else if (do_what=='hide') {
		document.getElementById('tooltip_layer').style.display = 'none';
	}
}

function enterkey(evt) {
	var evt = (evt) ? evt : event;
	var charCode = (evt.which) ? evt.which : evt.keyCode;
	if (charCode == 13) {
		return validate_login_form();
	}
}

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 show_hide_more_layer() {
	var args = show_hide_more_layer.arguments;
	var do_what = args[0];
	if (do_what=='show') {
		if (more_layer_status_1==0 && more_layer_status_2==0) {
			show_hide_profile_search_layer('hide');
			enable_disable_form(document.forms['quicksearch'], 'disable');
			more_layer_status_1 = 1;
			document.getElementById('more').className = 'more';
			document.getElementById('more_layer').style.display = 'block';

			setTimeout('more_layer_status_2=1', 500);
		}
	}
	else if (do_what=='hide') {
		if (more_layer_status_1==1 && more_layer_status_2==1) {
			more_layer_status_1 = 0;
			more_layer_status_2 = 0;
			document.getElementById('more_layer').style.display = 'none';
			document.getElementById('more').className = '';
			enable_disable_form(document.forms['quicksearch'], 'enable');
		}
	}
}

function set_gender() {
	var args = set_gender.arguments;
	var gender = args[0];
	document.quicksearch.hid_gender.value = gender;
}

function chk_quicksearch_community() {
	if (document.quicksearch.community.value=='') {
		alert('Please select religion.');
		return false;
	}

	objMT = document.getElementsByName("mothertonguearray[]");
	if (objMT[0].value=='doesn\'t_matter') {
		objMT[0].value='';
	}

	objCT = document.getElementsByName("castearray[]");
	if (objCT[0].value=='doesn\'t_matter') {
		objCT[0].value='';
	}
	document.quicksearch.submit();
	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 enable_disable_form() {
	var args = enable_disable_form.arguments;
	var form = args[0];
	var do_what = args[1];
	var count = form.elements.length;
	for (i=0; i<count; i++) {
		var element = form.elements[i];
		if (do_what=='disable') {
			element.disabled = true;
		}
		else if (do_what=='enable') {
			element.disabled = false;
		}
	}
}

