// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults


function hideAndShowAdvanceSearch(show){
  if(show=='true'){
    Element.show('greybg'); 
	Element.show('filter_commission'); 
    Element.hide('div_to_show');
  }else{
    Element.hide('greybg');
	Element.hide('filter_commission');  
    Element.show('div_to_show');
  }
}


  function MM_swapImgRestore() { //v3.0
    var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
  }

  function MM_preloadImages() { //v3.0
    var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  }

  function MM_findObj(n, d) { //v4.01
    var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
      d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
    if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
    for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
    if(!x && d.getElementById) x=d.getElementById(n); return x;
  }

  function MM_swapImage() { //v3.0
    var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
    if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
  }

  function borderit(which,color){
    if (document.all||document.getElementById){
      which.style.borderColor=color
    }
  }

// adds a drop shadow to a given element
//----------->start
//~ Effect.DropShadow = function(element, width){
	//~ element = $(element);
	
	//~ var i1 = new Element('div', { 'class': 'i1' });
	//~ var i2 = new Element('div', { 'class': 'i2' });
	//~ var i3 = new Element('div', { 'class': 'i3 cf' });
	
	//~ i1.style.width = width;
  //~ i2.style.width = parseInt(width) - 1 + 'px';
  
  //~ i2.appendChild(i3);
	//~ i1.appendChild(i2);
	
	//~ $A(element.childNodes).each(function(e){ i3.appendChild(e); });
	
	//~ var bfunc = function(className){
    //~ var e = new Element('div', { 'class': className });
    //~ e.style.width = parseInt(width) + 6 +'px';
		//~ return e;
	//~ };		
	
	//~ element.addClassName('cp');
	//~ element.appendChild(bfunc('bt'));
	//~ element.appendChild(i1);
	//~ element.appendChild(bfunc('bb'));		
  
//~ };
//----------->end

// Form Validations Start
  // ----------- For Add Commission
  
  function validateResetPasswordForm(){     
    var frm = document.forms["reset_form"];                       
    var passw=frm.elements["user[password]"].value.replace(/^\s/,"");
    var passw_confirm=frm.elements["user[password_confirmation]"].value.replace(/^\s/,"");
    
    if (passw<=0){
      alert('Password cannot be blank.');
      return false;
    }  
    if (passw_confirm<=0){
      alert('Password Confirmation cannot be blank.');
      return false;
    }
    if (passw.length < 4 ){
      alert("Password is too short (minimum is 4 characters)");
      return false;
    }
    if ( passw != passw_confirm ){
      alert("Password and confirmation entered don't match.");
      return false;
    }
  }
  
  function checkArtPrice(formname){
    var frm = document.forms[formname];         
    var p = frm.elements["art[price]"].value.replace(/^\s/,"");
    var editorInstance = tinyMCE.selectedInstance;
    var description = editorInstance.getHTML().replace(/^\s/,"");
    
    var download = frm.elements["art_downloadable"].checked;
    if(formname != 'edit_art_form'){
      var tandc = frm.elements['termsAndConditions'].checked;
    }
    
    if( description.replace(/<\/?[^>]+>/gi, "").replace(/&lt\/?[^>]+&gt;/gi, "").length <= 0 ){
      alert('Art description cannot be blank.');
      return false;
    }
    
    if (download){
      var reg_exp = /^[+]?[0-9]+(\.[0-9]+)?$/;
      if (p<=0){
        alert('Please enter a valid price.');
        return false;
      }  
      if( !p.match(reg_exp) ){
        alert('Please enter a valid price.');
        return false;
      }
    }
    
    if( !tandc && formname != 'edit_art_form' ){
      alert("You must agree to the Content Submissions Agreement.");
      return false;
    }
  }
  
  function checkArtPriceAtSignup(formname){
    var frm = document.forms[formname];         
    var p = frm.elements["art[price]"].value.replace(/^\s/,"");
    var description = frm.elements["description1"].value.replace(/^\s/, "");
    
    var download = frm.elements["art_downloadable"].checked;
    if(formname != 'edit_art_form'){
      var tandc = frm.elements['termsAndConditions'].checked;
    }
    
    if( description.replace(/<\/?[^>]+>/gi, "").replace(/&lt\/?[^>]+&gt;/gi, "").length <= 0 ){
      alert('Art description cannot be blank.');
      return false;
    }
    
    if (download){
      var reg_exp = /^[+]?[0-9]+(\.[0-9]+)?$/;
      if (p<=0){
        alert('Please enter a valid price.');
        return false;
      }  
      if( !p.match(reg_exp) ){
        alert('Please enter a valid price.');
        return false;
      }
    }
    
    if( !tandc && formname != 'edit_art_form' ){
      alert("You must agree to the Content Submissions Agreement.");
      return false;
    }
  }
  
  function validateUploadCommissionSample(){
    var frm = document.forms['upload_commission_sample_form'];
    var editorInstance = tinyMCE.selectedInstance;
    var description = editorInstance.getHTML().replace(/^\s/,"");
    var tandc = frm.elements['termsAndConditions'].checked;
    
    if(!tandc){
      alert("You must agree to the Content Submissions Agreement.");
      return false;
    }
    
    if( description.length <= 0 ){
      alert('Description cannot be blank.');
      return false;
    }
  }
  
  function checkRoyaltyFreeLicense(){
    price = document.getElementById('art_downloadable').checked;
    if(price){
      Element.show('priceDiv');
    }else{
      Element.hide('priceDiv');
    }
  }
  
  function checkCommissionForm(){            
    var frm = document.forms["commission_frm"];        
    var title=frm.elements['title'].value.replace(/^\s/,"");
    var genre=frm.elements['genre'].value.replace(/^\s/,"");
    var medium=frm.elements['medium'].value.replace(/^\s/,"");
    var theme=frm.elements['theme'].value.replace(/^\s/,"");
    //~ var expired_dt=frm.elements['expired_by_date'].value.replace(/^\s/,"");
    var editorInstance = tinyMCE.selectedInstance;
    var desc = editorInstance.getHTML().replace(/^\s/,"");
    var price=frm.elements['price'].value.replace(/^\s/,"");
   
    if (title.length <= 0 || genre.length <= 0 || medium.length <= 0 || theme.length <= 0 || desc.length <= 0 || price.length <= 0){
      alert("Please fill all the data for preview.");     
      return false;
    }       
    
    if( price.length!=0){
      var reg_exp = /^[+]?[0-9]+(\.[0-9]+)?$/;
      if (price<=0){
        alert('Please enter a valid commission price.');
        return false;
      }
      if( !price.match(reg_exp) ){
        alert('Please enter a valid commission price.');
        return false;
      }
    }
    
    $('commission_form_div1').hide;
  }      
  
  //~ // For Voottoo Terms and Conditions
  function acceptTermsAndConditions(formName, from){
    var frm = document.forms[formName];    
    var tandc = frm.elements['termsAndConditions'].checked;
    
    if(from == 'commission'){
      if( formName == 'commission_frm'){
        //~ var expired_dt=frm.elements['expired_by_date'].value.replace(/^\s/,"");
        var editorInstance = tinyMCE.selectedInstance;
        var desc = editorInstance.getHTML().replace(/^\s/,"");
        
        if(desc.length <= 0){
          alert("Description can not be blank.");
          return false;
        }
        //~ if(expired_dt.length <= 0){
          //~ alert("Commission expiry date can not be blank.");
          //~ return false;
        //~ }
      }
      message = "You must agree to the Content License Agreement."
    }else{
      message = "You must agree to the Terms of Use."
    }
    
    if( !tandc ){
      alert(message);
      return false;
    }
  }     

  //~ function confirmAndStartCommission(lowBalance){
    //~ var frm = document.forms["termsAndConditionForm"];         
    //~ if (lowBalance=='true'){
      //~ alert('Please add some credits to your Voottoo account to proceed further.');
      //~ return false;
    //~ }  
    
    //~ return confirm('Are you sure do you really want to start commission with this artist?\n Commission amount will be deducted from your voottoo account.');
  //~ }
  
  function checkDonationPrice(current_user_balance){ 
    var frm = document.forms["donation_form"];         
    var p=frm.elements["amount_1"].value.replace(/^\s/,"");
    var reg_exp = /^[+]?[0-9]+(\.[0-9]+)?$/;
     
    if (p<=0){
      alert('Please enter the valid price to tip.');
      return false;
    }  
    if( !p.match(reg_exp) ){
      alert('Please enter the valid price to tip.');
      return false;
    }
    if ( parseInt( current_user_balance ) <= parseInt(p) ){
      alert("You not having enough balance to tip, Please Add Credit to your account.");
      return false;
    }
    return confirm("Tip amount will be deducted from your Voottoo Account.");
  }

  function checkBidPrice(posted_by){
    var frm = document.forms["bidForm"];      
    var price=frm.elements["bidding_price"].value.replace(/^\s/,"");
    
    if( price.length!=0){
      var reg_exp = /^[+]?[0-9]+(\.[0-9]+)?$/;
      if (price<=0){
        alert('Please enter the valid  bid price.');
        return false;
      }
      if( !price.match(reg_exp) ){
        alert('Please enter the valid bid price.');
        return false;
      }
      if(posted_by=='owner'){
        return confirm('Are you sure do you want to change the ask price for this commission?');
      }
    }
  }

  function checkWorkDoneBidPosting(checkPrice){  
    var frm = document.forms["bidForm"];         
    var editorInstance = tinyMCE.selectedInstance;
    var description = editorInstance.getHTML().replace(/^\s/,"");
    
    if (frm.elements["status"]){
      var status = frm.elements["status"].checked;
    }
    var uploaded_file = frm.elements["upload_bidding"].value;
    
    if( description.length <= 0 ){
      alert('Description can not be blank.');
      return false;
    }
    
    if(status && !uploaded_file){
      return confirm("Are you sure? You have not uploaded any attachment.");
    }
  }
  
  function checkBidPosting(checkPrice, posted_by, last_posted){  
    //~ var frm = document.forms["bidForm"];
    if(last_posted){
      post = confirm("You have already submitted a bid, do you want to a post new bid?");
    }else{
      post = true;
    }
    
    if(post){
      var editorInstance = tinyMCE.selectedInstance;
      var description = editorInstance.getHTML().replace(/^\s/,"");
      
      if( description.length <= 0 ){
        alert('Description can not be blank.');
        return false;
      }
      
      if( checkPrice=='checkprice' ){
        //~ var price=frm.elements["bidding_price"].value.replace(/^\s/,"");
        var price = document.getElementById('bidding_price').value.replace(/^\s/,"");
        if( price.length!=0){
          var reg_exp = /^[+]?[0-9]+(\.[0-9]+)?$/;
          if (price<=0){
            alert('Please enter the valid bid price.');
            return false;
          }
          if( !price.match(reg_exp) ){
            alert('Please enter the valid bid price.');
            return false;
          }
          if(posted_by=='owner'){
            return confirm('Are you sure do you want to change the ask price for this commission?');
          }
        } 
      }
    }else{
      return false;
    }
  }
  
  function checkDescription(last_posted){
    //~ if(last_posted){
      //~ post = confirm("You have already submitted a bid, do you want to a post new bid?");
    //~ }else{
      //~ post = true;
    //~ }
    
    //~ if(post){
      var editorInstance = tinyMCE.selectedInstance;
      var description = editorInstance.getHTML().replace(/^\s/,"");
      
      if( description.length <= 0 ){
        alert('Description cannot be blank.');
        return false;
      }
    //~ }else{
      //~ return false;
    //~ }
    
  }
  
  function checkAcceptanceOfCommission(){
  var frm = document.forms["bidForm"];         
  var desc = tinyMCE.getContent();
  var regex=/<[^>]*>/gi;
  description = desc.replace(regex,"");
  
  if(document.getElementById('work_complete')){
    var checkBoxVal = document.getElementById('work_complete').checked;
  }
  
  if( description.length <= 0 ){
    alert('Description can not be blank.');
    return false;
  }
  
  if(checkBoxVal){
    return confirm("Are you sure? You want to Accept artist work for this commission.");
  }
 }
 
 function displayDonationPopup(e, commission_id){
  var popId = document.getElementById('donationPopup');
  var checkBoxVal = document.getElementById('work_complete').checked;
  if(checkBoxVal){
    popId.style.top = ( e.clientY + document.documentElement.scrollTop - 250 ) + "px" ;
    popId.style.left = "5px";
    new Ajax.Updater('select_artists_div', "/bids/donate_to_voottoo?show=true&commission_id="+commission_id, {asynchronous:true, evalScripts:true, parameters:'display=true'});
  }
 }
  
  function checkTipAmount(current_user_balance){
    var price = document.getElementById('revisedDonationAmount').value;
    var reg_exp = /^[+]?[0-9]+(\.[0-9]+)?$/;
    if (price<=0){
      alert('Please enter a valid tip amount.');
      return false;
    }  
    if( !price.match(reg_exp) ){
      alert('Please enter a valid tip amount.');
      return false;
    }
    if ( parseInt( current_user_balance ) <= parseInt(price) ){
      alert("There is not sufficient balance in your account to tip, please add credit.");
      return false;
    }
    return confirm('Tip amount will be deducted from your Voottoo Account.');
  }
  
  function confirmAndStartCommission(lowBalance, last_bid_price, last_posted){
    if(last_posted){
      post = confirm("The artist has not yet responded to your last ask price, do you want to post a new one?");
    }else{
      post = true;
    }
    
    if(post){
      //~ var editorInstance = tinyMCE.selectedInstance;
      //~ var description = editorInstance.getHTML().replace(/^\s/,"");
      
      if (lowBalance=='true'){
        alert("To proceed further, please add credit to your Voottoo account.");
        return false;
      }  
      
      //~ if( description.length <= 0 ){
        //~ alert('Description can not be blank.');
        //~ return false;
      //~ }
      
      var reply = confirm("Are you sure do you really want to start commission with this artist? Commission amount will be deducted from your voottoo account."); 
      
      if(reply){
        document.getElementById('startCommissionDiv').innerHTML ="<input type='hidden' name='start_commission' value='start'>";
        document.getElementById('finalPriceDiv').innerHTML ="<input type='hidden' name='final_price' value='"+ last_bid_price +"'>";
      }
      
      return reply;
    }else{
      return false;
    }
  }
  
  function postNewAskPrice(last_posted){
    if(last_posted && $('bidding_price').value.length!=0){
      post = confirm("The artist has not yet responded to your last ask price, do you want to post a new one?");
    }else{
      post = true;
    }
    
    if(post){
      var editorInstance = tinyMCE.selectedInstance;
      var description = editorInstance.getHTML().replace(/^\s/,"");
      var price = document.getElementById('bidding_price').value.replace(/^\s/,"");
      
      if( description.length <= 0 && price.length==0){
        alert('Description cannot be blank.');
        return false;
      }
      if( price.length!=0){
        var reg_exp = /^[+]?[0-9]+(\.[0-9]+)?$/;
        if (price<=0){
          alert('Please enter a valid ask price.');
          return false;
        }
        if( !price.match(reg_exp) ){
          alert('Please enter a valid ask price.');
          return false;
        }
        document.getElementById('finalPriceDiv').innerHTML ="<input type='hidden' name='bidding[price]' value='"+ price +"'>";
        
        return confirm("Are you sure you want to change the ask price for this commission?");
      }
    }else{
      return false;
    }
  }
  
  // Validation for add credit Form
  function validation(required_credits){
    var frm = document.forms["paypal_form"];               
    var amt=frm.elements['amount_1'].value.replace(/^\s/,"");
    var reg_exp = /^[+]?[0-9]+(\.[0-9]+)?$/;
   
    if (amt.length <= 0){
      alert("Amount cannot be blank.");
      return false;
    }
   
    if (required_credits != 0 && amt<required_credits){
      alert("You need to add minimum "+required_credits+" dollars to close the current transaction");
      return false;
    }
   
    if( !amt.match(reg_exp) ){
      alert('Please enter a valid amount.');
      return false;
    }
  }
  
  function acceptCLA(){
    var tandc = document.getElementById('termsAndConditions').checked;
    
    if( !tandc ){
      alert("You must agree to the Content License Agreement.");
      return false;
    }
    
   return confirm('Art price will be deducted from your account.');
  }
  
  function payArt(price){
    var tandc = document.getElementById('termsAndConditions').checked;
    
    if( !tandc ){
      alert("You must agree to the Content License Agreement.");
      return false;
    }
    
   return confirm('$'+price+' towards licensing this art will be deducted from your account.');
  }
  
  function acceptPrice(form_name, last_posted){
    if(document.getElementById('termsAndConditions')){
      tandc = document.getElementById('termsAndConditions').checked;
    }else{
      tandc = true;
    }
      
    if(last_posted && $('accept_price').value.length!=0){
      post = confirm("The commissioner has not yet responded to your last bid, do you want to post a new bid?");
    }else{
      post = true;
    }
    
    if(post){
      price = document.getElementById('accept_price').value.replace(/^\s/,"");
      price_valid =  checkBidPost(form_name, price);
      if(price_valid){
        if( !tandc ){
          alert("You must agree to the Content License Agreement.");
          return false;
        } 
        document.getElementById('status').innerHTML ="<input type='hidden' name='status' value='accepted'>";
        document.getElementById('biddingPrice').innerHTML ="<input type='hidden' name='bidding[price]' value="+"'"+price+"'"+">";
        return confirm("Are you sure you want to accept this commission?");
      }else{
        return false;
      }
    }else{
      return false;
    }
  }

  function postNewBidPrice(form_name, last_posted){
    if(tandc = document.getElementById('termsAndConditions')){
      tandc = document.getElementById('termsAndConditions').checked;
    }else{
      tandc = true;
    }
    
    if(last_posted && $('bid_price').value.length!=0){
      post = confirm("The commissioner has not yet responded to your last bid, do you want to post a new bid?");
    }else{
      post = true;
    }
   
    if(post){
      price = document.getElementById('bid_price').value.replace(/^\s/,"");
      price_valid = checkBidPost(form_name, price);
      if(price_valid){
       
        if(!tandc){
          alert("You must agree to the Content License Agreement");
          return false;
        }
       
        document.getElementById('biddingPrice').innerHTML ="<input type='hidden' name='bidding[price]' value="+"'"+price+"'"+">";
      }else{
        return false;
      }
    }else{
      return false;
    }
  }

  function checkBidPost(form_name, price){  
    var frm = document.forms[form_name];             
    var editorInstance = tinyMCE.selectedInstance;
    var description = editorInstance.getHTML().replace(/^\s/,"");
  
    if( description.length <= 0 && price.length==0){
      alert('Description cannot be blank.');
      return false;
    }
    if( price.length!=0){
      var reg_exp = /^[+]?[0-9]+(\.[0-9]+)?$/;
      if (price<=0){
        alert('Please enter a valid  bid price.');
        return false;
      }
      if( !price.match(reg_exp) ){
        alert('Please enter a valid bid price.');
        return false;
      }
    }
    return true;
  }
  
  function displayTipPopup(e, commission_id){   
    var popId = document.getElementById('donationPopup');
    var checkBoxVal = document.getElementById('status').checked;
    if(checkBoxVal){
      popId.style.top = ( e.clientY + document.documentElement.scrollTop - 250 ) + "px" ;
      popId.style.left = "5px";
      new Ajax.Updater('select_artists_div', "/bids/donate_to_voottoo?show=true&commission_id="+commission_id, {asynchronous:true, evalScripts:true, parameters:'display=true'});
    }
  }
  
  function checkAcceptanceOfCommission1(e, commission_id){
    var frm = document.forms["bidForm"];
    var desc = tinyMCE.getContent();
    var regex=/<[^>]*>/gi;
    var description = desc.replace(regex,"");
    
    if(document.getElementById('work_complete')){
      var checkBoxVal = document.getElementById('work_complete').checked;
    }
    
    if( description.length <= 0 ){
      alert('Description cannot be blank.');
      return false;
    }
    
    if(checkBoxVal){
      var reply = confirm("Are you sure you want to accept artist's work for this commission. The artist will be paid and the commission will be marked as 'Completed'"); 
      if(reply){
        var popId = document.getElementById('donationPopup'); 
        popId.style.top = ( e.clientY + document.documentElement.scrollTop - 250 ) + "px" ;
        popId.style.left = "5px";
        new Ajax.Updater('select_artists_div', "/bids/donate_to_voottoo?show=true&commission_id="+commission_id, {asynchronous:true, evalScripts:true, parameters:'display=true'});
        return false;
      }else{
        return false;
      }
    }
  }
  
  function removeTinyMceControl(editorId){
    if(tinyMCE.selectedInstance){
      tinyMCE.execCommand("mceRemoveControl", false, editorId);
    }
  }
  
  function checkWorkDoneBidPosting1(e, commission_id){  
    var reply = true;
    var frm = document.forms["bidForm"];         
    var editorInstance = tinyMCE.selectedInstance;
    var description = editorInstance.getHTML().replace(/^\s/,"");

    if (frm.elements["status"]){
      var status = frm.elements["status"].checked;
    }
    var uploaded_file = frm.elements["upload_bidding"].value;

    if( description.length <= 0 ){
      alert('Description cannot be blank.');
      return false;
    }

    if(status){
      if(!uploaded_file){
        reply = confirm("Are you sure? You have not uploaded an attachment.");
      }
     
      if(reply){
        doantionPopupBox(e, commission_id);
        return false;
      }else{
        return false;
      }
      doantionPopupBox(e, commission_id);
      return false;
    }
  }

  function doantionPopupBox(e, commission_id){
    var popId = document.getElementById('donationPopup');
    popId.style.top = ( e.clientY + document.documentElement.scrollTop - 250 ) + "px" ;
    popId.style.left = "5px";
    new Ajax.Updater('select_artists_div', "/bids/donate_to_voottoo?show=true&commission_id="+commission_id, {asynchronous:true, evalScripts:true, parameters:'display=true'});
  }
  
  function selectArtsPopup(e, img_no){
    var popupDiv = document.getElementById('selectArtsDiv');
    popupDiv.style.top = ( e.clientY + document.documentElement.scrollTop - 150 ) + "px" ;
    popupDiv.style.left = "25px";
    new Ajax.Updater( "/widget/select_banner_arts?image_no="+img_no, {asynchronous:true, evalScripts:true});
  }
  
  function validateSearchOptions(form, mode){
	
	  
    genre = form.elements['genre_select'].value;
    theme = form.elements['theme_select'].value;
    medium = form.elements['medium_select'].value;
    search_box = form.elements['search_box'].value;
    if(mode == 'art')
      size = form.elements['size_select'].value;
    
    if(mode == 'art'){
      if(genre=='select_one' && theme=='select_one' && medium=='select_one' && search_box=='' && size=='select_one')
        return false;
    }else{
      if(genre=='select_one' && theme=='select_one' && medium=='select_one' && search_box=='')
        return false;
    }
  }
  
  
  
  function validSearchOptions(form, mode){
	  
    genre = form.elements['genre_select'].value;
    theme = form.elements['theme_select'].value;
    medium = form.elements['medium_select'].value;
    //search_box = form.elements['search_box'].value;
    //if(mode == 'art')
     // size = form.elements['size_select'].value;
    
    if(mode == 'art'){
      if(genre=='select_one' && theme=='select_one' && medium=='select_one')
	    return false;
    }else{
      if(genre=='select_one' && theme=='select_one' && medium=='select_one')
        return false;
    }
  }
  
  
  
  
  
  
  
  
  
  function checkValidEmails(form_name){
    var form = document.forms[form_name];                       
    var email_format = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    var recipients = form.elements['recipients'].value;
    var sender = form.elements['sender'].value;
    
    if(sender.length != 0){
      if(recipients.length != 0){
        var recipients = recipients.split(",");
        for(i=0; i<recipients.length; i++){
          if(!(recipients[i].replace(/^\s/,"").match(email_format))){
            alert("Email address: '" + recipients[i] + "' is invalid");
            return false;
          }
        }
      }else{
        alert("Please enter email id / ids.");
        return false;
      }
    }else{
      alert("Enter You Name.");
      return false;
    }
  }
  
function checkSuspendNote(form_obj){
  note = form_obj['suspend_note'].value.replace(/^\s/,"");
  if(note.length<=0){
    alert('Suspend note can not be blank.'); 
    return false;
  }
}

function validate_file(){
  file = $('upload').value;
  if(file==''){
    alert("Image can not be blank");
    return false;
  }
}
  
  //~ function setTransparentImage(imageDiv, tranImageDiv){
    //~ var nAgt = navigator.userAgent;
    //~ if ((verOffset=nAgt.indexOf("Firefox"))!=-1){ 
      //~ mainImageDiv = document.getElementById(imageDiv);
      //~ transparentImage = document.getElementById(tranImageDiv);
      
      //~ mainHeight = mainImageDiv.offsetHeight + 2;
      //~ mainWidth = mainImageDiv.offsetWidth + 2;
      //~ mainLeft = mainImageDiv.offsetLeft;
      //~ mainTop = mainImageDiv.offsetTop;
      
      //~ transparentImage.style.width = mainWidth + 'px';
      //~ transparentImage.style.height = mainHeight + 'px';
      //~ transparentImage.style.left = mainLeft + 'px';
      //~ transparentImage.style.top = mainTop + 'px';
      //~ transparentImage.style.backgroundImage = "url(/images/small_transparent.gif.)";
      //~ transparentImage.style.imageImage = 'repeat';
      //~ transparentImage.style.position = 'absolute';
      //~ transparentImage.style.zIndex='100';
    //~ }
  //~ }
  
//----------->end