function _onloadWhat(){

	document.getElementById("teaser").focus();
	updateMessage();
	updateFullAd();
	updateTeaser();
	
		
}


function _allowNumberOnly(event){

var k = event.which ? event.which : (window.event ? window.event.keyCode : 0);
        if( k==8 || k== 9 || k== 0)
          {
             return true;
          }
        
         if(k>= 48 && k<= 57)               
                {  
                  return /^(\d)$/.test(String.fromCharCode(k) );  
                }
        
          return false;
   
}

function _allowDate(event){

var k = event.which ? event.which : (window.event ? window.event.keyCode : 0);
        if( k==8 || k== 9 || k== 0)
          {
             return true;
          }
        
         if(k>= 48 && k<= 57)               
                {  
                  return /^(\d)$/.test(String.fromCharCode(k) );  
                }
        
         if(k==45 )               
                {  
                  return /^(\d)$/.test(String.fromCharCode(k) );  
                }
        
          return false;
   
}


function _submitWhat(){
 		
 					if(document.getElementById("modeID").value == "create" ) {
 						document.getElementById("createPromoWhatFormId").action = "createPromoWhen.action?mode=create";
            			document.createPromoWhatForm.submit();
 					}else{
 						document.getElementById("createPromoWhatFormId").action = "editPromoWhen.action?mode=edit";
            			document.createPromoWhatForm.submit();
 					}
                     
 	}
 
function _confirmationWhat() 
	{
     	if(document.getElementById("modeID").value == "create" ){
      		var answer = confirm("You are about to cancel the Promo Creation procedure.")}
    	else{
        	var answer = confirm("You are about to cancel the Promo Editing procedure.")
      	}
      
  	if(answer){
            document.getElementById("createPromoWhatFormId").action = "adverPromos.action";
            document.createPromoWhatForm.submit();
    	 }
	}


		


 
 	function _submitWhen(){
 		
 					if(document.getElementById("modeID").value == "create" ) {	
 					
 						document.getElementById("createPromoWhenFormId").action = "createPromoWhere.action?mode=create";
            			document.createPromoWhenForm.submit();
 					}
 					
 					else{
 							
 					
 						document.getElementById("createPromoWhenFormId").action = "editPromoWhere.action?mode=edit";
            			document.createPromoWhenForm.submit();	
 					}                   
 	}
 

  
     	function _backWhen(){
	
 					if(document.getElementById("modeID").value == "create" ) {
 						window.location = "createPromoWhatSp.action?mode=create&from=back";            			
 					}
 					
 					else{
 					
 						window.location = "editPromoWhat.action?mode=edit&from=back";            			
 					
 					}
	
	}	
 


	function _confirmationWhen() 
	{
     	if(document.getElementById("modeID").value == "create" ){
      		var answer = confirm("You are about to cancel the Promo Creation procedure.")}
    	else{
        	var answer = confirm("You are about to cancel the Promo Editing procedure.")
      		}
      
      if (answer){

            document.getElementById("createPromoWhenFormId").action = "adverPromos.action";

            document.createPromoWhenForm.submit();

     	 }

	}
	

	function _toggleExpiration()
		{

			document.getElementById("expires_text").disabled = !document.getElementById("expires_text").disabled;

		}


function _displayDays(){

		if(!document.getElementById("promoDaysSelRadioIDoptionD").checked){
		

			document.getElementById("sunday").disabled="true";
			document.getElementById("monday").disabled="true";
			document.getElementById("tuesday").disabled="true";
			document.getElementById("wednesday").disabled="true";
			document.getElementById("thursday").disabled="true";
			document.getElementById("friday").disabled="true";
			document.getElementById("saturday").disabled="true";
			
		}
		else if(document.getElementById("promoDaysSelRadioIDoptionD").checked){
		
	
			if(document.getElementById("sunday").disabled){
			document.getElementById("sunday").disabled=!document.getElementById("sunday").disabled;
			}
			
			if(document.getElementById("monday").disabled){
			document.getElementById("monday").disabled=!document.getElementById("monday").disabled;}
			
			if(document.getElementById("tuesday").disabled){
			document.getElementById("tuesday").disabled=!document.getElementById("tuesday").disabled;}
			
			if(document.getElementById("wednesday").disabled){
			document.getElementById("wednesday").disabled=!document.getElementById("wednesday").disabled;}
			
			if(document.getElementById("thursday").disabled){
			document.getElementById("thursday").disabled=!document.getElementById("thursday").disabled;}
			
			if(document.getElementById("friday").disabled){
			document.getElementById("friday").disabled=!document.getElementById("friday").disabled;}
			
			if(document.getElementById("saturday").disabled){
			document.getElementById("saturday").disabled=!document.getElementById("saturday").disabled;}
			
		}
	
}


function _expiration(){

		updateExpiration();

		if(!document.getElementById("expires").checked){
				
				document.getElementById("expires_text").readOnly="true";
				document.getElementById("expires_text").value="";
			
		}
		else if(document.getElementById("expires").checked){
	
			if(document.getElementById("expires_text").readOnly){	
			document.getElementById("expires_text").readOnly=!document.getElementById("expires_text").readOnly;
		
			
			}
		
		
		}
		
		
		
		
}


function _onloadWhen(){
	if(document.getElementById("promoDaysSelRadioIDoptionD").checked){
					document.getElementById("promoDaysSelRadioIDoptionD").focus();	
					}
					
	else if(document.getElementById("promoDaysSelRadioIDoptionA").checked){
					document.getElementById("promoDaysSelRadioIDoptionA").focus();
						}
					
					
	else if (document.getElementById("promoDaysSelRadioIDoptionB").checked){
					document.getElementById("promoDaysSelRadioIDoptionB").focus();
						}
					
	else if(document.getElementById("promoDaysSelRadioIDoptionC").checked){
					document.getElementById("promoDaysSelRadioIDoptionC").focus();
						}
						
}


function _submitWhere(){
 		
		
 					if(document.getElementById("modeID").value == "create" ) {
 						
 					
 						document.getElementById("createPromoWhereFormId").action = "createPromoBid.action?mode=create";
            			document.createPromoWhereForm.submit();
 					}
 					
 					else{
 					
 						document.getElementById("createPromoWhereFormId").action = "editPromoBid.action?mode=edit";
            			document.createPromoWhereForm.submit();
 					
 					}
        }        
        
        
        	function _backWhere(){
	
 					if(document.getElementById("modeID").value == "create" ) {
 						window.location = "createPromoWhen.action?mode=create&from=back";            			
 					}
 					
 					else{
 					
 						window.location = "editPromoWhen.action?mode=edit&from=back";
            			
 					
 					}
	
	
	}	
		
	
	function _confirmationWhere(){
      	
      	if(document.getElementById("modeID").value == "create" ){
      		var answer = confirm("You are about to cancel the Promo Creation procedure.")}
    	else{
        	var answer = confirm("You are about to cancel the Promo Editing procedure.")
      	}
      				
     	if (answer){
          	 document.getElementById("createPromoWhereFormId").action = "adverPromos.action";
            document.createPromoWhereForm.submit();
     	 }
	}
	
	

function _onloadBid(){
	 	document.getElementById("bid").focus();
	 	
	 	}
	 	
	 	
	 	function _submitBid(){
 		
 					if(document.getElementById("modeID").value == "create" ) {
 						document.getElementById("createPromoBidFormId").action = "savePromotion.action?mode=create";
            			document.createPromoBidForm.submit();
 					}
 					
 					else{
 					
 				
 						document.getElementById("createPromoBidFormId").action = "saveEditPromotion.action?mode=edit";
            			document.createPromoBidForm.submit();
 					
 					}
 	 
		}
		

	function _backBid(){	
			if(document.getElementById("modeID").value == "create" ) {
				window.location = "createPromoWhere.action?mode=create&from=back";         			
			}else{ 					
				window.location = "editPromoWhere.action?mode=edit&from=back";         			 					
			}		
	}	
		

	function _confirmationBid() 
	{
	
	if(document.getElementById("modeID").value == "create" ){
      		var answer = confirm("You are about to cancel the Promo Creation procedure.")}
    	else{
        	var answer = confirm("You are about to cancel the Promo Editing procedure.")
      	}

      if (answer){

            document.getElementById("createPromoBidFormId").action ="adverPromos.action"

            document.createPromoBidForm.submit();

     	 }

	}


		
	function _togglePhoneText()
		{
			document.getElementById("call").disabled = !document.getElementById("call").disabled;
			updateMessage();

		}	
		
		
	function updateMessage()
	{
		var checkbox = document.getElementById('click_to_call');
		var message1= document.getElementById('msgNoPhone');
		var message2= document.getElementById('msgHavePhone');
		var text = document.getElementById('message');
	
		if (checkbox.checked) {
			text.innerHTML = message2.value;
		} else {
			text.innerHTML = message1.value;
		}
	}
		
		
		
