// JavaScript Document

/**
* Date: 19-May-2008
* Author: Guru
*
*/


var doc = document;
var arr;

  var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
  
// trim() function definition
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/, ''); };

/*
 *
 *
 *
 */
function redirect(loc, val)
{
	switch(val)
	{
		case 1:
		default:
		    document.location.href = loc;
			break;
			
		case 2:
			document.location.href = loc;
			break;
	}
}

/*
 *
 *
 *
 */
function validateForm(f)
{
	var i;
	var arr = f.elements;
	
	k = 1;
	
	for ( i = 0; i < arr.length; i++ )
	{	   
	   if ( !isEmpty(arr[i]) )	   
	   	 break;
	}
	
	if ( k != 0)
	{
		if ( !checkURL( f.url.value.trim() ) )	
		{
			alert('Please provide valid url');
			f.url.style.backgroundColor = '#FFCD9B';
			f.url.focus();
			f.url.select();
			k = 0;		
		}
		else
		 k = 2;
	}
	
	if ( k == 2 )
	{
		if ( !isNaN( f.noofvisitors.value.trim() )  && f.noofvisitors.value.trim() > 0 )
			k = 1;
		else
		 {
			 alert('Please enter a valid number of visitors');
			 f.noofvisitors.style.backgroundColor = '#FFCD9B';
			 f.noofvisitors.focus();
			 k = 0;
		 }  
	}
	
	//Form Submission code
	if ( k )
	{
		/*if ( confirm( 'Are you sure to proceed....?' ) )
		{*/
			for ( i = 0; i< arr.length; i++ )
			{
				if ( arr[i].type != 'hidden' && arr[i].type != 'button' )
					arr[i].className = 'readOnly';
			}			
			f.submit1.value = 'wait....';	
			f.submit1.disabled = true;
			showProgressBar();
			setTimeout('document.forms[0].submit();', 1000);	
		//}
	}
}

/*
 *
 *
 *
 */
 function isEmpty(oid)
 {
	 k = 1;
	 if ( oid != null )
	 {
	  if ( oid.value.trim().length == 0 )
	   {
		//alert('Please provide valid input');
		alert('  Please enter required data in the field  ');
		oid.style.backgroundColor = '#FFCD9B';
		if ( oid.type == 'text' || oid.type == 'textarea' )
			oid.select();
		oid.focus();
		k = 0;
	   }	   
	 }
	return k;   
 }
 
/*
 *
 *
 *
 */
function firstFocus(oid)
{
	if ( oid != null )
	 document.getElementById(oid).focus();
}



function checkURL(url)
{
    var RegExp = /^(([\w]+:)?\/\/)?(([\d\w]|%[a-fA-f\d]{2,2})+(:([\d\w]|%[a-fA-f\d]{2,2})+)?@)?([\d\w][-\d\w]{0,253}[\d\w]\.)+[\w]{2,4}(:[\d]+)?(\/([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)*(\?(&?([-+_~.\d\w]|%[a-fA-f\d]{2,2})=?)*)?(#([-+_~.\d\w]|%[a-fA-f\d]{2,2})*)?$/;

	if ( RegExp.test(url) )
        return 1;
    else
        return 0;
    
} 


// Function to validate e-mail address
function checkemail( mailId )
{
  k = 1;
  str = mailId.value;
	
	if ( !filter.test( str ) )
	{
		alert('Please enter valid email address')
		mailId.focus();
		k = 0;
	}	
	return k;
}



function validateYourself(f)
{
	var i;
	var arr = f.elements;
	
	k = 1;
	
	f.addline2.value = f.addline2.value.trim() != 0 ? f.addline2.value.trim() : '-' ;
	
	for ( i = 0; i < arr.length; i++ )
	{
	  if ( arr[i].disabled != true && arr[i].type != 'hidden' && arr[i].id != 'fax' )	
	   if ( !isEmpty(arr[i]) )	   
	   	 break;
		 
	  if ( f.state1 == null )
	  {
		if ( document.getElementById('state1') != null )
		{
		f.state1_1.value = document.getElementById('state1').value.trim();  
		//alert( f.state1_1.value.trim() );
	    if ( !isEmpty( document.getElementById('state1') ) )	   
	   	 break;
		}
	  }	
	}

	if ( k != 0 )
	{
	  if ( document.getElementById('ajaxMsg').className != 'success' )
	  {
		alert( 'Invalid e-mail id / e-mail id already exists...' );
		document.getElementById('uremail').focus();
		k = 0;
	  }
	  else
	   k = 2;
	}
	
	if ( k == 2 )
	{
	  if ( f.uremail.value.trim() != f.uremail2.value.trim() )	
	  {
		alert( 'Please check the email ids you have entered, they did not match.' );
		f.uremail2.focus();
		k = 0;		  
      }
	  else
	   k = 3;
	}
	
//	if ( k == 3 )
//	{
//		/*if ( !isNaN( f.fax.value.trim() )  && f.fax.value.trim() > 0 && f.fax.value.trim().length >= 6 )
//		{*/			
//			if ( !isNaN( f.zip.value.trim() )  && f.zip.value.trim() > 0 && f.zip.value.trim().length > 4 )
//			k = 1;			
//			
//			else
//			{
//			 alert('Please enter valid ZIP Code');
//			 f.zip.focus();
//			 k = 0;
//			}
//		/*}
//		else
//		{
//			 alert('Please enter a valid fax data');
//			 f.fax.focus();
//			 k = 0;			
//		}*/
//	}
	
	if ( k )
	{
		msg = 'Are you sure to proceed....?';	
		if ( f.pid.value != 0 )
		{
		    msg = 'Administrator will need to approve the modifications / changes you have requested.\nThis may take sometime to appear in your account.';	 

			if ( confirm( msg ) )
				fin = 1;
			else
				fin = 0;
		}
		else
		 fin = 1;
		 
		if ( fin )
		{
			for ( i = 0; i< arr.length; i++ )
			{
				if ( arr[i].type != 'hidden' && arr[i].type != 'button' )
					arr[i].className = 'readOnly';
			}
			f.submit1.value = 'wait....';	
			f.submit1.disabled = true;
			showProgressBar();
			setTimeout('document.forms[0].submit();', 1000);			
		}
	}
}


function validateUsernameForm(f)
{
	var i;
	var arr = f.elements;
	
	k = 1;
	//alert ( f.termsofuse.checked );
	for ( i = 0; i < arr.length; i++ )
	{	   
	  if ( arr[i].type != 'hidden' )
	   if ( !isEmpty(arr[i]) )	   
	   	 break;
	}
	
	if ( k != 0 )
	{
		if ( f.termsofuse != null && !f.termsofuse.checked )
		 {
			 alert( 'You must agree to "Terms of use" to use services offered by Xopor' );
			 f.termsofuse.focus();
			 k = 0;
		 }
		 else
		 k = 2;
	}	
	
	if ( k == 2 )
	{
	 if( f.username != null && f.username.disabled != true && f.username.value.trim().length < 5 )
	 {
		alert( 'Username should be minimum of 5 characters' );
		f.username.style.backgroundColor = '#FFCD9B';
		f.username.focus();
		k = 0;		 
	 }
	 else if ( f.pwd.value.trim().length < 6 )
	 {
		alert( 'Password should be minimum 6 characters' );
		f.pwd.style.backgroundColor = '#FFCD9B';
		f.pwd.focus();
		k = 0;
	 }	
	 else if ( document.getElementById('ajaxMsg') != null && document.getElementById('ajaxMsg').className != 'success' )
	  {
		alert( 'Username already exists.' );
		f.username.focus();
		k = 0;
	  }	
     else if ( f.pwd.value.trim() != f.pwd2.value.trim() )
	 {
		 alert('Please check the passwords again');
		 f.pwd2.focus();
		 k = 0;
	 }
	 
	 else
	   k = 1;
	}

	  if ( k )
	  {
		/*if ( confirm( 'Are you sure to proceed....?' ) )
		{*/
		for ( i = 0; i< arr.length; i++ )
		{
			if ( arr[i].type != 'hidden' && arr[i].type != 'button' )
				arr[i].className = 'readOnly';
		}
				
		 f.submit1.value = 'wait....';	
		 f.submit1.disabled = true;
		 document.getElementById('waitMsg').innerHTML = 'please wait a while...the process will take few seconds to get complete....';
		 document.getElementById('prog_bar').style.visibility = 'visible';
		 f.submit();		
		//}
	}	
}


function validatePaymentForm(f)
{
	k = 0;
	arr = f.elements;
	
	switch( f.paymode.selectedIndex )
	{
	  case 0 : if ( f.paymenton.value.trim().length	> 0 )
	  			 k = 1;
			   else
			   {
				//alert('please provide valid input');
				alert('   Please enter required data in the field  ');
				f.paymenton.style.backgroundColor = '#FFCD9B';
				f.paymenton.focus();
				f.paymenton.select();
				k = 0;
			   }
			   
			   if ( k != 0)
			   {
				   /*if ( document.getElementById('paymode').selectedIndex == 0 )
					AjaxCheckForPayPal( document.getElementById( 'paymenton' ).value.trim() ) ;					
					
					if ( document.getElementById('ajaxMsg').className != '' && document.getElementById('ajaxMsg').className != 'success' )   */
					if ( !filter.test( f.paymenton.value ) )
					{
						//alert('Invalid input / paypal email already exists...');
						alert( ' Invalid email id. ' );
						f.paymenton.style.backgroundColor = '#FFCD9B';
						f.paymenton.focus();
						f.paymenton.select();
						k = 0;						
					}	
			   }
				break;
				
	  case 1 : 	for ( i = 0; i < f.elements.length; i++)
	  			{
					//alert ( f.elements[i].id );
					 if ( f.elements[i].type != 'hidden' )	
					    if ( !isEmpty( f.elements[i] ) )	   
					   	 break;
						 
					if ( f.addline3 == null )		
					{
						f.addline3_1.value = document.getElementById('addline3').value;						
					    if ( !isEmpty( document.getElementById('addline3') ) )	   
					   	 break;							
					}
					if ( f.addline4 == null )
					{
						f.addline4_1.value = document.getElementById('addline4').value;						
					    if ( !isEmpty( document.getElementById('addline4') ) )	   
					   	 break;													
					}
					if ( f.city2 == null )
					{
						f.city2_1.value = document.getElementById('city2').value;						
					    if ( !isEmpty( document.getElementById('city2') ) )	   
					   	 break;													
					}
					if ( f.country2 == null )
					{
						f.country2_1.value = document.getElementById('country2').value;												
					    if ( !isEmpty( document.getElementById('country2') ) )	   
					   	 break;													
					}
					if ( f.state2 == null )
					{
						f.state2_1.value = document.getElementById('state2').value;												
					    if ( !isEmpty( document.getElementById('state2') ) )	   
					   	 break;													
					}					
				}
				
				if ( k != 0 )
				{
					//alert( document.getElementById('zip2').value );	
				if ( f.zip2 == null )
				{
				 f.zip2_1.value = document.getElementById('zip2').value ;		
				 f.zip2 = document.getElementById('zip2') ;	
				}
				 
				 if ( !isNaN( f.zip2.value.trim() )  && f.zip2.value.trim() > 0 && f.zip2.value.trim().length > 4 )	
				 k = 1;
				 else
				 {
					alert('Please enter valid ZIP Code');
					f.zip2.style.backgroundColor = '#FFCD9B';
					f.zip2.focus();
					 k = 0;					 
				 }
				}
				break;
				
		case 2 : for ( i = 0; i < f.elements.length; i++)
	  			{
					 if ( f.elements[i].type != 'hidden' && f.elements[i].id != 'cbcode' && f.elements[i].id != 'cbname' )	
					    if ( !isEmpty( f.elements[i] ) )	   
					   	 break;
					
					if ( f.bankacno == null )		
					{
						f.bankacno_1.value = document.getElementById('bankacno').value.trim();
					    if ( !isEmpty( document.getElementById('bankacno') ) )	   
					   	 break;							
					}
					if ( f.bankname == null )		
					{
						f.bankname_1.value = document.getElementById('bankname').value.trim();						
					    if ( !isEmpty( document.getElementById('bankname') ) )	   
					   	 break;							
					}
					if ( f.branchname == null )		
					{
						f.branchname_1.value = document.getElementById('branchname').value.trim();
					    if ( !isEmpty( document.getElementById('branchname') ) )	   
					   	 break;							
					}
					if ( f.swiftno == null )		
					{
						f.swiftno_1.value = document.getElementById('swiftno').value.trim();
					    if ( !isEmpty( document.getElementById('swiftno') ) )	   
					   	 break;							
					}
					if ( f.cbankadd == null )		
					{
						f.cbankadd_1.value = document.getElementById('cbankadd').value.trim();
					    if ( !isEmpty( document.getElementById('cbankadd') ) )	   
					   	 break;							
					}					
					if ( f.bankcity == null )		
					{
						f.bankcity_1.value = document.getElementById('bankcity').value.trim();
					    if ( !isEmpty( document.getElementById('bankcity') ) )	   
					   	 break;							
					}					
					if ( f.bankcountry == null )		
					{
						f.bankcountry_1.value = document.getElementById('bankcountry').value.trim();
					    if ( !isEmpty( document.getElementById('bankcountry') ) )	   
					   	 break;							
					}
					if ( f.cbname == null )
						f.cbname_1.value = document.getElementById('cbname').value.trim();
					if ( f.cbcode == null )
						f.cbcode_1.value = document.getElementById('cbcode').value.trim();						
				}
				
			if ( k != 0 )
				{
				if ( f.bankzip == null )	
				{
				 f.bankzip_1.value = document.getElementById('bankzip').value.trim();	
				 f.bankzip = document.getElementById('bankzip') ;	
				}
					
				 if ( !isNaN( f.bankzip.value.trim() )  && f.bankzip.value.trim() > 0 && f.bankzip.value.trim().length > 4 )	
				 k = 1;
				 else
				 {
					alert('Please enter valid ZIP Code');
					f.bankzip.style.backgroundColor = '#FFCD9B';
					f.bankzip.focus();
					 k = 0;					 
				 }
				}				
				break;
	}
	
	if ( k )
	{
		/*
	msg = 'Are you sure to proceed....?';	
	if ( f.pid.value != 0 )
	 msg = 'Changes you made will reflect after the acceptance given by ADMIN.';
	 
	if ( confirm( msg ) )
		{
			if ( arr != null )
			{
				for ( i = 0; i< arr.length; i++ )
				{
					if ( arr[i].type != 'hidden' && arr[i].type != 'button' )
						arr[i].className = 'readOnly';
				}
			}
			f.submit1.value = 'wait....';	
			f.submit1.disabled = true;
			showProgressBar();
			setTimeout('document.forms[0].submit();', 1700);	
		}
	*/

		msg = 'Are you sure to proceed....?';	
		if ( f.pid.value != 0 )
		{
		    msg = 'Administrator will need to approve the modifications / changes you have requested.\nThis may take sometime to appear in your account.';	 

			if ( confirm( msg ) )
				fin = 1;
			else
				fin = 0;
		}
		else
		 fin = 1;
		 
		if ( fin )
		{
			for ( i = 0; i< arr.length; i++ )
			{
				if ( arr[i].type != 'hidden' && arr[i].type != 'button' )
					arr[i].className = 'readOnly';
			}
			f.submit1.value = 'wait....';	
			f.submit1.disabled = true;
			showProgressBar();
			setTimeout('document.forms[0].submit();', 1000);			
		}		
	}
}
/*
 *
 *
 *
 */

function validateLoginForm(f)
{
	var i;
	var arr = f.elements;
	
	k = 1;
	
	for ( i = 0; i < arr.length; i++ )
	{	   
	   if ( !isEmpty(arr[i]) )	   
	    /*break;
	   else	*/
		 return false; 
	}
	
	if ( k )
	 f.submit();
}

/*
 *
 *
 *
 */

function doLogout()
{
	if ( confirm('Do you really want to LOGOUT now ?') )	
	 document.location.href = '../logout.php';
}




function noteBlur( conId, val )
{
	cid = document.getElementById(conId);
	
	switch ( val )
	{
	case 1 :	
	cid.innerHTML = 'This is the url of the website where you wish to post the advertisements. You may add more websites once you have registered using this primary website.';	
	break;
	
	case 2 :
	cid.innerHTML = 'Please Let us know about your website here. This is important so that it helps in placing appropriate advertisements on your website and allow you to monetize the same.';
	break;
	
	case 3 :
		cid.innerHTML = 'Please mention here the number of unique visitors visiting your website in a day.';
		break;

	case 4 :
		cid.innerHTML = 'Please define top three or four countries from where your visitors are example: USA, UK, India, China.';
		break;

	case 5 :
		cid.innerHTML = 'Your website must be categorized into one of the categories in the list. If you find that your website does not fit in to any category here, you may mention the category in “Others” column.';
		break;

	case 6 :
cid.innerHTML = 'Please enter your complete name here like “Stephen Johnson”, “Meng Ching Ling”, “Rajesh Agarwal”';
		break;
		
	case 7 :
		cid.innerHTML = 'Please enter your Company name here';
		break;
		
	case 8 :
		cid.innerHTML = 'This is important. This email id will be used for sending all the communication to you';
		break;
		
	case 9 :	
		cid.innerHTML = 'Fax number should be in this format.<br /><span style="color:#0000FF; font-style:normal; text-align:left;">Country Code + Area Code + Number. Example: 14156123456, 9143132654, 9245208997</span>';	
		break;
		
	case 10 :
		cid.innerHTML = 'Please mention your complete address. All the payments and documents will be sent to this address only';
		break;
		
	case 11 :
		 cid.innerHTML = 'Please provide your City/Town name';
		  break;
	
	case 12 :	
		 cid.innerHTML = 'Please choose your country from the drop down list';	
		  break;
		  
	case 13 :	
		 cid.innerHTML = 'Choose your state from the list if your country is india otherwise type the state name in the text field displayed.';	
		  break;

	case 14 :	
		 cid.innerHTML = 'Please provide valid zip code';
		  break;
		  
	case 15 :
		 cid.innerHTML = 'Payments will be in three formats. Paypal, Check and Wire Transfer. ';
		 break;
	
	case 16:
		 cid.innerHTML = 'Please provide the name payment should be made to';
		 break;

	case 35:
		 cid.innerHTML = 'Please choose a user name for accessing your control panel.';
		 break;
	
	case 36:
		 cid.innerHTML = 'Password must be minimum 6 characters.';
		 break;
		 
	case 37:
		 cid.innerHTML = 'Please choose the password hint question.';
		 break;	 

	case 38:
		 cid.innerHTML = 'Please provide the password hint answer.';
		 break;

	case 39:
		 cid.innerHTML = 'Please provide your contact number. <span style="color:#FF0000;font-style:normal;">Do not use any spaces or special signs. Use only numers.</span>';
		 break;
		 
	case 40:
		 cid.innerHTML = 'Please tell us the most comfortable time to contact you. The valid format is <span style="color:#0000FF;font-style:normal;">HH:MM AM/PM</span>';
		 break;	
	}
}

	/*
	*
	*
	*
	*
	*/
	
	function validateAddZoneForm(f)
	{
		var arr = f.elements;
		
		k = 1;
		
		for ( i = 0; i < arr.length; i++ )
		{	   
			if ( !isEmpty(arr[i]) )	   
				break;
		}
		
		if ( k )
		{
		  Msg = f.fuseaction.value != 'edit' ? 'Are you sure to proceed...?' : 'Administrator will need to approve the modifications / changes you have requested.\nThis may take sometime to appear in your account.' ;	
			if ( confirm( Msg ) )
			{	
				for ( i = 0; i< arr.length; i++ )
				{
					if ( arr[i].type != 'hidden' && arr[i].type != 'button' )
						arr[i].className = 'readOnly';
				}
				f.Submit.value = 'wait....';	
				f.Submit.disabled = true;
				showProgressBar();
				setTimeout('document.forms[0].submit();', 1700);	
			}
		}		
	}
	
	
	function showProgressBar()
	{
		document.getElementById('prog_bar').style.visibility = 'visible';
	}
	
	
	function AjaxCheckForPayPal( str )
	{
		if ( document.getElementById('paymode').selectedIndex == 0 )
		 AjaxCheck( str, '4');
		else
		 document.getElementById('ajaxMsg').innerHTML = '';
	}


   function changeCategoryControl( val, val2 )
   {
	    //alert(val.indexOf('other...')); alert(val2);
		//alert(val + val2);
		if ( val.indexOf('OTHER') != -1 )
		{
			document.getElementById('categorySpan').innerHTML = '<input type="text" name="category1" id="category1" value="' + val2 + '" maxlength="26" />';	
		}
   }   
   
   
   function changePwdHintQuescontrol( val )
   {
		if ( val == 'other' )
		{
			document.getElementById('hintQueSpan').innerHTML = '<input type="text" name="pwdhintque1" id="pwdhintque1"  maxlength="44" size="35" />';	
		}	   
   }
   
   
   function changeIcon( sid )
   {
	 arr = [ 2, 3, 4, 7, 8, 9 ]; 
	
	 if ( sid > 0 )
	 {
		  imgId = 'img' + ( sid - 1 );
		  
		 for ( i = 0; i < 6; i++ )
		 {
			oid = 'img' + i; 
			if ( i == ( sid - 1 ) )
			 document.getElementById(imgId).src = '../images/' + ( arr[ sid - 1 ] ) + 'c.gif';
			else 
			 document.getElementById(oid).src = '../images/' + ( arr[ i ] ) + '.gif';
		 }
	 }
	 else
	 {
		 for ( i = 0; i < 6; i++ )
		 {
			oid = 'img' + i; 
			document.getElementById(oid).src = '../images/' + ( arr[ i ] ) + '.gif';		 
		 }
	 }
   }
   
   
   function isTextAd( oid )
   {
	   if ( oid.checked && oid.value == 'Text ad' )
	    {
			doc.getElementById( 'zonesize' ).selectedIndex = 10;
			changeIcon( 10 );
		}
	   else
	   {
			doc.getElementById( 'zonesize' ).selectedIndex = 0;
			changeIcon( 0 );		   
	   }
   }
   
   
   function showAlert( val )
   {
	  switch ( val )
	  {
		case 0: msg = 'Oops! This zone is yet to get acceptance from ADMIN.';  
				break;
	  }
	  alert ( msg );
   }
   
   function Confirm ( val )
   {
	switch ( val )
	{
		case 0: msg = 'Do you really want to disable this zone...?';  
				break;
	}
	return confirm ( msg );	   
   }
   
   
   function reloadRepo ( sid )
   {
	   //document.getElementById('mon').value = sid.value;
	   var loc = document.location.href;
	   
	   //alert ( loc.substr( 0, loc.indexOf('&mon=') ) ) ;
	   
	   if ( loc.indexOf('&mon') == -1 )
		document.location.href += '&mon=' + sid.value ;   
	   else	
	    document.location.href = loc.substr( 0, loc.indexOf('&mon') ) + '&mon=' + sid.value ;     
   }
   
   var SpnId ;
   function sendDatesforReport ( zoneid, imgId, rowId )
   {
	    /*loaderGif = doc.getElementById('loader');
		loaderGif.style.visibility = 'visible';*/
		
		SpnId = 'ajaxMsg' + zoneid ;
		
		//alert(SpnId);
		if ( imgId.src.indexOf('black') != -1 )
		{
			document.getElementById( SpnId ).innerHTML = '<img src="../images/loading_g.gif" alt="img" title="loading...." align="center" />';
			document.getElementById( rowId ).style.backgroundColor = '#ECECEC';
			imgId.src = '../images/bluearrow.png';
			imgId.title = 'Click to minimize';
			fromDate = document.getElementById('fromDate').value;
			toDate = document.getElementById('toDate').value;
			month    = document.getElementById('mon').value;
			
			fromDate = fromDate ? '&' + fromDate : '' ;
			toDate   =  toDate  ? '&' + toDate : '' ;
			month    =  month   ? '&' + month : '' ;
			
			isExists( zoneid + fromDate + toDate + month, '5' ) ;
		}
		else
		{
			document.getElementById( rowId ).style.backgroundColor = '#FFFFFF';
			imgId.src = '../images/blackarrow.png';
			imgId.title = 'Click to Expland';
			document.getElementById( SpnId ).innerHTML = '';			
		}
		
   }
   
   
   function getTxtBox( aid, spanid )
   {	  
	  if ( aid.innerHTML.indexOf('Edit') != -1 )
	  {
		  aval = doc.getElementById( spanid ).innerHTML;
		  doc.getElementById( spanid ).innerHTML = '<input type="text" id="taxid" name="taxid" maxlength="15" size="13" value="' + aval + '" />';
		  doc.getElementById ( 'taxid' ).focus();
		  aid.innerHTML = 'Add';		  
	  }
	  else							 
	  {
	  if ( doc.getElementById( 'taxid' ) != null )
	  	{
			tax_id = doc.getElementById( 'taxid' );
			if ( tax_id.value.length == 0 )
			 {
				alert( 'You must update your Tax ID for the payments to be processed.' );
				tax_id.style.backgroundColor = '#FFCC99';
				tax_id.focus();
				aid.innerHTML = 'Add';	
			 }
			 else
			 {
				isExists( tax_id.value, '6' ); 
				doc.getElementById( spanid ).innerHTML = tax_id.value;
				aid.innerHTML = 'Edit';
			 }
		}
	  }	  
   }
   
   
   function validateNewTicketForm ( f )
   {
	 if ( f.tktsubject.value.trim().length == 0 )
	 {
		alert('Please enter "Subject" for the ticket.');
		f.tktsubject.style.backgroundColor = '#FFCC99';
		f.tktsubject.focus();
	 }
	 else if ( f.tktdesc.value.trim().length == 0 )
	 {
		alert('Please enter detailed description for the ticket.');
		f.tktdesc.style.backgroundColor = '#FFCC99';
		f.tktdesc.focus();
	 }
	 else
	 {
		showProgressBar();
		f.tktsubject.className = 'readOnly' ;
		f.tktdesc.className	   = 'readOnly' ;	
	 	f.submit();
	 }
   }   
   
   
	function dispReply( f )
	{
		f.reply.style.visibility = 'visible';

		if ( f.reply.value.length )
		{
		 f.reply.className = 'readOnly';	
		 f.submit1.value = 'wait....';	
		 f.submit1.disabled = true;	
		 showProgressBar();
		 f.submit();
		}
		/*else
		{
			alert ( 'Description required .... ' );	
			f.reply.style.backgroundColor = '#FFCC99';
			f.reply.focus();
		}*/
	}
	
	function closeTicket( f )
	{
	  /*if ( confirm ( 'Are you sure to close this ticket .... ?' ) )
		{*/
			// window.location = window.location + '&faction=y' ;
			if ( f.submit1 != null )
				f.submit1.disabled = true;
				
			f.reply.style.visibility = 'visible';
			
			msg = 'Provide the Reason for closing....';
			
			if ( f.reply.value.trim().length == 0 )
				f.reply.value = msg;
			
			/*alert( f.reply.value.trim().indexOf( msg ) );
			return false;*/
			
			if ( f.reply.value.length && f.reply.value.trim().indexOf( msg ) == -1 )
			{
			 f.reply.className = 'readOnly';
			 f.submit2.value = 'wait....';	
			 f.submit2.disabled = true;	
			 f.fuseaction.value = 'Y' ;
			 showProgressBar();
			 f.submit();
			}
		//}
	}   
   
   function ShowTime_1( sid )
	{
		var dt = new Date();
		document.getElementById( sid ).innerHTML = dt.toLocaleTimeString();
		window.setTimeout("ShowTime('" + sid + "')", 1000);
	}
	
	
	function mailInvokationCode ()
	{
		//alert( doc.getElementById('zid').value );	
		if ( !document.getElementById('email').value.trim().length )
		 return false;

	    if ( document.getElementById('loader') != null )
		 document.getElementById('loader').style.visibility = 'visible'; 
		
		zoneid = document.getElementById('zid').value ;
		isExists( document.getElementById('email').value.trim() + '&' + zoneid , '7' );
		setTimeout( "document.getElementById('ajaxid').innerHTML='';", 5000 );
		//document.getElementById('email').value = '';
	}	

	function allowAlphaNumerics( evt )
      {
         var charCode = ( evt.which ) ? evt.which : event.keyCode ;		 
         
		 if ( ( charCode >=65 && charCode <= 90 ) || ( charCode >=97 && charCode <= 122 ) || charCode == 8 || charCode == 32 )
            return true;
			
		 if ( charCode > 31 && ( charCode < 48 || charCode > 57 ) )
            return false;		 

         return true;
      }
	  
	function allowNumerics( evt )
      {
         var charCode = ( evt.which ) ? evt.which : event.keyCode ;
		 
         if ( charCode > 31 && ( charCode < 48 || charCode > 57 ) )
            return false;		

         return true;
      }
	  
	  
	function allowAlphabets( evt, par2 )
	{
		var charCode = ( evt.which ) ? evt.which : event.keyCode ;

		if ( par2 )
		 if ( charCode == 44 )
		  return true;
		  
		if ( ( charCode >=65 && charCode <= 90 ) || ( charCode >=97 && charCode <= 122 ) || charCode == 8 || charCode == 32 )
            return true;

         return false;
	}
	
	
	function previewZone ( par1, par2 )
	{
		arr = par2.split('*');
		//alert( arr[0] + '***'  + arr[1] );
		height = parseInt( arr[1] ) + 26;
		width  = parseInt( arr[0] ) + 26;
		
		//alert( width + '**'+ height );
		
		loc = 'zpreview.php?zid=' + par1 + '&ht=' + height + '&wd=' + width ; 
		 window.open ( loc, "mywindow","location=0,status=0,scrollbars=0,width="+ width +",height="+ height + '"' ); 
	}


	function validateContactUsForm ( f )
	{
		arr = f.elements ;
		k = 0;		

		for ( i = 0; i < arr.length; i++ )
		{
     	  spanId = i == 10 ? 'sp9' : 'sp' + i ;		  
			
		  if ( arr[i].type == 'text' || arr[i].type == 'textarea' || arr[i].type == 'select-one' )
		  {		
			if ( arr[i].value.trim().length == 0 && arr[i].id != 'urcompany' )
			{
			 	arr[i].style.backgroundColor = '#FFCCCC'; 
				document.getElementById( spanId ).innerHTML = ' *&nbsp;required ';
				arr[i].focus();
				
				if ( arr[i].type == 'text' || arr[i].type == 'textarea' )
				 arr[i].select();
				 
				k = 0;
				break;
			} 
			else
			{
				arr[i].style.backgroundColor = '#FFFFE1'; 
				document.getElementById( spanId ).innerHTML = '';			
				k = 1;
				continue;
			} 
		  }	
		}
		
		if ( k )
		{
			if ( f.urzip.value.trim().length < 5 )
			{
				f.urzip.style.backgroundColor = '#FFCCCC' ;
				document.getElementById( 'sp4' ).innerHTML = ' * Invalid zip data ' ;
				f.urzip.focus();
				f.urzip.select();
				k = 0;	
			}
			else if ( f.urphone.value.trim().length < 10 ) 
			{
				f.urphone.style.backgroundColor = '#FFCCCC' ;
				document.getElementById( 'sp6' ).innerHTML = ' * Invalid phone# ' ;
				f.urphone.focus();
				f.urphone.select();
				k = 0;	
			}
			else if ( f.urmobile.value.trim().length < 10 ) 
			{
				f.urmobile.style.backgroundColor = '#FFCCCC' ;
				document.getElementById( 'sp7' ).innerHTML = ' * Invalid mobile# ' ;
				f.urmobile.focus();
				f.urmobile.select();
				k = 0;	
			}			
			else if ( !filter.test( f.uremail.value.trim() ) )
			{
				f.uremail.style.backgroundColor = '#FFCCCC' ;
				document.getElementById( 'sp8' ).innerHTML = ' * Invalid email ' ;
				f.uremail.focus();
				f.uremail.select();
				k = 0;
			}
		}
		
		if ( k )
		{
		  f.submit1.value = ' wait.... ';	
		  f.submit1.disabled = true;
		  for ( i = 0; i < arr.length; i++ )
		   arr[ i ].className = 'readOnly' ;
		  showProgressBar();
		  f.submit();
		}
	}
	
	
	function checkConfirmValues( con1, con2, val )
	{
		val1 = con1.value.trim();
		val2 = con2.value.trim();
		
		if ( !val1 || !val2 )
			return;
		
		if ( val == 1 )
		  msg1 = 'Please check the email ids you have entered, they did not match.';
		else  
		  msg1 = 'Please check the passwords you have entered, they did not match.';
		  
		if ( val1 != val2 )
		{
			document.getElementById( 'spanId2' ).className = 'failure';
			document.getElementById( 'spanId2' ).innerHTML = msg1;	
			con2.focus();
		}
		else
			document.getElementById( 'spanId2' ).innerHTML = '';
				
	}
	
	
	function usernameValidate( evt )
	{
	var charCode = ( evt.which ) ? evt.which : event.keyCode ;
	
	//alert ( charCode );
	if ( ( charCode >=65 && charCode <= 90 ) || ( charCode >=97 && charCode <= 122 ) || ( charCode >=48 && charCode <= 57 ) || charCode == 46 || charCode == 95 || charCode == 8 )
            return true;

         return false;		
	}	
	
	
	function changeIoc( selIndex )
	{
		if ( selIndex != 0 )
			document.getElementById('ioccode').value = document.getElementById('jscode').value ;
		else
			document.getElementById('ioccode').value = document.getElementById('iframecode').value ;	
	}
	
	
	function openPage( val )
	{
		width  = 620;
		height = 710;
		
		page = val != 1 ? '../tofuse.html' : 'ppolicy.html' ;
		
		window.open ( page, "mywindow","location=0,status=0,scrollbars=1,width="+ width +",height="+ height + '"' );
	}	
	
	
	function disableStates( state1 )
	{
		var f = document.forms[0];		
		
		if ( f.country.value != 'United States' && f.country.value != 'India' )
		  document.getElementById( 'pinfo' ).innerHTML = 'Please enter your State name' ;
		else
		document.getElementById( 'pinfo' ).innerHTML = 'Please choose your country from the drop down list';

		if ( f.country.value == 'India' )
		{
			document.getElementById('oState').innerHTML = '';			
			f.state.disabled = false;			
		 	j = 0;
			f.state.options.length = 27;			
			for ( i = 50; i < 77; i++ )
			 {				 
				 f.state.options[ j ].value = f.sstate.options[ i ].value;
				 f.state.options[ j ].text  = f.sstate.options[ i ].value;

				 if ( f.state.options[ j ].value == state1 )
				  f.state.selectedIndex = j ;
				  
			 	 j++;
			 }			 
		}
		
		else if ( f.country.value != 'United States' && f.country.value != 'India' )
		{			
		    f.state.selectedIndex = 0; 
			f.state.disabled = true;
			document.getElementById('oState').innerHTML = '<input type="text" maxLength="50" size="14" name="state1" id="state1" value="' + state1 + '" />';	
			document.getElementById( 'state1' ).focus();
		}
		else
		{	
			document.getElementById('oState').innerHTML = '';			
			f.state.disabled = false;
			f.state.options.length = 50;			

			for ( i = 0; i < 50; i++ )
			 {
				 f.state.options[ i ].value = f.sstate.options[ i ].value;
				 f.state.options[ i ].text  = f.sstate.options[ i ].value;

				 if ( f.state.options[ i ].value == state1 )
				  f.state.selectedIndex = i ;				 
			 }			 			
		}
	}	
	
	
	function getExcel( val )
	{
		fromDate = document.getElementById( 'fromDate' ).value;
		toDate   = document.getElementById( 'toDate' ).value; 
		mon		 = document.getElementById( 'mon' ).value; 
		
		uri = './excel/?fd=' + fromDate + '&td=' + toDate + '&mon=' + mon + '&typ=' + val ;
		window.location = uri ;
	}
	
	function checkPwd( pwd )
	{
		val = pwd.value.trim().length;
		
		if ( val < 6 )
		 document.getElementById('errmsg').innerHTML = 'Password should contain minimum of 6 characters';
		 else
		 document.getElementById('errmsg').innerHTML = '' ;
	}
	
	
	function checkForEnterKey( evt )
	{
		var charCode = ( evt.which ) ? evt.which : event.keyCode ;

		if ( charCode == 13 )
		 return false;
	}
	
	function openHelpWindow()
	{
		loc = './xopor-help.html';
		windowReference = window.open ( loc, "mywindow","location=0,status=0,scrollbars=0,width=400, height=300,left=350,top=260,screenX=0,screenY=100" );		
	}
	
	function validateSupportForm( f )
	{
		arr = f.elements ;
		k = 0;		

		for ( i = 0; i < arr.length; i++ )
		{
     	  spanId = 'sp' + i ;		  
			
		  if ( arr[i].type == 'text' || arr[i].type == 'textarea' || arr[i].type == 'select-one' )
		  {		
			if ( arr[i].value.trim().length == 0 && arr[i].id != 'urcompany' )
			{
			 	arr[i].style.backgroundColor = '#FFCCCC'; 
				document.getElementById( spanId ).innerHTML = ' * required ';
				arr[i].focus();
				
				if ( arr[i].type == 'text' || arr[i].type == 'textarea' )
				 arr[i].select();
				 
				k = 0;
				break;
			} 
			else
			{
				arr[i].style.backgroundColor = '#FFFFE1'; 
				document.getElementById( spanId ).innerHTML = '';			
				k = 1;
				continue;
			} 
		  }	
		}
		
		if ( k )
		{
			if ( !filter.test( f.uremail.value.trim() ) )
			{
				f.uremail.style.backgroundColor = '#FFCCCC' ;
				document.getElementById( 'sp4' ).innerHTML = ' * Invalid email ' ;
				f.uremail.focus();
				f.uremail.select();
				k = 0;
			}			
		}
		
		if ( k )
		{
		  f.submit1.value = ' wait.... ';	
		  f.submit1.disabled = true;
		  for ( i = 0; i < arr.length; i++ )
		   arr[ i ].className = 'readOnly' ;
		  showProgressBar();
		  f.submit();
		}		
	}
	
	function showCallout( val )
	{
		if ( !val )
		 document.getElementById( 'call_out' ).style.visibility = 'hidden';
		else
		 document.getElementById( 'call_out' ).style.visibility = 'visible';
	}