/* *********************************************************** 
 *	FUNCTION:  sfHover, listOver, listOut
 *	PURPOSE: suckerfish rollover
 * ********************************************************* */
sfHover = function() {
	var sfEls = document.getElementById('universalnav').getElementsByTagName('li');
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=listOver;
		sfEls[i].onmouseout=listOut;
	}
	
	if (document.getElementById('dropdownnav')) {
		var sfMoreEls = document.getElementById('dropdownnav').getElementsByTagName('li'); 
		for (var i=0; i<sfMoreEls.length; i++) {
			sfMoreEls[i].onmouseover=listOver;
			sfMoreEls[i].onmouseout=listOut;
		}
	}
}

 
/*
function listOver () {
    
	this.className+=" hover";
	if (this.id == "boards") { //drop down menu over form element
		document.getElementById('iframeHidden').style.display = "block";
	}
	if(this.id=="sachin")
	{
	  	document.getElementById('iframeHidden').style.display = "block";
	}
}

function listOut () {
	this.className="";
	if (this.id == "boards") { //drop down menu over form element
		document.getElementById('iframeHidden').style.display = "none";
	}
}*/
//-------------------- redefined by manish------------------------

function listOver () 
{
	
	this.className+=" hover";
	document.getElementById('iframeHidden').style.display = "block";
	
	if(this.id=="sachin")
	{   
        document.getElementById("dir_submenu").style.visibility = "visible";
	}
}

function listOut () {
	this.className="";
	if (this.id == "boards") { //drop down menu over form element
		document.getElementById('iframeHidden').style.display = "none";
	}
	if(this.id=="sachin")
	{
	  	document.getElementById('iframeHidden').style.display = "none";
	  	document.getElementById("dir_submenu").style.visibility = "hidden";
	}
}



/* window.attachEvent for IE + Opera */
if (window.attachEvent){ 
	window.attachEvent('onload', sfHover);
}
else if (window.addEventListener)
{
    //window.attachEvent('onload', sfHover);
    window.addEventListener("load", sfHover, false);
}

/* *********************************************************** 
 *	FUNCTION: showMe, hideMe
 *	PURPOSE: footer tooltip rollover
 * ********************************************************* */
function showMe(divname) {
	document.getElementById(divname).style.display = "block";

}

function hideMe(divname) {
	document.getElementById(divname).style.display = "none";
}

/* *********************************************************** 
 *	FUNCTION: clearField
 *	PURPOSE: clear text field default value
 * ********************************************************* */
function clearField(field) {
	if (field.value == field.defaultValue)
		field.value = "";
}

function getDefaultValue(field) {
	if (field.value == "")
		field.value = field.defaultValue;
}

/* *********************************************************** 
 *	FUNCTION: turnme
 *	PURPOSE: expand/collapse Ask InfoServ FAQ
 * ********************************************************* */
function turnme(elem) {
	if (elem.className == '') elem.className = "on";
	else if (elem.className == "on") elem.className = "";
}

/* *********************************************************** 
 *	FUNCTION: showAskNow/hideAskNow
 *	PURPOSE: display Ask Now form on news story pages
 * ********************************************************* */
function toggleAskNow() {
	if (document.getElementById('askusnow_form').style.display == "block") {
		document.getElementById('askusnow_form').style.display = "none";
	} else {
		document.getElementById('askusnow_form').style.display = "block";
	}
}

function showAskNow() {
	document.getElementById('askusnow_form').style.display = "block";
}

function hideAskNow() {
	document.getElementById('askusnow_form').style.display = "none";
}

/* *********************************************************** 
 *	FUNCTION:	ldmHover, navOver, navOut
 *	PURPOSE: 	rollover for homepage navigation bar
 *				both IE & Mozilla
 * ********************************************************* */
function ldmHover() {
	if (document.getElementById('mainNavn')) 
	{
	
	    document.getElementById('mainNavn').onmouseout = hideAll;
		var z = document.getElementById("nav").getElementsByTagName("LI");
		for (k=0;k<z.length;k++) {
			z[k].onmouseover = function(){homeNavRoll(this)};
		}
		
		var y = document.getElementById("nav").getElementsByTagName("LI");
		for (j=0;j<y.length;j++) {
			if (y[j].className == "topRow") {
				subNavs = y[j].getElementsByTagName("UL");
				for (e=0;e<subNavs.length;e++) {
					subNavs[e].onmouseout = function(){homeNavRollOut(this)};
				}
			}
		}
		
		//var navItems = document.getElementById('mainNav').getElementsByTagName('li');
//		for (var i=0; i<navItems.length; i++) {
//			navItems[i].onmouseover=navOver;
//			//navItems[i].onmouseout=navOut;
//		}
	}
}

/* *********************************************************** 
 *	FUNCTION: homeNavRoll
 *	PURPOSE: shows subnav items for main nav on rollover
 * ********************************************************* */
function homeNavRoll(li) {
	hideAll();
	//document.getElementById('mainNavBg').style.display = "block";
	if(li.getElementsByTagName('UL')[0]) {	
		li.getElementsByTagName('UL')[0].style.top = "140px";
		turnOnNavRollover(li);
	}
}
/* End show subnav script */

/* *********************************************************** 
 *	FUNCTION: turnOnNavRollover
 *	PURPOSE: keeps main nav item rollover on when secondary nav item is rolled over
 * ********************************************************* */
function turnOnNavRollover(navItem) {
	//document.getElementById('mainNavBg').style.display = "block";
	navItem.getElementsByTagName('A')[0].style.backgroundPosition = "0 0";
	navItem.getElementsByTagName('A')[0].style.borderBottom = "1px solid #E3AB2E";
}
/* End show subnav script */

/* *********************************************************** 
 *	FUNCTION: homeNavRollOut, hideAll
 *	PURPOSE: hides subnav items for main nav
 * ********************************************************* */
function homeNavRollOut(ul) {
	if(ul) {
		ul.style.top = "-144px";
	}
}


function hideAll() {
	var navs = document.getElementById('nav').getElementsByTagName('ul');
	for(i=0;i<navs.length;i++)
	{
		navs[i].style.top = "-143px";
	}
//	document.getElementById('mainNavBg').style.display = "none";
}


function navOver () {
	switch(this.id) {
		case 'navOurChurch':
			document.getElementById('mainNav').className = 'ourChurch';
			break;
		case 'navOurFaith':
			document.getElementById('mainNav').className = 'ourFaith';
			break;
		case 'navOurPeople':
			document.getElementById('mainNav').className = 'ourPeople';
			break;
		case 'navOurWorld':
			document.getElementById('mainNav').className = 'ourWorld';
			break;
	}
}

/*function navOut () {
	document.getElementById('mainNav').className = 'nosub';
}*/


if(window.addEventListener){
	window.addEventListener('load',ldmHover,false);
} else if (window.attachEvent){ 
	window.attachEvent('onload', ldmHover);
}


/****** New Navigation *****/
/****** Pending approval, this will replace the navigation site-wide *****/

/* list of tabs and associated background images, sans extensions */
var tabArray = new Array();
//tabArray[0] = new Array("tab_community","nav-community");
tabArray[0] = new Array("tab_specialinitiatives","nav-specialinitiatives");
tabArray[1] = new Array("tab_commcentral","nav-commcentral");

/* preload rollover images */
image1 = new Image(); image1.src = getDomainName() + "/MasterTemplates/Ignify/Theme/images/nav-community-RO.gif";
image2 = new Image(); image2.src = getDomainName() + "/MasterTemplates/Ignify/Theme/images/nav-specialinitiatives-RO.gif";
image3 = new Image(); image3.src = getDomainName() + "/MasterTemplates/Ignify/Theme/images/nav-commcentral-RO.gif";


/* set the z-index of the active navigation tab and swap background image */
function navSwap(obj) {
        document.getElementById("sp21").style.visibility='visible';
	    document.getElementById("sp22").style.visibility='visible';
	    document.getElementById("sp23").style.visibility='visible';
	     document.getElementById("sp31").style.visibility='visible';
	    document.getElementById("sp32").style.visibility='visible';
	    document.getElementById("sp33").style.visibility='visible';
	
for (i=0; i<tabArray.length; i++) {
	if (obj==tabArray[i][0]) {
		document.getElementById(tabArray[i][0]).style.zIndex = "3";
		document.getElementById(tabArray[i][0]).style.backgroundImage = "url(" + getDomainName() + "/MasterTemplates/Ignify/Theme/Images/"+tabArray[i][1]+"-RO.gif)";	
		}
	else {
		document.getElementById(tabArray[i][0]).style.zIndex = "1";
		document.getElementById(tabArray[i][0]).style.backgroundImage = "url(" + getDomainName() + "/MasterTemplates/Ignify/Theme/Images/"+tabArray[i][1]+".gif)";		
		}
		
	}
	document.getElementById("nav_new").style.height='65px';
	
	document.getElementById("nav_new").style.backgroundImage="url(" + getDomainName() + "/MasterTemplates/Ignify/Theme/Images/bg-nav.gif)";
	
}

function navhide(obj) {
for (i=0; i<tabArray.length; i++) 
    {
	        if (obj==tabArray[i][0])
	             {
		                //document.getElementById(tabArray[i][0]).style.visibility='hidden';
		                document.getElementById(tabArray[i][0]).style.zIndex = "3";
	                    document.getElementById("sp21").style.visibility='hidden';
	                    document.getElementById("sp22").style.visibility='hidden';
	                    document.getElementById("sp23").style.visibility='hidden';
	                    document.getElementById("sp31").style.visibility='hidden';
	                    document.getElementById("sp32").style.visibility='hidden';
	                    document.getElementById("sp33").style.visibility='hidden';
	                    
	                  	document.getElementById("tab_specialinitiatives").style.backgroundImage = "url(" + getDomainName() + "/MasterTemplates/Ignify/Theme/Images/nav-specialinitiatives.gif)";	
	                  	document.getElementById("tab_commcentral").style.backgroundImage = "url(" + getDomainName() + "/MasterTemplates/Ignify/Theme/Images/nav-commcentral.gif)";	
		          }
                document.getElementById("nav_new").style.zIndex = "0";	
                document.getElementById("nav_new").style.backgroundImage="url(" + getDomainName() + "/MasterTemplates/Ignify/Theme/Images/bg-nav2.gif)";
             
	            }

            
}


/* return navigation to its default state when moused out */
function navReturn() {

    /* Detect the CLASS name of the main unordered list and use it to determine the tab's default state */
    var homeBase = "Blank";

    navSwap(homeBase);

}



/****** DHTML tab navigation -- switch between tabs without reloading page ******/

var categoryArray = new Array();

// Build tabs and keep tab values stored in an array 
function buildTabs(tabSet) {

if (tabSet == "set_1") {
	categoryArray[0] = new Array("Best Sellers","bestSellersBox")
	categoryArray[1] = new Array("Most Popular","mostPopularBox")
	categoryArray[2] = new Array("Customer Favorites","customerFavoritesBox");
	document.getElementById("switchBoxNav").innerHTML = "<ul><li id=\"link_"+categoryArray[0][1]+"\" class=\"on first\">"+categoryArray[0][0]+"</li><li id=\"link_"+categoryArray[1][1]+"\"><a href=\"#\" onclick=\"tab(this); return false;\">"+categoryArray[1][0]+"</a></li><li id=\"link_"+categoryArray[2][1]+"\"><a href=\"#\" onclick=\"tab(this); return false;\">"+categoryArray[2][0]+"</a></li></ul>";					

	}

if (tabSet == "set_2") {
	categoryArray[0] = new Array("Overview","overviewBox")
	categoryArray[1] = new Array("More Info","specsBox")
	
	document.getElementById("switchBoxNav").innerHTML = "<ul><li id=\"link_"+categoryArray[0][1]+"\" class=\"on first\">"+categoryArray[0][0]+"</li><li id=\"link_"+categoryArray[1][1]+"\"><a href=\"#\" onclick=\"tab(this); return false;\">"+categoryArray[1][0]+"</a></li></ul>";					
	}
if (tabSet == "set_3") 
   {
	categoryArray[0] = new Array("Overview","overviewBox")
	categoryArray[1] = new Array("&nbsp;","&nsbp;")
	document.getElementById("switchBoxNav").innerHTML = "<ul><li id=\"link_"+categoryArray[0][1]+"\" class=\"on first\">"+categoryArray[0][0]+"</li><li id=\"link_"+categoryArray[1][1]+"\"><a href=\"#\" onclick=\"tab(this); return false;\">"+categoryArray[1][0]+"</a></li></ul>";					
	}
}
					
function tab(tabLink) {
var currentTab = tabLink.parentNode.id.slice(5); // Determine the anchor's list ID as a reference

var tabArray = tabLink.parentNode.parentNode.getElementsByTagName("li"); // Traverse the node tree and create an array of list items (tabs)
if (!captionArray) var captionArray = new Array();
	
for (i=0;i<tabArray.length;i++) { // Reset the tabs
	var tabDiv = tabArray[i].getAttribute("id")
	document.getElementById(tabDiv.slice(5)).style.display = "none";
	if (i==0) tabArray[i].className = "first"; // The first list item requires a special "first" class
	else tabArray[i].className = "";
	}

document.getElementById(currentTab).style.display = "block"; //Display the selected content

for (j=0;j<tabArray.length;j++) { //Set the active tab
	// If the active tab is the first tab, include the "first" class (required for the first list item)
	if (tabArray[0].getAttribute("id") == "link_"+currentTab)  document.getElementById("link_"+currentTab).className = "on first";
	else document.getElementById("link_"+currentTab).className = "on";
	}

for (k=0;k<tabArray.length;k++) { //Set links in tabs, or remove link if tab is selected
	if ((tabArray[k].className == "on") || (tabArray[k].className == "on first")) tabArray[k].innerHTML = categoryArray[k][0];
	else tabArray[k].innerHTML = "<a href=\"\" onclick=\"tab(this); return false;\">"+categoryArray[k][0]+"</a>";
	}

}



/***** DHTML Shipping Calculator Widget *****
Displays and positions the Shipping Calculator layer
requires two variables:
The event (to read the mouse cursor location to position the layer)
The ID of the layer to manipulate
*/
function dispCalc(e,popinName) {
var popin = document.getElementById(popinName);

// Get cursor position for positioning
e = e || window.event;
var cursor = {x:0, y:0};
if (e.pageX || e.pageY) {
    cursor.x = e.pageX;
    cursor.y = e.pageY;
	} 
else {
    var de = document.documentElement;
    var b = document.body;
    cursor.x = e.clientX + 
        (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
    cursor.y = e.clientY + 
        (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
	}

// Display and position pop-in
if (popin.style.display != "block") {
	popin.style.display = "block";
	popin.style.top = cursor.y-(popin.offsetHeight/2)+"px";
	popin.style.left = cursor.x+10+"px";

	}
else {popin.style.display = "none";}
}



/****** "What Is This?" speech bubble tooltip *****/
/****** Displays tooltip, positions based on cursor position, and inserts content *****/
function whatisthis(e,content) {
var popin = document.getElementById("whatisthis");

// Get cursor position for positioning
e = e || window.event;
var cursor = {x:0, y:0};
if (e.pageX || e.pageY) {
    cursor.x = e.pageX;
    cursor.y = e.pageY;
	} 
else {
    var de = document.documentElement;
    var b = document.body;
    cursor.x = e.clientX + 
        (de.scrollLeft || b.scrollLeft) - (de.clientLeft || 0);
    cursor.y = e.clientY + 
        (de.scrollTop || b.scrollTop) - (de.clientTop || 0);
	}

// Display and position pop-in
if (popin.style.display != "block") {
	popin.style.display = "block";
	document.getElementById("whatisthisContent").innerHTML = content;
	popin.style.top = cursor.y-(popin.offsetHeight-8)+"px";
	popin.style.left = cursor.x+10+"px";
	}
else {popin.style.display = "none";}

// Safari bug fix - prevents empty tooltip from being displayed
if ((popin.style.display == "block") && (document.getElementById("whatisthisContent").innerHTML == "")) {popin.style.display = "none";}

}

function prodImgHover(thisImg) {
//	var thisImgLoc = "/PublicStore/MasterTemplates/Ignify/Theme/images/placeholder_product_4" + thisImg + ".jpg";
    var thisImgLoc = thisImg;
    document["prodImg"].src = thisImgLoc;
   	document["prodImg"].style.position="relative";
    document["prodImg"].style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(src='"+thisImg+"', sizingMethod='scale');" 
   	
   	
}
function ShowPage()
{
    window.open("../Catalog/UnderConstruction.aspx", "UnderConstruction", "location=no,resizable=no,top=250,left=250,height=200,width=450,status=no,toolbar=no");
}
function ShowCRMPage()
{
    window.open("../Catalog/RelatedToCrm.aspx", "UnderConstruction", "location=no,resizable=no,top=250,left=250,height=200,width=450,status=no,toolbar=no");
}

function ShowImagePage(path)
{
  
  window.open("../profile/DisplayImage.aspx?path="+path, "DisplayImage", "location=no,resizable=yes,top=120,left=250,height=600,width=650,status=no,toolbar=no,scrollbars=yes");
}
function ShowDownloadPage(productid)
{
  window.open("../profile/DisplayDownloads.aspx?productid="+productid, "Download", "location=no,resizable=no,top=250,left=250,height=400,width=650,status=no,toolbar=no");
}


function getDomainName()
{
    var currenturl;
    currenturl = window.location.href;
    currenturl=currenturl.toLowerCase();
    
    if(currenturl.indexOf("umcom") >= 0)
    {
       if(currenturl.indexOf("https")>=0)
       {
        currenturl = "https://" + document.domain + "/store";
       }
       else
       {
        currenturl = "http://" + document.domain + "/store";
       }
        
    }
    else
    {
        if(currenturl.indexOf("https")>=0)
         {
             currenturl = "https://" + document.domain;        
         }
         else
         {
            currenturl = "http://" + document.domain;        
         }
    }
    
    return currenturl;
}
function SetQtyHiddenValue(str,ID,hdnID)
       {
          var agree;
          if(!IsNumeric(document.getElementById(ID).value) || document.getElementById(ID).value<=0)
          {
             document.getElementById(ID).value="";
             document.getElementById(ID).focus();   
             alert("Enter proper quantity !!!")
             return false;
           }  
          
          if(document.getElementById(ID).value!="")
          {
              str=str+"_"+document.getElementById(ID).value;
              var temp = new Array();
              temp = str.split('~');
              str=getDomainName()+temp[1];
              
              if(document.getElementById(hdnID).value>1)
              {
               //alert("You Are going to buy "+document.getElementById(ID).value+" pack with "+document.getElementById(hdnID).value*document.getElementById(ID).value+" Quantity");
                agree= confirm("You Are going to buy "+document.getElementById(ID).value+" pack with "+document.getElementById(hdnID).value*document.getElementById(ID).value+" Quantity");
              
              }
              else
              {
              agree=true;
              }
              
           }
          else
          {
              var temp = new Array();
              temp = str.split('~');
              str=getDomainName()+temp[1];
              
              if(document.getElementById(hdnID).value>1)
              {
               //alert("You Are going to buy 1 pack with "+document.getElementById(hdnID).value+" Quantity");
                agree= confirm("You Are going to buy 1 pack with "+document.getElementById(hdnID).value+" Quantity");
              } 
              else
              {
                document.location.href=str;
              }
              
          }
          //alert(str);
          
               if (agree)
    	          document.location.href=str;
                else
	                return false ;
          
    }
    
function popitup(url)
{
	//newwindow=
	window.open(getDomainName()+url,'name','height=500,width=550,top=300,left=500,scrollbars=1');
	//if (window.focus) {newwindow.focus()}
	//return false;
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;
   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
           blnResult = false;
         }
      }
   return blnResult;
   }
   
  function IsNumericShopcartqty(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "123456789";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;
   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
           blnResult = false;
         }
      }
   return blnResult;
   }
    
  function CheckNumeric(strqty)
  {
    if(!IsNumeric(strqty.value) || strqty.value<= 0)
    {
      alert("Please enter proper quantity");
      return false;
    }
    return true;
  }
  function IsPageNumeric(strqty)
  {
    if(!IsNumeric(strqty.value) || strqty.value<= 0)
    {
      alert("Please enter proper page size !");
      strqty.value="";
      strqty.focus();
      return false;
    }
    return true;
  }  
    
  function MessageAlertProduct(ID,hdnID,dropdownids,dropdownvalues)
  {
       var flag= checkSkuSelecteOrNot(dropdownids,dropdownvalues);
        if(flag==true)
        { 
          var vflag=MessageAlert(ID,hdnID);
          
           if(vflag==false)
           {
             return false;
           }
           else
           {
             return true;
           }
        }
        else
          {
             return false;
          }   
        return true;   
  } 
  function CheckNumericProduct(strqty,dropdownids,dropdownvalues)
  {
  
      var flag= checkSkuSelecteOrNot(dropdownids,dropdownvalues);
      if(flag==true)
      {
           var hflag=CheckNumeric(strqty);
           
           if(hflag==false)
           {
             return false;
           }
            else
            { 
             return true;
            }
       }
       else
       {
         return false;   
       }
       return true; 
     
  } 
  
  function checkSkuSelecteOrNot(dropids,dropvalues)
     {
      
        var droparray=dropids.split(',');
        var dropvaluesarray=dropvalues.split(',');
        
      for(intcounter=0;intcounter<droparray.length;intcounter++)
      {
        var list = document.getElementById(droparray[intcounter]).value;
        if(list=="0")
        {
         alert("Please Select Sku Attributes !!");
         return false;
         }
      }
      
     return true;
   }
   
  function MessageAlert(ID,hdnID)
  {
     var agree;
     var num=hdnID.value.toLowerCase();
     if(num=='each')
           {
               num=1;
           }
     else
           {
               var str=num.split("-");
               num=trim(str[1]);
              }
      
    
     if(ID.value!="")
          {
          if(!IsNumeric(ID.value) || ID.value <= 0)
          {
             
             ID.value="";
             ID.focus();   
             alert("Enter proper quantity !!!")
             return false;
           }  
           
              
              if(parseInt(num)>1)
              {
               agree=confirm("You Are going to buy "+ID.value+" pack with "+num*ID.value+" Quantity");
              }
              else
              {
                agree=true;
              }
              
           }
          else
          {
              if(num>1)
              {
               agree=confirm("You Are going to buy 1 pack with "+hdnID.value+" Quantity");
              } 
              else
              {
                 return true;
              }
          }
          
    if (agree)
        return true;
    else
        return false ;
  }
 
 function LTrim( value ) {
	
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
	
}

// Removes ending whitespaces
function RTrim( value ) {
	
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
	
}

// Removes leading and ending whitespaces
function trim( value ) {
	
	return LTrim(RTrim(value));
	
}

            
            
 function Print()
    {
        alert("Operation Completed");
    }
    
   function Check()						 
	{
	
	    for(var i=0; i < document.forms[0].elements.length; i++)
        {
            strElement = document.forms[0].elements[i].id;
            if(strElement.substring(strElement.length-12, strElement.length) == "chkSelectAll")
            {
               if (document.forms[0].elements[i].checked == true)
               {
              
                   CheckAll();
               }
               else
               {
              
                   UnCheckAll();
               }
            }
        }
    }
    function CheckAll()
    {
       for(var i=0; i < document.forms[0].elements.length; i++)
        {
            strElement = document.forms[0].elements[i].id;
            
            if(strElement.substring(strElement.length-9, strElement.length) == "chkItemId") 
            {
                document.forms[0].elements[i].checked = true ;   
            }
        }
    }
    function UnCheckAll()
    {
        for(var i=0; i < document.forms[0].elements.length; i++)
        {
            strElement = document.forms[0].elements[i].id;
            
            if(strElement.substring(strElement.length-9, strElement.length) == "chkItemId") 
            {
                document.forms[0].elements[i].checked = false;    
            }
        }
    }         
    
    
    function TransferFocus(CurrentControl, NextControl,e )
{

 
	var keyCode;
	if(window.event) { // IE Specific
	        
			 keyCode = window.event.keyCode;
			 // if shift key is pressed, return from function
			 if(window.event.shiftkey == true || window.event.shiftLeft == true) {
		
			 			PhoneFlag = false;
			 			return;
			}
			//keycode 16 = shift key, 9 = tab	Key
			 if((16 == keyCode) || ( ( 9 == keyCode) && ( (window.event.shiftkey) || (window.event.shiftLeft) ) ) )
			 	{
		
			 		PhoneFlag = false;
			 		return;
				}
			 
		} else { // Netscape specific
			// if shift key is pressed, return from function
			if( e.modifiers & Event.SHIFT_MASK ) {
				return;
			}
			keyCode = e.which
			//keycode 16 = shift key, 9 = tab	Key
			if((16 == keyCode) || (( 9 == keyCode) && (e.modifiers & Event.SHIFT_MASK)))
			{
					PhoneFlag = false;
					return;
			}
	}

	var controlLength = 0
	// Telephone control has maxlength of 3 , 3 AND 4 
	if(CurrentControl.name.substring( (CurrentControl.name.length-12) , CurrentControl.name.length ) == 'NationalCode'  )
		controlLength = 3
	else  if( CurrentControl.name.substring( (CurrentControl.name.length-8), CurrentControl.name.length ) == 'AreaCode'  ) {
		controlLength = 3
	} else 
		controlLength = 4
	
	if (!(isNaN(parseInt(CurrentControl.value))))
		{	//alert("number")
		    if( ( (keyCode>=48 && keyCode<=57) || (keyCode>=96 && keyCode<=105) )) {
			   	PhoneFlag = true; 
				if ((controlLength == CurrentControl.value.length) && (true == PhoneFlag)) {
					PhoneFlag = false;
					NextControl.focus();
				}
			} else 
				PhoneFlag = false;	
		} else {
			PhoneFlag = false;
		}
}
          
//FIREFOX CODE FOR SUBMIT BUTTOn
function addClickFunction(id) 
    {
       
            var b = document.getElementById(id);
            if (b && typeof(b.click) == 'undefined') b.click = function()
             {
             
                var result = true; if (b.onclick) result = b.onclick();
                if (typeof(result) == 'undefined' || result) 
                    {
                
                             eval(b.href); 
                
                    }                
             }
       
        }          
        
        
           
function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail Address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail Address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail Address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail Address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail Address")
		    return false
		 }

 		 return true					
	}

        function ValidateForm(emailaddress)
        {
	        var emailID=emailaddress;
        	
	        if ((emailID.value==null)||(emailID.value=="")){
		        alert("Please Enter Email Address");
		        emailID.focus();
		        return false;
	        }
	        if (echeck(emailID.value)==false){
		        emailID.value="";
		        emailID.focus();
		        return false
	        }
	        return true
        }   
        
        
        
          
        function ShowWinVideo(ID)
        {
             window.open("../profile/WinMedia.aspx?ID="+ID, "Video", "location=no,resizable=yes,top=120,left=250,height=600,width=650,status=no,toolbar=no,scrollbars=yes");
        }
        function ShowQckVideo(ID)
        {
            window.open("../profile/QuickMedia.aspx?ID="+ID, "Video", "location=no,resizable=yes,top=120,left=250,height=600,width=650,status=no,toolbar=no,scrollbars=yes");
        }
        