
function ajaxFormProcessEffect(id)
{
	$(id)
	.ajaxStart(function(){
		$(this).html('<img src="/OralHealthMonth/IN/EN/images/common/searching.gif" border="0"/>');
		$(this).show();
	})
	.ajaxComplete(function(){
		$(this).hide(500);
	});
}


function IsNumeric(sText)
{
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
   
   }
   
   function isValidEmail(str) {
   return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}

function dragCal(){
	$("#eventDialog").draggable({revert: true, drag:function(){ $(this).css({opacity: 0.5})}, stop:function(){ $(this).css({opacity: 1})}});
}

function getCalCenter(){
	$("#eventDataPanel").html("");
var data = $(this).find("div").html();
	$("#eventDataPanel").html(data);
	var pos = $(this).position();
var x = pos.left;
var y = pos.top;
var cenY = y-$("#eventDialog").height()/2 + $(this).height()/2
var cenX = x-$("#eventDialog").width()/2 + $(this).width()/2
$("#eventDialog").css({
 top: cenY,
 left: cenX })
$("#eventDialog").fadeIn()
}




function closeCal(){
	$("#eventDialog").fadeOut()
}


function getQuery(keyValue)
{
	try
	{
	var index =-1
	var _all = window.location.href.toString()
	var _query = window.location.search.substring(1)
	if(_query)	
	{
		var parmas = _query.split("&")
		for(i=0;  i< parmas.length; i++)
		{
			var key = parmas[i]
			
			if((index = key.indexOf("=")) >0)
			{
				var paramKey = key.substring(0, index)
				var paramVal = key.substring(index+1)
				if(paramKey == keyValue)
				{
					return paramVal;
				}
			}
		}
	}else
	return false;
	}catch(e){}
	
	
	
}
function resetTable()
{
	$("#result tr:has(td)").remove()
}
function getResultData()
{
resetTable();
$.ajax({
    type: "GET",
	url: "/OralHealthMonth/IN/EN/xml/data.xml",
	dataType: "xml",
	success: function(xml) {
 		$(xml).find('c').each(function(){ 
			// var id= $(this).attr("i");
			var title= $(this).find('t').text();
			var firstName= $(this).find('f').text();
			var lastName= $(this).find('l').text();
			var address= $(this).find('a').text();
			var phone= $(this).find('p').text();
			var pincode= $(this).find('e').text();
			var city= $(this).find('y').text();
			
			$("#result").append(
					"<tr><td>"+title+"</td><td>"+firstName+"</td><td>"+lastName+"</td><td>"+address+"</td><td>"+city+"</td><td>"+pincode+"</td><td>"+phone+"</td></tr>"
				)
		
 		})
	}
});	

}

function getFirstPinCode(pincodes) {
  var tokenizedPincode = pincodes.split( "," );
  if (tokenizedPincode.length >= 1)
  {
    return tokenizedPincode[0];
  }
  return pincodes;
}

function getResultDataByZipCode(code) {
  $("#result").append(
  		"<tr><td colspan=7>Oral Health Month 2009 has ended on October 31. Thank you for your enthusiastic participation!</td></tr>"
  )
}

function getResultDataByZipCodeProgress(code)
{
	var i=0;
	$.ajax({
    type: "GET",
  	url: "/OralHealthMonth/IN/EN/xml/data.xml",
  	dataType: "xml",
  	success: function(xml) {
   		if (code.length == 6) {
     		$(xml).find( "c:has(e:contains('" + code + "'))" ).each(function(){ 
    			var title= $(this).find('t').text();
    			var firstName= $(this).find('f').text();
    			var lastName= $(this).find('l').text();
    			var address= $(this).find('a').text();
    			var phone= $(this).find('p').text();
    			var pincode= $(this).find('e').text();
    			var city= $(this).find('y').text();
    			
    			pincode = getFirstPinCode(pincode);
    			
  				$("#result").append(
  					"<tr><td>"+title+"</td><td>"+firstName+"</td><td>"+lastName+"</td><td>"+address+"</td><td>"+city+"</td><td>"+pincode+"</td><td>"+phone+"</td></tr>"
  				)
  				i++;
  		  })		
 		  }
  		if(i==0)
  		{
  			$("#result").append(
  					"<tr><td colspan=7>There is no result match</td></tr>"
  			)
  		}
	  }
  });	
  sendPageEvent('SearchByCode');
}


function popUpLink_RightToothbrush()
{
	window.open("http://www.colgate.co.in/app/Colgate/IN/OralCare/ToothBrushes.cvsp", "popUpLink_RightToothpaste")
}
function popUpLink_RightMouthwash()
{
	window.open("http://www.colgate.co.in/app/Colgate/IN/FromTheDentist/GingivitisTreatment/TotalPlax.cvsp", "popUpLink_RightMouthwash")
}
function popUpLink_RightToothpaste()
{
	window.open("http://www.colgate.co.in/app/Colgate/IN/OralCare/ToothPastes.cvsp", "popUpLink_RightToothpaste")
}
function popUpLink_DentalCheckUp()
{
	top.location.href = "/app/OralHealthMonth/IN/EN/CDC/AboutOralHealthMonth2009/SearchDentalClinics.cvsp";
}

function sendPageEvent(pageName) {
  // alert("sendPageEvent:= "+pageName);
  ns=s_account; 
  s_pageName='/OralHealthMonth/IN/EN/CDC/' + pageName + '.cvsp';
  void(s_gs(ns));
}

function nextMonth() {
	$('#calenderSept').css('display','none');
	$('#calenderOct').css('display','block');
}

function prevMonth() {
	$('#calenderOct').css('display','none');
	$('#calenderSept').css('display','block');
}
